:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #fffdf8;
  --panel-strong: #f1eee6;
  --ink: #1f2428;
  --muted: #68706a;
  --line: #d9d2c4;
  --accent: #166a72;
  --accent-dark: #0f4d55;
  --rose: #8c4351;
  --gold: #a76f18;
  --shadow: 0 18px 45px rgba(31, 36, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1480px;
  margin: 0 auto;
}

.input-panel,
.output-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  align-self: start;
  position: sticky;
  top: 24px;
  padding: 20px;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-size: 22px;
  line-height: 1.18;
}

h3 {
  font-size: 16px;
  line-height: 1.25;
}

.person-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.field input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(22, 106, 114, 0.14);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  flex: 1;
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  background: var(--panel-strong);
  border-color: var(--line);
  color: var(--ink);
  padding: 0 12px;
}

.ghost-button:hover {
  border-color: var(--accent);
}

.output-panel {
  min-height: calc(100vh - 48px);
  padding: 20px;
}

.empty-state {
  display: grid;
  min-height: 300px;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.report-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}

.report-header p {
  color: var(--muted);
  margin-bottom: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.code-card,
.analysis-band,
.plain-report {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.code-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.code-card.primary {
  border-color: rgba(22, 106, 114, 0.45);
}

.role-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.code-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.code-number {
  color: var(--accent-dark);
  font-size: 32px;
  font-weight: 850;
}

.code-name {
  font-size: 18px;
  font-weight: 800;
}

.metric-list {
  display: grid;
  gap: 8px;
}

.metric {
  display: grid;
  gap: 3px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.metric b {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.metric span {
  line-height: 1.42;
}

.analysis-band {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.analysis-block {
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-strong);
}

.analysis-block ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.strategy-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.strategy-list li::marker {
  color: var(--gold);
  font-weight: 800;
}

.plain-report {
  margin-top: 14px;
  overflow: hidden;
}

.plain-report-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.plain-report-header h3 {
  margin-bottom: 0;
}

textarea {
  display: block;
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border: 0;
  resize: vertical;
  color: var(--ink);
  background: #fff;
  line-height: 1.45;
}

.error-box {
  border: 1px solid rgba(140, 67, 81, 0.45);
  border-radius: 8px;
  background: rgba(140, 67, 81, 0.08);
  color: var(--rose);
  padding: 14px;
}

@media (max-width: 980px) {
  .workspace,
  .card-grid,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
  }

  .output-panel {
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  .title-row,
  .report-header,
  .plain-report-header {
    grid-template-columns: 1fr;
    display: grid;
  }

  h1 {
    font-size: 24px;
  }

  .actions {
    flex-direction: column;
  }
}
