/* app.css — one white card floating on warm grey.
   The lens colour never floods a surface; it lives in the tab dot, the
   highlights, the caret and the numbers. Everything structural is neutral.
   The only hard rule in here: .backdrop and textarea must stay
   metrically identical, or the highlights drift off the words. */

:root {
  --space: #eae9e4;   /* the warm-grey canvas behind everything */
  --paper: #ffffff;   /* the writing card */
  --paper-2: #f4f3f0; /* chips, quiet fills */
  --ink: #1d1d1f;
  --muted: #86868b;
  --faint: #b9b8b4;
  --hair: #e8e7e3;
  --lens: #3a6ea5;
  --lens-fill: rgba(58, 110, 165, 0.20);
  --lens-line: rgba(58, 110, 165, 0.50);
  --lens-soft: rgba(58, 110, 165, 0.12);

  /* Both text layers read from these. Change one, change both. */
  --type: 16px;
  --leading: 1.7;

  /* --face is the WRITING surface. --ui is everything else.
     To write in sans too, set --face to var(--ui). */
  --face: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas,
          'Courier New', monospace;
  --ui: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto,
        'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--space);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
}

.stage {
  max-width: 1040px;
  margin: 0 auto;
  padding: 30px 22px 60px;
  position: relative;
}

/* ---- the line above the card ---------------------------------------- */

.topline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 18px;
  color: var(--muted);
  font-size: 12.5px;
}

.topline .brand {
  color: #a6a5a1;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
  margin-right: 4px;
}

.topline input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
  outline: none;
}
.topline input::placeholder { color: var(--faint); font-weight: 400; }

