/* Proofread admin — "galley proof" theme.
 *
 * A copy-editor's marked-up page: warm paper, ink-black type, red strikes for
 * deletions, green for insertions, highlighter yellow for anything still
 * awaiting a decision. Each colour means one thing and only that thing.
 *
 * Type note: the Latin display face is a text serif, but CJK falls back to a
 * *gothic*, not a mincho. Mincho at UI sizes reads loose and mismatched next
 * to Latin serif; gothic is what Japanese and Korean interfaces actually use.
 */

/* ---------------------------------------------------------------- tokens */

:root {
  /* paper & ink */
  --paper:      #faf7f1;
  --paper-sunk: #f2ece1;
  --surface:    #fffefc;
  --ink:        #1a1815;
  --ink-soft:   #4a453d;
  --muted:      #857e72;
  --rule:       #e7e0d3;
  --rule-firm:  #d5cab6;

  /* proof marks */
  --mark:     #f5c518;
  --mark-dim: #fdf3cf;
  --del:      #b23a2e;
  --del-bg:   #fbe7e3;
  --ins:      #1b6b45;
  --ins-bg:   #dcf0e3;
  --info:     #2c5c99;
  --info-bg:  #e6eefa;

  /* one spacing scale, used everywhere */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;

  --r:    8px;
  --r-lg: 12px;
  --shadow: 0 24px 60px -28px rgba(40, 32, 20, .4);

  --display: "Newsreader", "Hiragino Sans", "Yu Gothic", "Noto Sans JP",
             "Apple SD Gothic Neo", "Malgun Gothic", Georgia, serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP",
        "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, "Roboto Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14.5px/1.65 var(--ui);
  text-rendering: optimizeLegibility;
}
body.centered { display: grid; place-items: center; min-height: 100vh; padding: var(--s5); }

a { color: inherit; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 3px; }

/* ------------------------------------------------------------ typography */

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -.01em;
  /* Korean should break between words, not inside them. */
  word-break: keep-all;
  overflow-wrap: break-word;
}
h1 { font-size: 28px; line-height: 1.25; margin: 0; }
h2 { font-size: 17px; line-height: 1.35; margin: 0; }
h3 { font-size: 15px; margin: 0; }

.muted  { color: var(--muted); }
.small  { font-size: 12.5px; }
.strong { font-weight: 600; }
.lead   { margin: 0; font-size: 15px; line-height: 1.7; color: var(--ink-soft); word-break: keep-all; }
.error  { color: var(--del); font-size: 13px; margin: 0; }

code, .mono {
  font-family: var(--mono); font-size: .88em;
  background: var(--paper-sunk); padding: 1px 5px; border-radius: 4px;
}

/* ----------------------------------------------------------------- chrome */

.logo {
  display: inline-block;
  background: var(--mark); color: #16140f;
  border-radius: 4px; padding: 2px 6px;
  font-family: var(--ui); font-weight: 700; font-size: 11px; letter-spacing: .04em;
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  height: 56px;
  /* Line the brand up with the page title below it, not the window edge. */
  padding: 0 max(var(--s5), calc((100% - 1060px) / 2 + var(--s5)));
  background: #16140f;
  color: #f6f2ea;
}
.topbar .brand {
  display: flex; align-items: center; gap: var(--s2);
  text-decoration: none; font-family: var(--display); font-size: 18px; font-weight: 500;
}
.topbar nav { display: flex; align-items: center; gap: var(--s4); font-size: 13px; }
.topbar nav a { color: #b8b0a2; text-decoration: none; }
.topbar nav a:hover { color: #fff; }
.topbar .crumb { color: #b8b0a2; }
.topbar .crumb b { color: #f6f2ea; font-weight: 500; }

.wrap { width: 100%; max-width: 1060px; margin: 0 auto; padding: var(--s6) var(--s5) var(--s7); }
.wrap.narrow { max-width: 560px; padding-top: var(--s7); }

/* --------------------------------------------------------- the next thing */

/* The admin's whole job is "what needs me now" — so say it, in one line,
   before anything else on the page. */
.next {
  display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap;
  margin: 0 0 var(--s5);
  font-size: 15px; line-height: 1.6;
}
.next .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--rule-firm);
  flex: none; align-self: center;
}
.next.hot .dot { background: var(--mark); box-shadow: 0 0 0 3px var(--mark-dim); }
.next a { font-weight: 600; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5);
}
.page-head .titles { min-width: 0; }
.page-head h1 { margin-bottom: var(--s1); }
.page-head .sub { color: var(--muted); font-size: 13px; margin: 0; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  margin-bottom: var(--s4);
  overflow: hidden;
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--s4); flex-wrap: wrap;
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--rule);
}
.card-head .titles { min-width: 0; }
.card-head h2 + .sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.card-body { padding: var(--s5); }
.card-body > :first-child { margin-top: 0; }
.card-body > :last-child { margin-bottom: 0; }

.row-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }

