/* ============================================================
   Letter Assistant — academic, restrained design system
   ============================================================ */

:root {
  /* Surfaces — mint / white */
  --bg-page: #DCEAE2;
  --bg: #E8F1EB;
  --surface: #F2F8F4;
  --surface-2: #FBFEFC;
  --surface-3: #FFFFFF;

  /* Ink — deep navy */
  --ink: #0A2540;
  --ink-2: #1C3A5C;
  --ink-3: #3E5C7D;
  --muted: #6B8390;
  --subtle: #9DB0B9;

  /* Lines */
  --line: #BFD9CC;
  --line-soft: #D6E7DC;
  --line-strong: #95B8A6;

  /* Accent — teal / turquoise */
  --accent: #0F766E;
  --accent-hover: #0B5C56;
  --accent-soft: #14B8A6;
  --accent-tint: #CFEFE9;
  --accent-tint-border: #8FD6CE;

  /* Status */
  --good: #16A34A;
  --warn: #B45309;
  --info: #1E40AF;

  /* Citation highlight — lime */
  --hl: rgba(132, 204, 22, 0.30);
  --hl-strong: rgba(132, 204, 22, 0.60);
  --hl-line: #65A30D;

  /* Type */
  --serif: 'Source Serif 4', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Radii (modest — academic) */
  --r-sm: 3px;
  --r: 5px;
  --r-md: 8px;
  --r-lg: 12px;

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(10, 37, 64, 0.06), 0 1px 1px rgba(10, 37, 64, 0.04);
  --shadow-2: 0 2px 8px rgba(10, 37, 64, 0.08), 0 1px 2px rgba(10, 37, 64, 0.04);
  --shadow-3: 0 10px 30px rgba(10, 37, 64, 0.14), 0 2px 6px rgba(10, 37, 64, 0.06);

  /* Sizing */
  --side: 320px;
  --notes: 320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

#root { min-height: 100vh; }

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin: 0;
}
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }

.eyebrow {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Top bar ---------- */
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  background: var(--surface-3);
}
.brand small {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: 6px;
  font-weight: 500;
}

.mode-switch {
  margin-left: auto;
  display: flex;
  background: var(--bg-page);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.mode-switch button {
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.mode-switch button.active {
  background: var(--ink);
  color: var(--surface);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--sans);
  font-size: 13px;
  white-space: nowrap;
  font-weight: 500;
  border: 1px solid var(--line-strong);
  background: var(--surface-3);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--r);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: translateY(0.5px); }
.btn-primary {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.btn-primary:hover { background: #051A2E; }
.btn-accent {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-3);
}
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; width: 28px; height: 28px; justify-content: center; }

