/* The Detector Dial — chapter 4, the student's desk */
.view--desk { display: grid; grid-template-columns: minmax(0, 1fr) 400px; }
.desk-main { min-width: 0; min-height: 0; overflow-y: auto; padding: 20px 28px 24px; display: flex; flex-direction: column; gap: 12px; }
.desk-head { max-width: 62ch; }
.desk-side { background: var(--alt); border-left: 1px solid var(--soft); overflow-y: auto; min-height: 0; padding: 18px 22px 24px; display: flex; flex-direction: column; gap: 12px; }

.draft-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.draft-tab {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  border-radius: 999px; padding: 6px 14px 6px 6px; font-size: 13.5px; font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.draft-tab:hover { border-color: var(--blue); }
.draft-tab[aria-checked="true"] { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; }
.draft-avatar { width: 24px; height: 24px; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; background: var(--ink); border-radius: 50%; letter-spacing: -0.02em; }
.draft-avatar--sq { border-radius: 6px; }
.draft-truth { font-size: 13px; color: var(--muted); }
.draft-truth b { color: var(--ink); }

.editor { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; }
.editor-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.editor-prompt { font-size: 13px; color: var(--muted); }
.switch--small { font-size: 12.5px; }
.editor-box {
  position: relative; flex: 1; min-height: 260px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  overflow: hidden;
}
.editor-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 94, 162, 0.15); }
.editor-hl, .editor-text {
  margin: 0; border: 0; padding: 16px 18px;
  font-family: var(--font); font-size: 16px; line-height: 1.7; letter-spacing: 0;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; tab-size: 4;
}
.editor-hl { position: absolute; inset: 0; color: transparent; overflow: hidden; pointer-events: none; }
.editor-text { position: relative; display: block; width: 100%; height: 100%; min-height: 260px; resize: none; background: transparent; color: var(--ink); outline: none; overflow-y: auto; }
.editor-hl mark { color: transparent; border-radius: 3px; }
.hl-phrase { background: rgba(180, 35, 24, 0.14); }
.hl-rare { background: transparent; text-decoration: underline; text-decoration-color: var(--blue); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.editor-box.is-plain .editor-hl { visibility: hidden; }
.editor-key { font-size: 12px; color: var(--muted); }
.editor-key mark { color: var(--ink); padding: 0 2px; }
.editor-key .hl-rare { color: var(--ink); }

/* Score card */
.score-card { background: var(--surface); border: 1px solid var(--soft); border-radius: var(--radius); padding: 14px 16px 16px; }
.score-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.score-num { font-size: 52px; font-weight: 700; letter-spacing: -0.045em; line-height: 0.95; font-variant-numeric: tabular-nums; }
.score-num.is-flagged { color: var(--flag); }
.score-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.score-verdict { font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 12px; background: rgba(26, 127, 55, 0.12); color: var(--ok); white-space: nowrap; }
.score-verdict.is-flagged { background: var(--flag); color: #fff; }
.score-verdict.is-pending { background: var(--alt); color: var(--muted); }
.meter { position: relative; height: 10px; border-radius: 999px; background: linear-gradient(90deg, #ececf0 0 70%, rgba(180, 35, 24, 0.16) 70% 100%); margin: 16px 0 4px; }
.meter-line { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--flag); left: 70%; }
.meter-start { position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; border: 2px solid var(--faint); background: #fff; transition: left 0.3s var(--ease); }
.meter-dot { position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: var(--ink); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); transition: left 0.3s var(--ease); }
.meter-dot.is-flagged { background: var(--flag); }
.meter-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.score-delta { font-size: 13px; color: #3a3a3c; margin-top: 8px; }
.score-delta b { font-variant-numeric: tabular-nums; }

/* Tricks */
.tricks { background: var(--surface); border: 1px solid var(--soft); border-radius: var(--radius); padding: 14px 16px; }
.trick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn--trick { background: var(--alt); border-color: transparent; color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; font-weight: 600; justify-content: flex-start; text-align: left; }
.btn--trick:hover { background: var(--blue-soft); color: var(--blue-dark); }
.btn--trick.is-used { box-shadow: inset 0 0 0 1px rgba(0, 94, 162, 0.35); }
.btn--polish { grid-column: 1 / -1; background: rgba(154, 88, 0, 0.08); color: var(--el); }
.btn--polish:hover { background: rgba(154, 88, 0, 0.14); color: var(--el); }
.trick-meta { display: flex; gap: 8px; margin-top: 10px; }

/* Signals */
.signals { background: var(--surface); border: 1px solid var(--soft); border-radius: var(--radius); padding: 14px 16px; }
.signal { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; align-items: baseline; }
.signal + .signal { margin-top: 10px; }
.signal-name { font-size: 13px; font-weight: 500; }
.signal-val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.signal-bar { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: #ececf0; overflow: hidden; }
.signal-fill { height: 100%; border-radius: 999px; background: var(--ink); transition: width 0.3s var(--ease); }
.signal-hint { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

.reveal-slot { display: flex; flex-direction: column; gap: 10px; }
.reveal-slot:empty { display: none; }
.desk-note { margin-top: 0; }

@media (max-width: 1100px) {
  .view--desk { grid-template-columns: minmax(0, 1fr) 360px; }
  .desk-main { padding: 18px 20px 20px; }
}
@media (max-width: 899px) {
  /* Keep focused controls clear of the sticky score card. */
  html:has(#viewDesk:not([hidden])) { scroll-padding-top: 150px; }
  .view--desk { display: flex; flex-direction: column; gap: 12px; padding: 16px 14px 24px; }
  .desk-main, .desk-side { display: contents; }
  .desk-head { order: 1; }
  .draft-tabs { order: 2; }
  .draft-truth { order: 3; }
  .score-card { order: 4; position: sticky; top: 0; z-index: 4; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.07); padding: 10px 14px 12px; }
  .editor { order: 5; flex: none; }
  .tricks { order: 6; }
  .reveal-slot { order: 7; }
  .signals { order: 8; }
  .desk-note { order: 9; }
  .desk-side .panel-foot { order: 10; }
  .editor-box { flex: none; height: 52vh; min-height: 280px; }
  .editor-text { min-height: 0; }
  .editor-hl, .editor-text { font-size: 15px; padding: 12px 14px; }
  .score-num { font-size: 36px; }
  .meter { margin: 10px 0 2px; }
  .meter-ends { display: none; }
  .score-delta { margin-top: 4px; font-size: 12.5px; }
}