.flash {
  background: var(--mark-dim); border: 1px solid #ecd98d;
  border-radius: var(--r); padding: var(--s3) var(--s4); margin-bottom: var(--s5);
  font-size: 13px;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--rule-firm); background: var(--surface); color: var(--ink);
  border-radius: var(--r); padding: 7px 13px;
  font: 500 13px/1.4 var(--ui);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .13s ease, border-color .13s ease;
}
.btn:hover { background: #fdfaf4; border-color: #bfb29a; }
.btn.primary { background: var(--mark); border-color: #dcae0d; color: #16140f; font-weight: 600; }
.btn.primary:hover { background: #f8d449; border-color: #dcae0d; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--del); }
.btn.danger:hover { background: var(--del-bg); border-color: #d9a99f; }
.btn.ok { color: var(--ins); }
.btn.ok:hover { background: var(--ins-bg); border-color: #8fc4a4; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--paper-sunk); color: var(--ink); }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ----------------------------------------------------------------- inputs */

input[type="text"], input[type="password"], textarea {
  border: 1px solid var(--rule-firm); border-radius: var(--r);
  padding: 8px 11px; font: inherit; font-size: 13.5px;
  background: var(--surface); color: var(--ink);
  transition: border-color .13s ease, box-shadow .13s ease;
}
input::placeholder { color: #a89f8f; }
input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(26, 24, 21, .07);
}

/* The native file input can't be styled, so hide it behind a label. */
.file {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--rule-firm); border-radius: var(--r);
  background: var(--surface); overflow: hidden;
}
.file input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file label {
  display: inline-flex; align-items: center; padding: 7px 13px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  border-right: 1px solid var(--rule-firm); background: #fdfaf4;
}
.file label:hover { background: var(--mark-dim); }
.file .filename {
  display: inline-flex; align-items: center; padding: 7px 12px;
  font-size: 12.5px; color: var(--muted); max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file input:focus-visible + label { outline: 2px solid var(--ink); outline-offset: -2px; }

/* ------------------------------------------------------------------ table */

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--s3) var(--s5); border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); padding-top: 10px; padding-bottom: 10px;
}
/* Numeric columns stay tight so the title column keeps the width it deserves. */
th.num, td.num { width: 84px; text-align: right; font-variant-numeric: tabular-nums; }
th.act, td.act { width: 1%; text-align: right; white-space: nowrap; }
td.act .row-actions { justify-content: flex-end; flex-wrap: nowrap; }

.title-cell { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.title-cell a { font-weight: 600; text-decoration: none; }
.title-cell a:hover { text-decoration: underline; }
.title-cell .meta { font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* ------------------------------------------------------------------ pills */

.pill {
  display: inline-block;
  background: var(--paper-sunk); color: var(--ink-soft);
  border-radius: 100px; padding: 2px 9px;
  font-size: 11px; font-weight: 600; line-height: 1.6;
  font-variant-numeric: tabular-nums;
}
.pill.warn   { background: var(--mark-dim); color: #7d5c00; }
.pill.info   { background: var(--info-bg); color: var(--info); }
.pill.danger { background: var(--del-bg); color: var(--del); }
.pill.ok     { background: var(--ins-bg); color: var(--ins); }
.pill.zero   { background: transparent; color: #b6ada0; font-weight: 400; }

/* ----------------------------------------------------------- empty states */

.empty { padding: var(--s6) var(--s5); text-align: center; }
.empty p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* -------------------------------------------------------------- reviewers */

.reviewer { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--rule); }
.reviewer:last-child { border-bottom: 0; }
.reviewer.off .reviewer-name { color: var(--muted); text-decoration: line-through; }
.reviewer-head {
  display: flex; justify-content: space-between; gap: var(--s3);
  align-items: center; flex-wrap: wrap;
}
.reviewer-name { font-weight: 600; font-size: 15px; }
.reviewer-id { display: flex; align-items: center; gap: var(--s2); min-width: 0; }

.linkbox {
  display: flex; align-items: stretch;
  border: 1px solid var(--rule-firm); border-radius: var(--r);
  background: var(--paper-sunk); overflow: hidden;
}
.linkbox .link {
  border: 0; background: transparent; border-radius: 0;
  font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
  padding: 6px 10px; width: min(330px, 44vw);
}
.linkbox .link:focus { outline: none; box-shadow: none; }
.linkbox .btn { border: 0; border-left: 1px solid var(--rule-firm); border-radius: 0; }

/* Assignment is all-on by default, so keep it out of the way until wanted. */
.assign-toggle {
  appearance: none; border: 0; background: none; cursor: pointer;
  font: 500 12px/1.6 var(--ui); color: var(--muted); padding: var(--s2) 0 0;
}
.assign-toggle::before {
  content: "▸"; display: inline-block; margin-right: 5px; font-size: 9px;
  transition: transform .13s ease;
}
.reviewer.open .assign-toggle::before { transform: rotate(90deg); }
.assign-toggle:hover { color: var(--ink); }
.assign { display: none; flex-wrap: wrap; gap: 6px; margin-top: var(--s2); }
.reviewer.open .assign { display: flex; }

.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.chip span {
  display: inline-block; padding: 4px 11px; border-radius: 100px;
  border: 1px solid var(--rule-firm); background: var(--surface);
  font-size: 12px; color: var(--muted); transition: all .13s ease;
}
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ------------------------------------------------------------ change list */

.change {
  border: 1px solid var(--rule);
  border-radius: var(--r); padding: var(--s3) var(--s4); margin-bottom: var(--s3);
  background: var(--surface);
}
.change:last-child { margin-bottom: 0; }
.change.rejected { opacity: .65; }

.change-meta { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); flex-wrap: wrap; }
/* Status as a dot before the name — a coloured bar down the side just repeats
   what the words next to it already say. */
.change-meta::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--rule-firm);
}
.change.pending  .change-meta::before { background: var(--mark); }
.change.accepted .change-meta::before { background: var(--ins); }
.change.rejected .change-meta::before { background: var(--del); }
.change-meta .who { font-weight: 600; }
.change-meta time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.change.accepted .status-label { color: var(--ins); }
.change.rejected .status-label { color: var(--del); }

.diff { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.diff-side {
  border: 1px solid var(--rule); border-radius: var(--r);
  padding: var(--s2) var(--s3); background: var(--surface);
  font-size: 14px; line-height: 1.75; word-break: break-word;
}
.diff-tag {
  display: block; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: var(--s1);
}
.diff-side.before { background: #fefaf9; }
.diff-side.after  { background: #fafdfb; }
.diff del { background: var(--del-bg); color: var(--del); text-decoration: line-through; border-radius: 2px; }
.diff ins { background: var(--ins-bg); color: var(--ins); text-decoration: none; border-radius: 2px; }

.orig {
  background: var(--paper-sunk); border-radius: var(--r);
  padding: var(--s2) var(--s3); font-size: 14px; color: var(--ink-soft);
}
/* Someone's words, so it reads as a quotation rather than a callout panel. */
.note {
  border-left: 2px solid #cddaeb; padding: 2px 0 2px var(--s3); margin-top: var(--s3);
  color: var(--info);
}
.note p { margin: 2px 0 0; white-space: pre-wrap; font-size: 13.5px; }
.note .who { font-weight: 600; font-size: 13px; }
.note time { font-size: 12px; color: var(--muted); margin-left: 6px; }

/* ------------------------------------------------------ reviewer landing */

.reviewer-home .mast { text-align: center; margin-bottom: var(--s6); }
.reviewer-home .wordmark {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted); letter-spacing: .02em;
  margin-bottom: var(--s4);
}
.reviewer-home .mast h1 { font-size: 26px; margin-bottom: var(--s2); }
.reviewer-home .mast .who { margin: 0; color: var(--muted); font-size: 13.5px; word-break: keep-all; }
.reviewer-home .mast .langs { margin-top: var(--s4); }

/* The instructions are the point of this page, so they get the paper, and
   the page list below reads as the thing to click. */
.howto {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r-lg); padding: var(--s4) var(--s5); margin-bottom: var(--s5);
}
.howto p { margin: 0; }
.howto b { background: var(--mark-dim); padding: 0 3px; border-radius: 2px; font-weight: 600; }

.page-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s2); }
.page-list a {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s3);
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: var(--s4); text-decoration: none;
  transition: border-color .13s ease;
}
.page-list a:hover { border-color: var(--ink); }
.page-list .name { font-weight: 600; }
.page-list .name::after { content: " →"; color: var(--muted); font-weight: 400; }