/* ---------- Inputs ---------- */
.input, .textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { resize: vertical; min-height: 96px; font-family: var(--sans); }
.input:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}
.input::placeholder, .textarea::placeholder { color: var(--subtle); }
.tag-late{font-size:10px;font-family:var(--mono);color:#92400E;background:#FEF3C7;border:1px solid #FDE68A;border-radius:4px;padding:2px 6px;letter-spacing:0.05em;white-space:nowrap}
.cited.uncited{border-bottom:1.5px dotted #D97706}
.cited.uncited.ok{border-bottom:1.5px dotted var(--line-strong)}
.flag-mark{font-size:10px;color:#D97706;vertical-align:super;margin-left:2px;font-family:var(--sans)}
.flag-mark.ok{color:var(--muted)}
@media print{
  .topbar,.workspace-tabs,.no-print,aside{display:none!important}
  .app-shell,.app-shell main{height:auto!important;overflow:visible!important}
  .workspace-grid{display:block!important;height:auto!important;overflow:visible!important}
  main.workspace-pane{overflow:visible!important;padding:0!important;background:#fff!important}
  .letter-article{border:none!important;box-shadow:none!important;padding:0!important;background:#fff!important}
  .cite-mark,.flag-mark{display:none!important}
  .cited.uncited{border-bottom:none!important}
}
.inbox-grid { display: grid; grid-template-columns: 2fr 2fr 1.2fr 1fr 90px; align-items: center; column-gap: 16px; }
button.inbox-grid { width: 100%; box-sizing: border-box; border: none; background: transparent; font: inherit; color: inherit; text-align: left; }
.blank-page:empty::before{content:attr(data-placeholder);color:var(--subtle);font-style:italic;pointer-events:none}

.label {
  display: block;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: 0.005em;
}
.help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  font-family: var(--sans);
  line-height: 1.45;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.chip.active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.chip.tag {
  cursor: default;
  background: var(--accent-tint);
  border-color: var(--accent-tint-border);
  color: var(--accent);
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

/* ---------- Citation marker ---------- */
.cite-mark {
  display: inline-block;
  font-family: var(--sans);
  font-size: 9.5px;
  font-weight: 600;
  color: #14532D;
  background: #ECFCCB;
  border: 1px solid #BEF264;
  border-radius: 3px;
  padding: 0 4px;
  line-height: 14px;
  margin: 0 2px;
  vertical-align: super;
  cursor: pointer;
  transition: all 0.1s;
}
.cite-mark:hover, .cite-mark.active {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}

/* Highlight bands used by hover-to-cite */
.cited {
  background: transparent;
  border-radius: 2px;
  transition: background 0.15s;
  cursor: default;
  padding: 0 1px;
}
.cited.hl {
  background: var(--hl);
  box-shadow: 0 0 0 1px var(--hl-strong);
}

.evidence-item.hl {
  background: var(--hl);
  border-color: var(--hl-line);
  box-shadow: 0 0 0 1px var(--hl-strong);
}

/* ---------- Misc ---------- */
.divider {
  height: 1px;
  background: var(--line-soft);
  border: 0;
  margin: 0;
}
.scroll {
  overflow-y: auto;
}
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb {
  background: rgba(10, 37, 64, 0.18);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.scroll::-webkit-scrollbar-thumb:hover { background: rgba(10, 37, 64, 0.36); background-clip: padding-box; border: 2px solid transparent; }

.tooltip {
  position: absolute;
  background: var(--ink);
  color: var(--surface);
  font-size: 11.5px;
  padding: 5px 8px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
  box-shadow: var(--shadow-2);
}

/* Page max-width wrapper */
.page-wrap {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

/* ============================================================
   Mobile / narrow-viewport adaptation
   ============================================================ */

/* Wizard grid: stepper above form on narrow viewports */
.wizard-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
  align-items: start;
}
.wizard-stepper-sticky {
  position: sticky;
  top: 80px;
}
.wizard-step-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Workspace tabbar — only shown on mobile */
.workspace-tabs {
  display: none;
  position: sticky;
  top: 56px;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 6px 12px;
  gap: 4px;
}
.workspace-tab {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  padding: 9px 8px;
  border-radius: var(--r);
  cursor: pointer;
  letter-spacing: 0.01em;
}
.workspace-tab.active {
  background: var(--accent);
  color: #fff;
}

/* App shell: drop the desktop min-width when narrow */
.app-shell { min-width: 1280px; }

@media (max-width: 1100px) {
  .app-shell { min-width: 0; }

  /* Wizard becomes single column with stepper on top */
  .wizard-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .wizard-stepper-sticky {
    position: static;
  }
  .wizard-step-list {
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 4px;
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .wizard-step-list li { flex-shrink: 0; }

  /* Workspace: hide grid columns, show tabs */
  .workspace-tabs { display: flex; }
  .workspace-grid {
    grid-template-columns: 1fr !important;
    height: auto !important;
  }
  .workspace-pane {
    border-left: 0 !important;
    border-right: 0 !important;
  }
  .workspace-pane.is-hidden { display: none !important; }

  /* Inbox: collapse extra columns */
  .inbox-grid { grid-template-columns: 1.5fr 1fr 100px !important; }
  .inbox-hide-md { display: none !important; }

  /* Topbar: simplify */
  .brand small { display: none; }
  .topbar-meta > span:first-child { display: none; }
  .topbar { padding: 0 14px; gap: 12px; }

  /* Page wrap padding tighter */
  .page-wrap { padding: 18px 14px; }
}

@media (max-width: 600px) {
  /* Letter article on phone */
  .letter-article {
    padding: 32px 22px !important;
    font-size: 15px !important;
  }
  .letter-page { padding: 18px !important; }
  /* Modal becomes single column, scrolls */
  .resume-modal {
    grid-template-columns: 1fr !important;
    max-height: calc(100vh - 24px) !important;
  }
  .resume-modal-extracts {
    border-left: 0 !important;
    border-top: 1px solid var(--line) !important;
  }
}
