:root {
  --bg: #e7e0d6;
  --bg-deep: #111827;
  --shell: #0d1522;
  --shell-soft: #142033;
  --shell-card: #101c2c;
  --shell-line: rgba(123, 162, 214, 0.2);
  --paper: #fffaf2;
  --paper-line: rgba(48, 54, 68, 0.12);
  --paper-shadow: 0 28px 60px rgba(38, 30, 18, 0.16);
  --ink: #1f2937;
  --ink-soft: #596579;
  --white: #f8fafc;
  --accent: #86b8ff;
  --accent-strong: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --good: #2fbf71;
  --good-soft: rgba(47, 191, 113, 0.16);
  --bad: #ef5b67;
  --bad-soft: rgba(239, 91, 103, 0.16);
  --warm: #ffd7a0;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-shell: 0 24px 50px rgba(14, 18, 24, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(134, 184, 255, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(255, 215, 160, 0.12), transparent 20%),
    linear-gradient(180deg, var(--bg) 0%, #ddd3c6 100%);
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1560px, calc(100vw - 28px));
  margin: 14px auto 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  padding: 18px 22px;
  margin-bottom: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-xl);
  background: rgba(255, 250, 242, 0.72);
  box-shadow: 0 18px 36px rgba(52, 41, 24, 0.1);
  backdrop-filter: blur(18px);
}

.brand-block h1,
.preview-header h2 {
  margin: 0;
}

.brand-block h1 {
  font-size: 1.45rem;
  letter-spacing: -0.04em;
}

.eyebrow,
.field span,
.mini-label {
  display: block;
  color: var(--ink-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-controls,
.thread-actions,
.toggle-row,
.preview-meta,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.topbar-controls {
  align-items: end;
  justify-content: flex-end;
}

.split-shell {
  display: grid;
  grid-template-columns: minmax(420px, 0.88fr) minmax(420px, 1.12fr);
  gap: 16px;
  align-items: start;
}

.agent-shell {
  display: grid;
  gap: 14px;
}

.thread-message,
.preview-shell {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-shell);
}

.thread-message {
  position: relative;
  padding: 18px 18px 20px;
  border: 1px solid var(--shell-line);
  background: var(--shell-card);
  color: var(--white);
  overflow: hidden;
}

.thread-message::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(134, 184, 255, 0.06), transparent 40%);
}