/* Language switch — light on paper, and a dark variant for the topbar. */
.langs { display: inline-flex; border: 1px solid var(--rule-firm); border-radius: 100px; overflow: hidden; }
.langs button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: 500 12px/1 var(--ui); color: var(--muted); padding: 6px 12px;
  transition: background .13s ease, color .13s ease;
}
.langs button + button { border-left: 1px solid var(--rule-firm); }
.langs button:hover { background: var(--paper-sunk); color: var(--ink); }
.langs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.langs.dark { border-color: rgba(255, 255, 255, .2); }
.langs.dark button { color: #b8b0a2; padding: 5px 10px; font-size: 11.5px; }
.langs.dark button + button { border-left-color: rgba(255, 255, 255, .2); }
.langs.dark button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.langs.dark button[aria-pressed="true"] { background: var(--mark); color: #16140f; font-weight: 700; }

/* ------------------------------------------------------------------ login */

.login {
  width: min(360px, 100%); padding: var(--s6);
  display: flex; flex-direction: column; gap: var(--s3);
  box-shadow: var(--shadow);
}
.login h1 { font-size: 22px; display: flex; align-items: center; gap: var(--s2); }
.login p { margin: -8px 0 var(--s1); }
.login input { padding: 10px 12px; font-size: 14px; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 860px) {
  .wrap { padding: var(--s5) var(--s4) var(--s6); }
  .diff { grid-template-columns: 1fr; }
  th, td { padding-left: var(--s4); padding-right: var(--s4); }
  .linkbox .link { width: min(220px, 46vw); }
  h1 { font-size: 24px; }
}

@media (max-width: 620px) {
  .card-head { align-items: flex-start; flex-direction: column; }
  .reviewer-head { align-items: flex-start; }
  th.num, td.num { width: 58px; padding-left: var(--s2); padding-right: var(--s2); }
  .topbar { padding: 0 var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
