:root { --ink: #1f2933; --muted: #616e7c; --line: #d3d9e0; --bg: #f5f7fa; --accent: #1f5fa8; --ok: #1d7a46; --bad: #a83232; --warn: #8a5a00; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.top nav { display: flex; gap: 16px; align-items: center; }
.who { color: var(--muted); }
main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 60px; }
h1 { font-size: 1.4rem; margin: 8px 0 12px; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); font-size: 0.9em; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 16px 18px; margin: 14px 0; }
.card.narrow { max-width: 560px; margin: 40px auto; }
.flash { padding: 10px 14px; border-radius: 6px; margin: 10px 0; border: 1px solid var(--line); background: #fff; }
.flash.ok { border-color: #9fd3b3; background: #eef9f2; }
.flash.warn { border-color: #e3c27a; background: #fdf6e3; color: var(--warn); }
.flash.bad { border-color: #e0a0a0; background: #fcefef; color: var(--bad); }
table.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
table.grid th { background: #eef1f5; font-weight: 600; }
table.review .c-name { width: 14%; }
table.review .c-exp { width: 20%; font-size: 0.9em; }
table.review .c-rating { width: 14%; }
table.review .c-just { width: 30%; }
table.review .c-fb { width: 22%; }
table.review p { margin: 0 0 6px; }
textarea { width: 100%; font: inherit; padding: 6px; border: 1px solid var(--line); border-radius: 4px; resize: vertical; }
select, input[type=text], input[type=email], input[type=file] { font: inherit; padding: 5px; border: 1px solid var(--line); border-radius: 4px; max-width: 100%; }
table.review select { width: 100%; }
button, .button { font: inherit; padding: 7px 14px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; text-decoration: none; color: var(--ink); display: inline-block; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: 0.6; cursor: wait; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
form.inline { display: inline; }
.fb { padding: 8px; border-radius: 4px; border-left: 4px solid var(--line); background: #f7f9fb; white-space: pre-wrap; }
.fb-ok { border-left-color: var(--ok); }
.fb-no { border-left-color: var(--bad); }
.facts { display: flex; gap: 32px; margin: 0 0 12px; }
.facts dt { color: var(--muted); font-size: 0.85em; }
.facts dd { margin: 0; font-weight: 600; }
.grades { display: flex; gap: 48px; }
.grades .label { display: block; color: var(--muted); font-size: 0.85em; }
.grades .value { font-size: 1.15rem; font-weight: 700; }
.working { font-weight: 600; color: var(--accent); }
.empty { padding: 20px; background: #fff; border: 1px dashed var(--line); border-radius: 6px; }
.sr { position: absolute; left: -9999px; }
.actions button { margin-right: 8px; }
.cols { display: flex; gap: 24px; flex-wrap: wrap; }
.cols > section { flex: 1 1 360px; }
.mono { font-family: Consolas, monospace; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
@media (max-width: 900px) { table.review { font-size: 0.9em; } }

.badge { padding: 2px 10px; border-radius: 10px; border: 1px solid var(--line); background: #fff; text-decoration: none; font-size: 0.85em; color: var(--muted); }
.badge-synced { border-color: #9fd3b3; color: var(--ok); }
.badge-syncing { border-color: #9fbfe3; color: var(--accent); }
.badge-error { border-color: #e0a0a0; color: var(--bad); }

.dictate { margin-top: 6px; }
.d-panel { border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-top: 6px; background: #fafbfc; }
.d-panel label { display: block; font-weight: 600; margin: 6px 0; }
.d-panel textarea { font-weight: 400; }
.d-timer { margin-left: 10px; font-variant-numeric: tabular-nums; }
.d-warnings { color: var(--warn); margin: 6px 0; padding-left: 18px; }
meter { width: 200px; }

.tag { display: inline-block; padding: 0 6px; border-radius: 8px; background: #e6edf5; color: #34506e; font-size: 0.75em; font-weight: 600; vertical-align: middle; }
.filter { margin: 10px 0; }
.filter select { margin: 0 6px; }

.tag-vis { background: #e3f3e8; color: #1d5e37; }
.tag-hidden { background: #f5e8e8; color: #7a2a2a; }
.q-card textarea { margin: 4px 0; }
.copy-source { background: #f7f9fb; }
.draft-warnings { color: var(--warn); }
.draft-area { border: 1px dashed var(--line); padding: 8px; margin: 8px 0; }

.hint { margin-top: 8px; }
.hint summary { cursor: pointer; font-weight: 600; }
.hint-lead { margin: 6px 0 4px; }
.hint-questions { margin: 4px 0 6px; padding-left: 18px; }
.hint-questions.dictate-hint { margin-top: 0; }
.hint-ratings .hint-rating { display: none; margin: 6px 0 0; font-style: italic; color: var(--muted); }
/* Correct on load without JS: only the chosen rating's line shows. Until a rating is chosen,
   keep the general writing prompts without showing contradictory rating advice. */
tr[data-selected-rating="Consistently exceeds expectations"] .hint-rating[data-rating="Consistently exceeds expectations"] { display: block; }
tr[data-selected-rating="Sometimes exceeds expectations"] .hint-rating[data-rating="Sometimes exceeds expectations"] { display: block; }
tr[data-selected-rating="Consistently meets expectations"] .hint-rating[data-rating="Consistently meets expectations"] { display: block; }
tr[data-selected-rating="Inconsistently meets expectations"] .hint-rating[data-rating="Inconsistently meets expectations"] { display: block; }
tr[data-selected-rating="Below expectations"] .hint-rating[data-rating="Below expectations"] { display: block; }
.hint-toggle { margin: 8px 0; }

/* ---- Focus view (round 10) --------------------------------------------------------------------
   The long layout above is the default and what no-JS and narrow screens get. focus.js adds
   html.fv-capable (1100px and wider) and html.fv-on (capable and not switched to the overview). */
.fv-only, .tog-long, .tog-focus { display: none; }
html.fv-capable:not(.fv-on) .tog-long { display: inline-block; }
.rail ul { list-style: none; margin: 0; padding: 0; }
.rail-item { display: flex; align-items: center; gap: 6px; width: 100%; margin: 0 0 3px; text-align: left; padding: 6px 8px; border-radius: 4px; }
.rail-item .ri-name { flex: 1; min-width: 0; font-weight: 600; font-size: 0.92em; }
.rail-item[aria-current="true"] { background: #e6edf5; border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.rail-item .ri-copy { font-size: 0.75em; color: var(--ok); }
.chip { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 0.75em; white-space: nowrap; }
.dot { display: inline-block; min-width: 1.2em; text-align: center; font-weight: 700; }
.dot-holds { color: var(--ok); }
.dot-no { color: var(--bad); }
.dot-written { color: var(--accent); }
.dot-empty { color: var(--muted); }
.rail-id p { margin: 0 0 4px; }
.pane-nav { align-items: center; gap: 10px; padding-top: 6px; }
.pane-nav .shortcuts { margin-left: auto; font-size: 0.8em; }

html.fv-on, html.fv-on body { height: 100%; }
html.fv-on body { display: flex; flex-direction: column; overflow: hidden; }
html.fv-on main { flex: 1; min-height: 0; max-width: none; width: 100%; margin: 0; padding: 8px 14px; display: flex; flex-direction: column; }
html.fv-on .intro, html.fv-on .fv-hide, html.fv-on .hint-toggle, html.fv-on .own-card .muted { display: none; }
html.fv-on .flash { margin: 4px 0; padding: 6px 10px; }
html.fv-on .tog-focus { display: inline-block; }
html.fv-on .pane-nav { display: flex; }
html.fv-on .card { margin: 6px 0; padding: 8px 10px; }

/* review page */
html.fv-on #review-form { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto; column-gap: 14px; }
html.fv-on #review-form > .rail-id { display: block; grid-column: 1; grid-row: 1; }
html.fv-on #review-form > .own-card { grid-column: 1; grid-row: 2; }
html.fv-on #review-form > .rail { display: block; grid-column: 1; grid-row: 3; overflow: auto; min-height: 0; }
html.fv-on #review-form .rail-item { padding: 4px 6px; gap: 4px; min-height: 32px; }
html.fv-on #review-form .ri-name { font-size: 13px; line-height: 1.2; }
html.fv-on #review-form .chip { font-size: 11px; padding: 0 4px; }
html.fv-on #review-form > .actions { grid-column: 1; grid-row: 4; }
html.fv-on #review-form > table.review { grid-column: 2; grid-row: 1 / 4; min-height: 0; }
html.fv-on #review-form > .pane-nav { grid-column: 2; grid-row: 4; }
html.fv-on table.review, html.fv-on table.review tbody { display: block; height: 100%; min-height: 0; border: 0; background: none; }
html.fv-on table.review thead { display: none; }
html.fv-on table.review tr { display: none; }
html.fv-on table.review tr.is-active { display: grid; height: 100%; min-height: 0; column-gap: 16px;
  grid-template-columns: 38fr 62fr; grid-template-rows: auto auto minmax(0, 1fr) auto auto; }
html.fv-on table.review td { display: block; border: 0; padding: 0; min-height: 0; }
html.fv-on table.review td.c-just { display: contents; }
html.fv-on table.review td.c-name { grid-column: 1; grid-row: 1; font-size: 1.1em; }
html.fv-on table.review td.c-exp { grid-column: 1; grid-row: 2; max-height: 24vh; overflow: auto; width: auto; }
html.fv-on table.review td.c-rating { grid-column: 2; grid-row: 1; width: auto; }
html.fv-on table.review td.c-just > textarea { grid-column: 2; grid-row: 2 / 4; height: 100%; min-height: 6em; resize: none; }
html.fv-on table.review td.c-just > .hint { grid-column: 1; grid-row: 3 / 5; overflow: auto; min-height: 0; margin: 4px 0; }
html.fv-on table.review td.c-just > .dictate { grid-column: 2; grid-row: 4; min-height: 0; }
html.fv-on table.review td.c-fb { grid-column: 1 / -1; grid-row: 5; width: auto; }
html.fv-on .hint summary { display: none; }
html.fv-on .dictate-hint, html.fv-on .d-panel > p.muted { display: none; }
html.fv-on .d-panel { max-height: 34vh; overflow: auto; }
html.fv-on .d-result { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
html.fv-on .d-result > :not(label) { grid-column: 1 / -1; }
html.fv-on .d-result textarea { height: 6em; resize: none; }
html.fv-on .fb { max-height: 3.3em; overflow: hidden; cursor: pointer; }
html.fv-on .fb.expanded { max-height: 35vh; overflow: auto; }

/* Garena page */
html.fv-on .g-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr); column-gap: 14px; }
html.fv-on .rail-wrap { display: flex; flex-direction: column; min-height: 0; }
html.fv-on .rail-wrap .rail { flex: 1; overflow: auto; min-height: 0; }
html.fv-on .g-main { display: flex; flex-direction: column; min-height: 0; }
html.fv-on .g-main > form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
html.fv-on .g-main [data-pane] { display: none; }
html.fv-on .g-main [data-pane].is-active { display: block; flex: 1; min-height: 0; overflow: auto; margin: 0; }
html.fv-on .g-main .pane-scroll.is-active { display: block; }
html.fv-on .q-card[data-draft].is-active { display: grid; overflow: hidden; column-gap: 16px;
  grid-template-columns: 1fr 1fr; grid-template-rows: auto auto minmax(0, 1fr) auto auto auto; }
html.fv-on .q-card[data-draft] > h2 { grid-column: 1 / -1; grid-row: 1; margin: 0 0 4px; }
html.fv-on .q-card[data-draft] > label[for^="notes_"] { grid-column: 1; grid-row: 2; }
html.fv-on .q-card[data-draft] > textarea[name^="notes_"] { grid-column: 1; grid-row: 3; height: 100%; min-height: 5em; resize: none; }
html.fv-on .q-card[data-draft] > .dictate { grid-column: 1; grid-row: 4 / 6; min-height: 0; }
html.fv-on .q-card[data-draft] > .hint { grid-column: 1; grid-row: 6; max-height: 24vh; overflow: auto; }
html.fv-on .q-card[data-draft] > p { grid-column: 2; grid-row: 2; margin: 0; }
html.fv-on .q-card[data-draft] > .draft-area { grid-column: 2; grid-row: 3; overflow: auto; min-height: 0; margin: 0; }
html.fv-on .q-card[data-draft] > label[for^="final_"] { grid-column: 2; grid-row: 4; }
html.fv-on .q-card[data-draft] > textarea[name^="final_"] { grid-column: 2; grid-row: 5; height: 7em; resize: none; }
html.fv-on .q-card[data-draft] > .copy-btn { grid-column: 2; grid-row: 6; justify-self: start; }

/* Plain-text editing tools keep the original textarea and autosave events. */
.editor-box { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.editor-toolbar, .editor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.editor-toolbar { margin: 3px 0 5px; }
.editor-toolbar button { padding: 4px 7px; font-size: 12px; }
.editor-status { font-size: 12px; }
.editor-status:empty { display: none; }
.editor-box textarea { width: 100%; }
html.fv-on table.review td.c-just > .editor-box { grid-column: 2; grid-row: 2 / 4; }
html.fv-on .editor-box > textarea { flex: 1; min-height: 5em; resize: none; }
html.fv-on .q-card[data-draft] > .editor-notes { grid-column: 1; grid-row: 3; }
html.fv-on .q-card[data-draft] > .editor-final { grid-column: 2; grid-row: 5; }
html.fv-on .q-card[data-draft] > .editor-final textarea { height: 7em; }
.polish-dialog { width: min(1000px, 94vw); max-height: 90vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
.polish-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.polish-dialog h2 { margin-top: 0; }
.polish-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.polish-compare textarea { display: block; width: 100%; min-height: 180px; }
.polish-warnings { color: var(--warn); }
.expectation-current, .expectation-next { padding: 8px 10px; border-radius: 4px; }
.expectation-current { background: #fff; border-left: 3px solid #8a9db2; }
.expectation-next { color: #163b65; background: #e7f0fc; border-left: 4px solid #2b65a5; font-weight: 500; }
@media (max-width: 700px) { .polish-compare { grid-template-columns: 1fr; } }

/* Garena accents and an optional black/red theme, shared by every page. */
:root { color-scheme: light; --accent: #c51b2e; --primary: #d7192d; --surface: #fff; --raised: #f4f0f1; --accent-soft: #fff0f2; --accent-ink: #8d1725; --focus: #d7192d; }
html[data-theme="dark"] { color-scheme: dark; --ink: #f2f2f4; --muted: #b7b3bb; --line: #454049; --bg: #101013; --surface: #1a191e; --raised: #252329; --accent: #ff7683; --primary: #d7192d; --accent-soft: #361d24; --accent-ink: #ffc0c7; --focus: #ff7683; --ok: #85d6a3; --bad: #ff939d; --warn: #f0c576; }
.top { background: var(--surface); border-top: 3px solid var(--primary); }
.top .brand { color: var(--accent); }
.card, .flash, table.grid, .empty, .badge, .chip, button, .button, .polish-dialog { background: var(--surface); color: var(--ink); }
table.grid th, .fb, .copy-source, .d-panel { background: var(--raised); }
textarea, select, input[type=text], input[type=email], input[type=number], input[type=file] { background: var(--surface); color: var(--ink); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button:hover:not(:disabled):not(.primary) { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rail-item[aria-current="true"], .tag { background: var(--accent-soft); color: var(--accent-ink); }
.rail-item[aria-current="true"] { border-color: var(--accent); }
.expectation-current { background: var(--surface); border-left-color: var(--muted); }
.expectation-next { color: var(--accent-ink); background: var(--accent-soft); border-left-color: var(--accent); }
html[data-theme="dark"] .flash.ok, html[data-theme="dark"] .tag-vis { background: #192d22; border-color: #3f7551; color: var(--ok); }
html[data-theme="dark"] .flash.warn { background: #302719; border-color: #806735; }
html[data-theme="dark"] .flash.bad, html[data-theme="dark"] .tag-hidden { background: #351d24; border-color: #85404c; color: var(--bad); }
#theme-toggle { font-size: 12px; padding: 4px 9px; white-space: nowrap; }
@media (max-width: 700px) { .top { padding: 8px 12px; flex-wrap: wrap; gap: 8px; } .top nav { gap: 10px; flex-wrap: wrap; } }

/* Expectations lead the review: both ranks occupy the full width above the writing area. */
.track-context { color: var(--accent-ink); font-weight: 650; font-size: 14px; margin: 4px 0 8px; }
.expectation-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.rank-expectation { padding: 14px 16px; border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 7px; font-size: 15px; line-height: 1.55; color: var(--ink); }
.rank-expectation.expectation-next { border-left-color: var(--accent); }
.rank-label { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.expectation-next .rank-label { color: var(--accent-ink); }
.rank-expectation h3 { font-size: 18px; line-height: 1.3; margin: 3px 0 10px; color: var(--ink); }
table.review .rank-expectation p { margin: 0; }
html.fv-on table.review tr.is-active { grid-template-columns: 38fr 62fr; grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; row-gap: 10px; }
html.fv-on table.review td.c-name { grid-column: 2; grid-row: 2; align-self: center; width: auto; }
html.fv-on table.review td.c-rating { grid-column: 2; grid-row: 3; }
html.fv-on table.review td.c-exp { grid-column: 1 / -1; grid-row: 1; max-height: 42vh; font-size: 1em; }
html.fv-on .expectation-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
html.fv-on table.review td.c-just > .editor-box,
html.fv-on table.review td.c-just > textarea { grid-column: 2; grid-row: 4; }
html.fv-on table.review td.c-just > .hint { grid-column: 1; grid-row: 2 / 6; font-size: 13px; line-height: 1.45; }
html.fv-on table.review td.c-just > .dictate { grid-column: 2; grid-row: 5; }
html.fv-on table.review td.c-fb { grid-column: 1 / -1; grid-row: 6; }
@media (max-height: 700px) and (min-width: 1100px) { html.fv-on .rank-expectation { padding: 10px 12px; } }

/* Dictation has one scrollable workspace instead of nested editor panes. */
.dictation-dialog { width: min(1100px, 94vw); max-height: 90dvh; overflow: auto;
  padding: 0 20px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); }
.dictation-dialog::backdrop { background: rgb(0 0 0 / 50%); }
.dictation-heading { position: sticky; top: 0; z-index: 2; background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--line); }
.dictation-heading h2 { margin: 0; }
html .dictation-dialog .d-panel { max-height: none; overflow: visible; padding: 0;
  margin: 10px 0 0; border: 0; background: transparent; }
html .dictation-dialog .d-result { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
html .dictation-dialog .d-result[hidden], html .dictation-dialog .d-panel[hidden] { display: none; }
html .dictation-dialog .d-result > :not(label) { grid-column: 1 / -1; }
html .dictation-dialog .d-result textarea { min-height: 180px; resize: none; overflow: hidden; }
.dictation-actions { display: flex; flex-wrap: wrap; gap: 8px; position: sticky;
  bottom: -16px; padding: 12px 0; background: var(--surface); border-top: 1px solid var(--line); }
.dictation-actions button { width: auto; }
@media (max-width: 700px) {
  html .dictation-dialog .d-result { grid-template-columns: 1fr; }
  .dictation-heading { align-items: flex-start; }
}

.grading-policy-label { margin: .35rem 0; font-size: .85rem; }
.grading-policy-dialog { max-width: 760px; width: 90vw; max-height: 85vh; overflow-y: auto; padding: 1.5rem; }
.grading-policy-dialog li { margin-bottom: .65rem; }

.grading-baselines { font-size: .8rem; line-height: 1.35; margin: .3rem 0 .5rem; }

/* Mobile review cards: avoid the desktop table's horizontal scrolling. */
@media (max-width: 700px) {
  table.review, table.review tbody, table.review tr, table.review td { display: block; width: 100%; }
  table.review thead { display: none; }
  table.review tr { margin-bottom: 1rem; padding: .6rem; border: 1px solid var(--line); }
  table.review td { box-sizing: border-box; }
  table.review textarea { min-height: 160px; font-size: 16px; }
  select, input, textarea { font-size: 16px; }
  button { min-height: 42px; }
  .grading-policy-dialog { box-sizing: border-box; }
  .grid { display: block; overflow-x: auto; }
}
