:root {
  --ink: #1f2520;
  --muted: #667066;
  --paper: #fbfaf5;
  --panel: #ffffff;
  --line: #ded8c8;
  --green: #3d6b4b;
  --moss: #849164;
  --sun: #d9a441;
  --rose: #b76a5b;
  --shadow: 0 18px 50px rgba(44, 50, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Nunito Sans", Verdana, sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(217, 164, 65, 0.18), transparent 26rem),
    linear-gradient(135deg, #f7f2e6 0%, #edf3e5 48%, #f7ece7 100%);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

.workspace {
  display: grid;
  gap: 22px;
}

.intro h1,
.result-header h2 {
  max-width: 760px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: 0;
}

.result-header h2 {
  font-size: clamp(1.6rem, 3vw, 2.6rem);
}

.eyebrow,
.meta {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel,
.card,
.status {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(222, 216, 200, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 118px;
  padding: 14px;
  resize: vertical;
}

select {
  min-width: 170px;
  padding: 11px 12px;
}

textarea:focus,
select:focus {
  outline: 2px solid rgba(61, 107, 75, 0.22);
  border-color: var(--green);
}

.mode-option {
  cursor: pointer;
}

.mode-label {
  display: flex;
  align-items: center;
  min-height: 48px;
  border: 1px solid rgba(132, 145, 100, 0.35);
  border-radius: 8px;
  padding: 10px 14px;
  color: #40513f;
  background: #f9f7ef;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.35;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.mode-label:hover {
  background: #fff;
  border-color: rgba(61, 107, 75, 0.45);
  transform: translateY(-1px);
}

.mode-label.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 4px 14px rgba(61, 107, 75, 0.25);
}

.chips,
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips button,
.tags span {
  min-height: 34px;
  border: 1px solid rgba(132, 145, 100, 0.4);
  border-radius: 999px;
  padding: 7px 12px;
  color: #40513f;
  background: #f4f4e9;
  font-weight: 700;
}

.chips button {
  cursor: pointer;
}

.controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.select-label {
  display: grid;
  gap: 6px;
}

#submit-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: white;
  background: var(--green);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

#submit-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.status {
  padding: 16px;
  color: #4c543f;
  background: #fff8df;
}

.results {
  display: grid;
  gap: 16px;
}

.result-header {
  margin-top: 10px;
}

.trend {
  white-space: pre-line;
  color: var(--muted);
}

.card {
  padding: 18px;
}

.card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.card h3 {
  margin: 0;
  max-width: 760px;
  font-size: 1.15rem;
  line-height: 1.35;
}

.score {
  min-width: 108px;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  background: var(--paper);
  color: var(--green);
  font-size: 1.25rem;
  font-weight: 900;
}

.score span {
  display: block;
  margin-bottom: 2px;
}

.score.small {
  min-width: 72px;
  font-size: 0.95rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.metric-grid div {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fcfbf7;
}

.metric-grid span,
dt {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-grid b {
  display: block;
  margin-top: 8px;
  font-size: 1.25rem;
}

.action {
  margin-top: 16px;
  border-left: 4px solid var(--sun);
  padding: 10px 12px;
  background: #fff9e9;
}

.action p,
.reason {
  margin: 6px 0 0;
  line-height: 1.55;
}

.reason {
  color: var(--muted);
}

details {
  margin-top: 16px;
}

summary {
  cursor: pointer;
  font-weight: 800;
}

/* ── Post details expandable ─────────────────────────────── */
.post-details {
  margin-top: 14px;
  border-radius: 10px;
  border: 1px solid #d4e0c8;
  overflow: hidden;
}

.post-details-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #465246;
  background: #f4f9f0;
  list-style: none;
  user-select: none;
}

.post-details-summary::before {
  content: "▶";
  font-size: 10px;
  color: #8aaa7a;
  transition: transform 0.2s ease;
}

.post-details[open] > .post-details-summary::before {
  transform: rotate(90deg);
}

.post-details-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafef8;
}

.detail-row-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fff;
  border: 1px solid #d4e0c8;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  flex: 1;
  min-width: 120px;
}

.detail-chip-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7c836e;
}

.detail-block {
  font-size: 13px;
  line-height: 1.6;
  color: #3a4a38;
}

.detail-block b {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7c836e;
  margin-bottom: 3px;
}

.detail-pre {
  margin: 4px 0 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: #3a4a38;
}

/* ── Content suggestion block ─────────────────────────────── */
.content-suggestion-block {
  border-radius: 10px;
  border: 1.5px solid #8aaa7a;
  background: linear-gradient(135deg, #edf7e4 0%, #f7fbf2 100%);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.content-suggestion-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #3a6030;
}

.suggestion-part {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.suggestion-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #5a7a4a;
}

.suggestion-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: #2a3828;
  font-style: italic;
  background: rgba(255,255,255,0.7);
  border-radius: 6px;
  padding: 8px 10px;
  border-left: 3px solid #8aaa7a;
}

.suggestion-reason {
  margin: 0;
  font-size: 11.5px;
  color: #5a6e50;
  font-style: normal;
  border-top: 1px solid #c8e0b8;
  padding-top: 8px;
}

.trend-reason-block {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fcd34d;
  border-left: 3px solid #f59e0b;
  border-radius: 8px;
  padding: 10px 14px;
}
.trend-reason-block b {
  color: #92400e;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.trend-reason-block p {
  color: #78350f;
  font-size: 13px;
  margin: 4px 0 0;
}

.learning-report {
  margin: 16px 0 0;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre-wrap;
  line-height: 1.55;
  background: #f8f5eb;
  font-family: "Avenir Next", Verdana, sans-serif;
}

.card.good {
  border-color: rgba(61, 107, 75, 0.35);
}

.card.test,
.card.improve {
  border-color: rgba(217, 164, 65, 0.45);
}

.card.rewrite {
  border-color: rgba(183, 106, 91, 0.42);
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 22px, 1120px);
    padding-top: 18px;
    padding-bottom: 40px;
  }

  .workspace {
    gap: 14px;
  }

  .panel {
    padding: 14px;
  }

  .card-top,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .score {
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid b {
    font-size: 1.05rem;
  }

  .mode-label {
    min-height: 42px;
    font-size: 0.82rem;
    padding: 8px 12px;
  }

  #submit-btn {
    width: 100%;
  }

  .intro h1 {
    font-size: clamp(1.6rem, 7vw, 2.8rem);
  }

  #analysis-console {
    font-size: 0.78rem;
  }
}