.topline button {
  flex: 0 0 auto;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 999px;
  color: #55555a;
  font: inherit;
  font-size: 12px;
  padding: 6px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.topline button:hover {
  color: var(--ink);
  border-color: #d4d3cf;
}

/* ---- tabs: a row of quiet pills -------------------------------------- */

.tabsrow {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 3;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  flex: 0 0 auto;
  font: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* Resting: white pill, hairline edge, the lens colour as a small dot.
   Active: the pill turns charcoal — the colour stays in the dot. */
.tab-body {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: #55555a;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transition: box-shadow 0.15s;
}

.tab:not(.active):hover .tab-body {
  color: var(--ink);
  border-color: #d4d3cf;
}

.tab.active .tab-body {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
  font-weight: 600;
}

/* ---- the card -------------------------------------------------------- */

.pane {
  background: var(--paper);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 22px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 560px;
  box-shadow: 0 1px 2px rgba(29, 29, 31, 0.04), 0 18px 44px rgba(29, 29, 31, 0.07);
  overflow: hidden;
}

/* Inner wrapper kept for structure; the pane itself is the card now. */
.card {
  background: transparent;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ---- version rail ---------------------------------------------------- */

/* Rail and overlay give up space before the text column does. */
.rail {
  width: 0;
  overflow: hidden;
  border-right: 1px solid transparent;
  transition: width 0.16s;
  flex: 0 1 auto;
  min-width: 0;
}
.rail.open {
  width: 172px;
  border-right-color: var(--hair);
}
.rail-inner { padding: 22px 14px; width: 172px; }
.rail h4 {
  margin: 0 0 10px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.ver {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 11.5px;
  background: transparent;
  border: 0;
  border-left: 2px solid var(--hair);
  padding: 5px 8px;
  margin-bottom: 2px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0 6px 6px 0;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.ver:hover { color: var(--ink); border-left-color: var(--lens); background: var(--paper-2); }
.ver .d { color: var(--lens); }
.rail .empty { font-size: 11px; color: var(--muted); line-height: 1.6; }

/* ---- the document ---------------------------------------------------- */

.doc {
  flex: 1 0 auto;
  min-width: 300px;
  max-width: 100%;
  padding: 36px 38px 12px 14px;
}

.block { display: flex; align-items: flex-start; margin-bottom: 4px; }

.gutter {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  padding-top: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}
.block:hover .gutter, .block.focused .gutter { opacity: 1; }

.gutter button {
  font: inherit;
  font-size: 11px;
  line-height: 1;
  background: transparent;
  border: 0;
  color: var(--faint);
  cursor: pointer;
  padding: 2px 3px;
  border-radius: 4px;
}
.gutter button:hover { color: var(--ink); background: var(--paper-2); }
.gutter .num {
  font-size: 10px;
  color: var(--faint);
  width: 14px;
  text-align: right;
}

.layers { position: relative; flex: 1; min-width: 0; padding-left: 10px; }

/* THE CRITICAL PAIR — identical metrics, or highlights drift. */
.backdrop,
.layers textarea {
  font-family: var(--face);
  font-size: var(--type);
  line-height: var(--leading);
  font-weight: 400;
  letter-spacing: 0;
  padding: 1px 0;
  margin: 0;
  border: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  text-align: left;
  text-indent: 0;
  tab-size: 4;
}

.backdrop {
  position: absolute;
  top: 0;
  left: 10px;
  right: 0;
  bottom: 0;
  color: transparent;
  pointer-events: none;
  overflow: hidden;
  user-select: none;
}

.layers textarea {
  position: relative;
  display: block;
  width: 100%;
  background: transparent;
  color: var(--ink);
  resize: none;
  overflow: hidden;
  outline: none;
  caret-color: var(--lens);
}

.layers textarea::placeholder { color: var(--faint); }

.block.h .backdrop,
.block.h .layers textarea {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.4;
}
.block.h { margin-top: 18px; margin-bottom: 8px; }

/* highlight styles — all keyed off the active lens colour */
.backdrop mark {
  background: transparent;
  color: transparent;
  border-radius: 3px;
}
.backdrop mark.m-fill { background: var(--lens-fill); }
.backdrop mark.m-line { box-shadow: inset 0 -2px 0 0 var(--lens-line); }
.backdrop mark.m-good {
  background: var(--lens-fill);
  box-shadow: inset 0 -2px 0 0 var(--lens);
}
.backdrop mark.deliberate {
  background: transparent;
  box-shadow: inset 0 -1px 0 0 var(--hair);
}
.backdrop mark.sel { background: var(--lens-line); }

/* voice · Van Edwards cue words — fixed semantic colours, not lens-keyed */
.backdrop mark.m-warm { background: rgba(238, 153, 46, 0.28); }
.backdrop mark.m-strong { background: rgba(84, 150, 199, 0.26); }
.backdrop mark.m-charisma {
  background: linear-gradient(90deg, rgba(238, 153, 46, 0.26), rgba(84, 150, 199, 0.26));
}
.backdrop mark.m-danger { box-shadow: inset 0 -2px 0 0 rgba(190, 84, 70, 0.9); }

/* ---- overlay panel --------------------------------------------------- */

.overlay {
  width: 0;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid transparent;
  transition: width 0.16s;
}
.overlay.open { width: 318px; border-left-color: var(--hair); }
.overlay-inner { width: 318px; padding: 22px 20px 24px; max-height: 620px; overflow-y: auto; }

.ov-switch { display: flex; gap: 4px; margin-bottom: 14px; }
.ov-switch button {
  font: inherit;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  cursor: pointer;
}
.ov-switch button.on { color: var(--paper); background: var(--ink); border-color: var(--ink); }

.ov h4 {
  margin: 0 0 4px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.ov p.hint { margin: 0 0 14px; font-size: 11.5px; line-height: 1.6; color: var(--muted); }

/* structure spine */
.spine-row {
  display: flex;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--hair);
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
}
.spine-row:hover .spine-text { color: var(--lens); }
.spine-row .n { color: var(--faint); flex: 0 0 16px; font-size: 10px; padding-top: 2px; }
.spine-text { flex: 1; }
.spine-meta { font-size: 10px; color: var(--muted); margin-top: 3px; }
.flagchip {
  display: inline-block;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--lens-line);
  color: var(--lens);
  border-radius: 999px;
  padding: 0 6px;
  margin-right: 4px;
}
.spine-row select {
  font: inherit;
  font-size: 10px;
  border: 1px solid var(--hair);
  border-radius: 4px;
  background: var(--paper);
  color: var(--muted);
  margin-top: 4px;
  padding: 1px 2px;
}

/* pace chart */
.pace-block { margin-bottom: 16px; }
.pace-block .pb-label { font-size: 10px; color: var(--muted); margin-bottom: 5px; }
.bar {
  height: 9px;
  margin-bottom: 3px;
  border-radius: 999px;
  background: var(--lens-fill);
  position: relative;
  cursor: pointer;
  min-width: 3px;
}
.bar.med { background: var(--lens-line); }
.bar.hard { background: var(--lens); }
.bar .len {
  position: absolute;
  right: -22px;
  top: -2px;
  font-size: 9px;
  color: var(--muted);
}

/* concrete checklist */
.cc-block { border-bottom: 1px solid var(--hair); padding: 10px 0; }
.cc-block .prev { font-size: 11.5px; line-height: 1.5; color: var(--ink); margin-bottom: 7px; }
.cc-q {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  padding: 2px 0;
  cursor: pointer;
}
.cc-q input { accent-color: var(--lens); margin: 0; }
.cc-q.done { color: var(--lens); }

/* voice — warm ◀ | sweet spot | ▶ strength scale */
.ws-scale {
  position: relative;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--hair);
  background: linear-gradient(90deg,
    rgba(238, 153, 46, 0.22), rgba(238, 153, 46, 0.05) 40%,
    rgba(84, 150, 199, 0.05) 60%, rgba(84, 150, 199, 0.22));
  margin: 8px 0 4px;
}
.ws-zone {
  position: absolute;
  left: 40%;
  width: 20%;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--hair);
  border-right: 1px solid var(--hair);
  background: rgba(29, 29, 31, 0.05);
}
.ws-needle {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  border-radius: 2px;
  background: #1d1d1f;
  transform: translateX(-50%);
  transition: left 0.25s ease;
}
.ws-legend { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.ws-warm-lab { color: #b06a14; }
.ws-strong-lab { color: #3a6f99; }
.sig { font-size: 10.5px; color: var(--muted); line-height: 1.8; }
.sig .cue { margin-right: 12px; white-space: nowrap; }
.cue-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: baseline;
}
.cue-dot.cd-warm { background: #ee992e; }
.cue-dot.cd-strong { background: #5496c7; }
.cue-dot.cd-charisma { background: linear-gradient(90deg, #ee992e, #5496c7); }
.cue-dot.cd-danger { background: #be5446; }

.aloud-sent {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  background: transparent;
  border: 0;
  border-left: 2px solid var(--hair);
  padding: 5px 9px;
  margin-bottom: 3px;
  color: var(--ink);
  cursor: pointer;
}
.aloud-sent:hover { border-left-color: var(--lens); }
.aloud-sent.stumble {
  border-left-color: var(--lens);
  background: var(--lens-fill);
  text-decoration: line-through;
  text-decoration-color: var(--lens-line);
}

/* rhetoric deck */
.fig {
  border-bottom: 1px solid var(--hair);
  padding: 9px 0;
  cursor: pointer;
}
.fig .fname { font-size: 12px; }
.fig .fname .fid { color: var(--faint); font-size: 10px; margin-right: 5px; }
.fig .fwhat { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.fig .feg { font-size: 11px; color: var(--lens); line-height: 1.5; margin-top: 3px; }
.fig .fprompt {
  display: none;
  font-size: 11px;
  line-height: 1.6;
  margin-top: 6px;
  padding: 7px 9px;
  background: var(--paper-2);
  border-radius: 8px;
}
.fig.open .fprompt { display: block; }
.picked {
  font-size: 12px;
  line-height: 1.6;
  padding: 9px 11px;
  background: var(--paper-2);
  border-left: 2px solid var(--lens);
  border-radius: 0 8px 8px 0;
  margin-bottom: 14px;
}

/* detail list */
.dgroup { margin-bottom: 18px; }
.dgroup .drule { font-size: 12px; margin-bottom: 2px; }
.dgroup .dwhy { font-size: 10.5px; color: var(--muted); line-height: 1.6; margin-bottom: 8px; }
.ditem {
  font-size: 11.5px;
  line-height: 1.55;
  border-left: 2px solid var(--lens-line);
  padding: 4px 0 4px 9px;
  margin-bottom: 7px;
}
.ditem .dq { color: var(--ink); }
.ditem .di { color: var(--muted); }

/* ---- the note bar ---------------------------------------------------- */

.notebar {
  display: none;
  align-items: baseline;
  gap: 10px;
  padding: 10px 24px;
  border-top: 1px solid var(--hair);
  background: #fbfaf8;
  font-size: 12px;
  line-height: 1.55;
}
.notebar.on { display: flex; }
.notebar .nrule {
  flex: 0 0 auto;
  color: var(--lens);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.notebar .ntext { flex: 1; }
.notebar .ntext .nq { color: var(--ink); }
.notebar .ntext .ni { color: var(--muted); }
.notebar button {
  flex: 0 0 auto;
  font: inherit;
  font-size: 10.5px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.notebar button:hover { color: var(--ink); border-color: #d4d3cf; }
.notebar button.on { color: var(--paper); background: var(--ink); border-color: var(--ink); }

/* ---- the strip ------------------------------------------------------- */

.strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 8px;
  gap: 16px;
  padding: 12px 20px 12px 16px;
  border-top: 1px solid var(--hair);
  font-size: 12px;
}

.scorechip {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--paper-2);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 6px 12px;
  font: inherit;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
}
.scorechip:hover { border-color: #d4d3cf; }
.scorechip .val {
  font-size: 17px;
  line-height: 1;
  font-weight: 600;
  color: var(--lens);
}
.scorechip .val.none { font-size: 12px; font-weight: 400; }
.scorechip .sname { color: var(--ink); display: block; }
.scorechip .snext { color: var(--muted); font-size: 10px; display: block; margin-top: 1px; }

.headline { flex: 1 1 240px; min-width: 180px; color: var(--muted); line-height: 1.5; }

/* The cut meter — bottom-right, visible under every lens. */
.cut {
  flex: 0 0 auto;
  text-align: right;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: nowrap;
}
.cut .big { color: var(--ink); font-weight: 500; }
.cut .pts { color: var(--lens); }

.cutbar {
  position: relative;
  width: 124px;
  height: 5px;
  background: #e9e8e4;
  border-radius: 999px;
  margin: 5px 0 0 auto;
  overflow: hidden;
}
.cutbar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--lens); border-radius: 999px; }
.cutbar .tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(0, 0, 0, 0.18); }

/* ---- footnote -------------------------------------------------------- */

.footnote {
  padding: 20px 8px 0;
  font-size: 11.5px;
  line-height: 1.8;
  color: #a6a5a1;
}
.footnote b { color: #6b6b70; font-weight: 500; }

@media (max-width: 1100px) {
  .overlay.open { width: 268px; }
  .overlay-inner { width: 268px; }
  .rail.open { width: 148px; }
}

/* Too narrow to hold three columns — the rail floats over the text instead. */
@media (max-width: 900px) {
  .pane-body { position: relative; }
  .rail.open {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 172px;
    background: var(--paper);
    z-index: 6;
    box-shadow: 8px 0 22px rgba(0, 0, 0, 0.10);
  }
  .tab-body { font-size: 11.5px; padding: 6px 11px; gap: 6px; }
  .strip { flex-wrap: wrap; row-gap: 8px; }
  .headline { order: 3; flex-basis: 100%; }
}

/* Narrower still — the overlay floats too, so the text keeps its width. */
@media (max-width: 760px) {
  .overlay.open {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 268px;
    background: var(--paper);
    z-index: 6;
    box-shadow: -8px 0 22px rgba(0, 0, 0, 0.10);
  }
  .overlay-inner { max-height: none; height: 100%; }
}

/* Phone width. The tabs already scroll inside their own row, but the top line
   is a single non-wrapping flex row, so the four buttons push the document
   itself sideways — the whole page then scrolls horizontally. Let it wrap. */
@media (max-width: 620px) {
  .topline {
    flex-wrap: wrap;
    row-gap: 8px;
    padding-left: 4px;
    padding-right: 4px;
  }
  .topline input { flex: 1 1 60%; }
  .stage { padding-left: 12px; padding-right: 12px; }

  /* Stop competing for the same row. A 268px side panel on a 390px screen
     leaves a column of text too narrow to write in, so at phone width the
     spine and the version rail stack underneath the writing surface. */
  .pane-body { display: block; }
  .doc { min-width: 0; padding: 24px 16px 10px 6px; }

  .rail,
  .overlay {
    width: auto;
    height: 0;
    border-left: 0;
    border-right: 0;
    transition: none;
  }

  .rail.open,
  .overlay.open {
    position: static;
    width: auto;
    height: auto;
    background: transparent;
    box-shadow: none;
    border-top: 1px solid var(--hair);
  }

  .rail-inner,
  .overlay-inner {
    width: auto;
    max-height: none;
  }
}