.system-message {
  background: linear-gradient(180deg, #101c2c 0%, #0c1624 100%);
}

.user-message {
  background: linear-gradient(180deg, #162233 0%, #101827 100%);
}

.accent-message {
  border-color: rgba(255, 215, 160, 0.18);
}

.message-label {
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(134, 184, 255, 0.08);
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: lowercase;
}

.thread-title,
.preview-header h2 {
  margin: 0 0 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
  line-height: 1.45;
}

.thread-copy {
  margin: 0;
  color: rgba(226, 232, 240, 0.78);
  line-height: 1.6;
}

.subtle-copy {
  color: rgba(226, 232, 240, 0.6);
}

.field {
  display: grid;
  gap: 8px;
}

.compact-field {
  min-width: 0;
}

.grid-two,
.grid-three,
.console-grid,
.path-grid {
  display: grid;
  gap: 12px;
}

.grid-two,
.path-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-three,
.console-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(123, 162, 214, 0.18);
  border-radius: var(--radius-md);
  background: rgba(10, 17, 28, 0.56);
  color: var(--white);
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: rgba(226, 232, 240, 0.42);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(134, 184, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

button {
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, #8bbcff 0%, #4b87e7 100%);
  color: #08111f;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
  box-shadow: 0 10px 18px rgba(75, 135, 231, 0.24);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button.secondary,
.toggle-button {
  background: rgba(255, 255, 255, 0.06);
  color: var(--white);
  border: 1px solid rgba(123, 162, 214, 0.16);
  box-shadow: none;
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.inline-toggle {
  display: flex;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid rgba(123, 162, 214, 0.14);
  border-radius: var(--radius-md);
  background: rgba(134, 184, 255, 0.04);
  color: rgba(226, 232, 240, 0.8);
}

.inline-toggle input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
  padding: 0;
}

.console-panel,
.question-card,
.bullet-option,
.section-row,
.provenance-card,
.editor-card {
  padding: 14px;
  border: 1px solid rgba(123, 162, 214, 0.14);
  border-radius: var(--radius-lg);
  background: rgba(7, 14, 24, 0.28);
}

.stack-list,
.question-list,
.bullet-option-list,
.provenance-list {
  display: grid;
  gap: 12px;
}

.question-card p,
.bullet-option p,
.provenance-card p,
.provenance-card ul {
  margin: 0;
}

.tag-row + .tag-row,
.chip-block + .chip-block {
  margin-top: 12px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.tag,
.chip {
  background: rgba(134, 184, 255, 0.12);
  color: var(--accent);
}

.tag.soft,
.chip.soft {
  background: rgba(255, 215, 160, 0.12);
  color: var(--warm);
}

.bullet-option {
  cursor: pointer;
}

.bullet-option.active {
  border-color: rgba(134, 184, 255, 0.34);
  background: rgba(59, 130, 246, 0.12);
}

.bullet-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.section-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.provenance-card ul {
  margin-top: 10px;
  padding-left: 18px;
  color: rgba(226, 232, 240, 0.72);
}

.preview-shell {
  position: sticky;
  top: 14px;
  padding: 22px;
  border: 1px solid var(--paper-line);
  background: var(--paper);
  box-shadow: var(--paper-shadow);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.preview-header h2 {
  color: var(--ink);
  font-size: 1rem;
}

.preview-meta {
  margin-top: 14px;
  align-items: center;
}

.status-pill,
.meta-pill,
.legend-pill,
.toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.status-pill {
  background: rgba(47, 191, 113, 0.14);
  color: #17603a;
}

.meta-pill {
  background: rgba(31, 41, 55, 0.08);
  color: var(--ink-soft);
}

.meta-pill.muted {
  opacity: 0.75;
}

.toggle-button {
  background: rgba(31, 41, 55, 0.06);
  color: var(--ink-soft);
}

.toggle-button.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-strong);
  border-color: rgba(59, 130, 246, 0.18);
}

.legend-pill {
  background: rgba(31, 41, 55, 0.06);
  color: var(--ink-soft);
}

.legend-pill.selected {
  background: var(--good-soft);
  color: #1d7d47;
}

.legend-pill.rejected {
  background: var(--bad-soft);
  color: #b53b4b;
}

.preview-copy {
  margin: 16px 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.resume-preview {
  min-height: 640px;
  max-height: calc(100vh - 290px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86) 0%, rgba(255, 249, 241, 0.98) 100%);
}

.preview-empty {
  padding: 40px 18px;
  color: var(--ink-soft);
  text-align: center;
}

.document-head h3,
.section-block h4 {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
}

.document-head {
  margin-bottom: 20px;
}

.document-head h3 {
  font-size: 1.45rem;
}

.document-head p {
  margin: 10px 0 0;
  color: var(--ink-soft);
}

.section-block + .section-block {
  margin-top: 22px;
}

.section-block h4 {
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 0.95rem;
}

.entry-card {
  padding: 14px 0;
  border-top: 1px solid rgba(31, 41, 55, 0.08);
}

.entry-card:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.entry-heading {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.entry-role {
  margin: 4px 0 10px;
  color: var(--ink);
  font-weight: 700;
}

.bullet-list {
  display: grid;
  gap: 8px;
  padding-left: 0;
  margin: 0;
  list-style: none;
}

.bullet-item {
  position: relative;
  padding: 10px 12px 10px 18px;
  border-radius: 12px;
  background: rgba(31, 41, 55, 0.04);
  color: var(--ink);
  line-height: 1.6;
}

.bullet-item::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 17px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: rgba(31, 41, 55, 0.4);
}

.bullet-item.selected {
  background: var(--good-soft);
  color: #164b2e;
}

.bullet-item.selected::before {
  background: var(--good);
}

.bullet-item.rejected {
  background: var(--bad-soft);
  color: #7d2633;
}

.bullet-item.rejected::before {
  background: var(--bad);
}

.body-line {
  margin: 6px 0 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.preview-export,
.editor-card {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(31, 41, 55, 0.08);
}

.preview-shell .field span,
.preview-shell .mini-label,
.preview-shell .eyebrow {
  color: var(--ink-soft);
}

.preview-shell button.secondary {
  background: rgba(31, 41, 55, 0.06);
  color: var(--ink);
  border: 1px solid rgba(31, 41, 55, 0.12);
}

.preview-shell input,
.preview-shell textarea,
.preview-shell select {
  background: rgba(31, 41, 55, 0.04);
  color: var(--ink);
  border-color: rgba(31, 41, 55, 0.12);
}

.preview-shell textarea {
  min-height: 280px;
}

@media (max-width: 1260px) {
  .split-shell {
    grid-template-columns: 1fr;
  }

  .preview-shell {
    position: static;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 14px, 100%);
    margin: 8px auto 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-controls {
    justify-content: flex-start;
  }

  .grid-two,
  .grid-three,
  .console-grid,
  .path-grid {
    grid-template-columns: 1fr;
  }

  .preview-header,
  .section-row {
    grid-template-columns: 1fr;
  }

  .resume-preview {
    max-height: none;
    min-height: 420px;
    padding: 18px;
  }
}
