/* Structure shared by all looks. A theme file sets the variables and its own touches. */

:root {
  --bg: #fff;
  --fg: #1d1d1f;
  --muted: #86868b;
  --line: #e5e5ea;
  --soft: #f5f5f7;
  --accent: #ff7a00;
  --link: inherit;
  --ok: #157f3b;
  --ok-bg: #e6f5eb;
  --first: #fff;
  --first-bg: #1f9d4c;
  --no: #c2410c;
  --no-bg: #fdeee6;
  --wait: #8a5a00;
  --wait-bg: #fff3d1;
  --frozen: #3451b2;
  --frozen-bg: #eaf0ff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: var(--font);
  --radius: 10px;
  --cell: 54px;
  --row: 48px;
  --gutter: 16px;
  --page: 760px;
  --page-wide: 1120px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-head); }
img { max-width: 100%; }

/* ---- header ---------------------------------------------------------------- */

.top { display: flex; align-items: center; gap: 8px 22px; flex-wrap: wrap; max-width: var(--page-wide); margin: 0 auto; padding: 16px var(--gutter) 12px; }
.brand { font-family: var(--font-head); font-weight: 650; font-size: 17px; text-decoration: none; color: var(--fg); }
.nav { display: flex; gap: 18px; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); }
.nav a.on, .nav a:hover { color: var(--fg); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 12px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.clock { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.clock.ph-after, .clock.ph-before { color: var(--muted); font-weight: 500; }
.clock.frozen::after { content: " ❄"; font-weight: 400; }
.who { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.who .me { color: var(--fg); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who form { margin: 0; }
.linklike { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.banner { max-width: var(--page-wide); margin: 0 auto 8px; padding: 10px var(--gutter); background: var(--wait-bg); }

@media (max-width: 640px) {
  .top { gap: 6px 16px; }
  .clock { margin-left: auto; }
  .nav { order: 3; width: 100%; gap: 16px; }
  .who { order: 2; }
  .who .me { max-width: 140px; }
}

.main { max-width: var(--page); margin: 0 auto; padding: 12px var(--gutter) 80px; }
body.wide .main { max-width: var(--page-wide); }
.empty { color: var(--muted); padding: 40px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- scoreboard ---------------------------------------------------------------- */

.board-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 8px; }
.board { --rankw: 40px; border-collapse: separate; border-spacing: 0; min-width: 100%; font-variant-numeric: tabular-nums; }
.board th, .board td { padding: 0 4px; text-align: center; height: var(--row); white-space: nowrap; }
.board thead th { font-weight: 600; color: var(--muted); height: 40px; }
.board .rank { width: var(--rankw); min-width: var(--rankw); color: var(--muted); }
.board .team { text-align: left; padding: 0 18px 0 6px; min-width: 150px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.board .prob, .board .cell, .board .stat { width: var(--cell); min-width: var(--cell); }
.board .prob a { text-decoration: none; color: inherit; display: block; }
.board .solved, .board .pen { width: 56px; min-width: 56px; font-weight: 600; }
.board .pen { color: var(--muted); font-weight: 500; }
.board .cell b { display: block; font-weight: 650; line-height: 1.15; font-size: 15px; }
.board .cell i { display: block; font-style: normal; font-size: 11px; line-height: 1.2; opacity: .75; min-height: 13px; }
.board .cell.ok { background: var(--ok-bg); color: var(--ok); }
.board .cell.ok.first { background: var(--first-bg); color: var(--first); }
.board .cell.no { background: var(--no-bg); color: var(--no); }
.board .cell.wait { background: var(--wait-bg); color: var(--wait); }
.board .cell.frozen { background: var(--frozen-bg); color: var(--frozen); }
.board tfoot td { color: var(--muted); font-size: 13px; height: 44px; }
.board tfoot .stat i { display: block; font-style: normal; font-size: 11px; opacity: .7; }
.board tr.me .team { color: var(--accent); }

@media (max-width: 760px) {
  :root { --cell: 42px; --row: 44px; }
  .board .rank, .board .team { position: sticky; z-index: 1; background: var(--bg); }
  .board { --rankw: 30px; }
  .board .rank { left: 0; }
  .board .team { left: var(--rankw); min-width: 96px; max-width: 112px; padding-right: 8px; }
}

/* ---- problems ------------------------------------------------------------------ */

.plist { list-style: none; margin: 0; padding: 0; }
.pitem a { display: grid; grid-template-columns: 36px 1fr auto 36px; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.pcode { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 650; font-size: 14px; color: var(--fg); box-shadow: inset 0 0 0 2px var(--c, var(--line)); }
.pstate { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.pstate.ok { color: var(--ok); }
.pstate.no { color: var(--no); }
.pstate.wait { color: var(--wait); }
.pcount { text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.phead { display: flex; align-items: center; gap: 12px; margin: 8px 0 18px; }
.phead h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -.01em; }
.phead .pcode { width: 34px; height: 34px; font-size: 16px; }
.phead .pstate { margin-left: auto; }
.statement { margin: 0 0 22px; max-width: 64ch; }
.statement p { margin: 0 0 10px; }
.statement .big { font-size: 24px; letter-spacing: .06em; font-weight: 600; margin: 8px 0 16px; }
.closed { color: var(--muted); padding: 8px 0 24px; }

/* ---- forms ----------------------------------------------------------------------- */

.answer, .stack { display: grid; gap: 16px; max-width: 640px; }
.field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.flabel { font-size: 13px; color: var(--muted); font-weight: 500; }
fieldset.field { display: grid; }
legend.flabel { padding: 0; margin-bottom: 6px; }
input[type=text], input[type=email], input:not([type]), textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--fg); }
textarea { resize: vertical; min-height: 90px; }
input.code { font-size: 24px; letter-spacing: .3em; font-variant-numeric: tabular-nums; max-width: 240px; }
.mono, textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; }
.opt { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.opt input { width: 18px; height: 18px; margin: 0; accent-color: var(--fg); flex: none; }
.f-choice .opt, .f-multi .opt { padding: 7px 0; }
.f-file input { padding: 8px 0; border: 0; font-size: 14px; color: var(--muted); }
.f-file input::file-selector-button { font: inherit; font-size: 15px; color: var(--fg); background: var(--bg); border: 1px solid var(--fg); border-radius: var(--radius); padding: 9px 16px; margin-right: 12px; cursor: pointer; }
.f-file input::file-selector-button:hover { background: var(--soft); }
.previews { display: flex; gap: 8px; flex-wrap: wrap; }
.previews img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
.actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.submit, .button, button.btn-ok, button.btn-no, button.btn-plain, .inline-form button, .filters button {
  display: inline-block; padding: 10px 20px; border: 0; border-radius: var(--radius); background: var(--fg); color: var(--bg);
  font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.3;
}
.submit:disabled { opacity: .5; cursor: default; }
.secondary { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.flash { margin: 0 0 18px; padding: 10px 14px; border-radius: var(--radius); background: var(--soft); }
.flash-ok { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.flash-no, .flash-error { background: var(--no-bg); color: var(--no); font-weight: 600; }
.flash-wait { background: var(--wait-bg); color: var(--wait); font-weight: 600; }
.flash-note { background: var(--soft); }

.login { max-width: 380px; margin: 48px auto; }
.login h1 { font-size: 26px; margin: 0 0 20px; }
.sent { margin: 0 0 12px; color: var(--muted); }
.sent b { color: var(--fg); font-weight: 500; }

/* ---- crossword ----------------------------------------------------------------------- */

.xw { display: grid; gap: 22px; }
.xw-grid { --size: min(40px, calc((100vw - 2 * var(--gutter)) / var(--cols))); display: grid; grid-template-columns: repeat(var(--cols), var(--size)); grid-auto-rows: var(--size); width: max-content; }
.xw-cell, .xw-block { position: relative; border: 1px solid var(--fg); margin: 0 -1px -1px 0; }
.xw-block { background: transparent; border-color: transparent; }
.xw-cell { background: var(--bg); }
.xw-cell input { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; padding: 0; background: transparent; text-align: center; text-transform: uppercase; font-size: calc(var(--size) * .5); font-weight: 600; caret-color: transparent; }
.xw-cell input:focus { background: var(--wait-bg); }
.xw-cell.in-word { background: var(--soft); }
.xw-n { position: absolute; top: 1px; left: 2px; font-size: 9px; line-height: 1; color: var(--muted); pointer-events: none; z-index: 1; }
.xw-clues { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.xw-clues h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.xw-clues ol { margin: 0; padding-left: 26px; }
.xw-clues li { padding: 2px 0; }
.xw-clues li.on { background: var(--wait-bg); }
@media (max-width: 560px) { .xw-clues { grid-template-columns: 1fr; } }

/* ---- sudoku ------------------------------------------------------------------------------ */

.sd-grid { --size: min(46px, calc((100vw - 2 * var(--gutter) - 4px) / 9)); display: grid; grid-template-columns: repeat(9, var(--size)); grid-auto-rows: var(--size); border: 2px solid var(--fg); width: max-content; }
.sd-cell { position: relative; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: calc(var(--size) * .5); font-variant-numeric: tabular-nums; }
.sd-cell:nth-child(9n) { border-right: 0; }
.sd-cell:nth-last-child(-n+9) { border-bottom: 0; }
.sd-cell.br { border-right: 2px solid var(--fg); }
.sd-cell.bb { border-bottom: 2px solid var(--fg); }
.sd-cell.given { font-weight: 650; }
.sd-cell input { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; padding: 0; text-align: center; background: transparent; font-size: inherit; color: var(--frozen); caret-color: transparent; }
.sd-cell input:focus { background: var(--wait-bg); }
.sd-cell.peer { background: var(--soft); }

/* ---- nonogram ------------------------------------------------------------------------------ */

.ng { overflow-x: auto; }
.ng-grid { --size: min(30px, calc((100vw - 2 * var(--gutter) - 70px) / 10)); border-collapse: collapse; user-select: none; -webkit-user-select: none; touch-action: none; }
.ng-grid th { font-weight: 500; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ng-col { vertical-align: bottom; padding: 0 0 4px; width: var(--size); }
.ng-col span { display: block; line-height: 1.25; }
.ng-row { text-align: right; padding: 0 6px 0 0; white-space: nowrap; }
.ng-row span + span { margin-left: 5px; }
.ng-grid td { width: var(--size); height: var(--size); padding: 0; border: 1px solid var(--line); }
.ng-grid td.br { border-right: 2px solid var(--fg); }
.ng-grid tr.bb td { border-bottom: 2px solid var(--fg); }
.ng-grid tbody tr:first-child td { border-top: 2px solid var(--fg); }
.ng-grid tbody tr:last-child td { border-bottom: 2px solid var(--fg); }
.ng-grid tbody td:last-child { border-right: 2px solid var(--fg); }
.ng-grid tbody th + td { border-left: 2px solid var(--fg); }
.ng-grid input { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; background: transparent; cursor: pointer; }
.ng-grid input:checked { background: var(--fg); }
.ng-grid input.x { background: linear-gradient(45deg, transparent 46%, var(--muted) 46% 54%, transparent 54%), linear-gradient(-45deg, transparent 46%, var(--muted) 46% 54%, transparent 54%); }
.ng-grid input:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---- the word game ------------------------------------------------------------------------- */

.guesses { border-collapse: collapse; margin: 0 0 16px; font-variant-numeric: tabular-nums; }
.guesses th { font-size: 12px; color: var(--muted); font-weight: 500; padding: 0 10px 6px; }
.guesses td { padding: 3px 10px; text-align: center; }
.guesses .n { color: var(--muted); font-size: 13px; width: 24px; }
.guesses .w { display: flex; gap: 4px; }
.guesses .w span { display: inline-flex; width: 36px; height: 40px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; font-weight: 650; font-size: 18px; }
.guesses .slot .w span { border-style: dashed; }
.guesses .b, .guesses .c { font-weight: 650; font-size: 18px; min-width: 52px; }
.guesses tr.hit .w span { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.guess { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.guess input { width: 200px; text-transform: uppercase; letter-spacing: .2em; font-weight: 600; font-size: 18px; }
.guess .left { color: var(--muted); font-size: 13px; }

/* ---- submissions ------------------------------------------------------------------------------ */

.history h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 40px 0 8px; }
.subs { border-collapse: collapse; width: 100%; }
.subs td { padding: 10px 12px 10px 0; border-top: 1px solid var(--line); vertical-align: top; }
.subs .t { color: var(--muted); font-variant-numeric: tabular-nums; width: 56px; white-space: nowrap; }
.subs .p { width: 32px; font-weight: 600; }
.subs .v { width: 1%; white-space: nowrap; text-align: right; }
.verdict { font-weight: 600; }
.v-accepted { color: var(--ok); }
.v-rejected { color: var(--no); }
.v-pending { color: var(--wait); }
.v-ignored { color: var(--muted); text-decoration: line-through; }
.comment { display: block; color: var(--muted); font-size: 13px; white-space: normal; max-width: 260px; }
.answer-view { display: grid; gap: 4px; min-width: 0; }
.av-row { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }
.av-label { padding-top: 1px; }
.av-label { color: var(--muted); font-size: 13px; }
.multiline { white-space: pre-wrap; }
.grid-text { margin: 0; font: 12px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .2em; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 160px; max-height: 160px; object-fit: cover; border-radius: 8px; display: block; background: var(--soft); }

/* ---- admin ----------------------------------------------------------------------------------- */

.subnav { display: flex; gap: 18px; flex-wrap: wrap; margin: 0 0 22px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.subnav a { text-decoration: none; color: var(--muted); }
.subnav a.on { color: var(--fg); font-weight: 600; }
.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.qitem { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 12px; }
.qhead { display: flex; gap: 14px; flex-wrap: wrap; align-items: baseline; }
.judge { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.judge input { flex: 1 1 220px; width: auto; }
.judge button { padding: 9px 14px; }
button.btn-ok { background: var(--ok); color: #fff; }
button.btn-no { background: var(--no); color: #fff; }
button.btn-plain { background: var(--soft); color: var(--fg); font-weight: 500; }
button.current { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.filters select { width: auto; }
.list { border-collapse: collapse; width: 100%; margin: 0 0 20px; }
.list td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr.is-hidden td { opacity: .55; }
.list .pcode-cell { width: 44px; }
.list.files .thumb img { width: 56px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.list.files input { min-width: 260px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 18px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.card.danger { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.plain { list-style: none; margin: 0 0 12px; padding: 0; }
.plain li { padding: 5px 0; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
form.inline { display: inline; margin: 0; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input { width: auto; flex: 1 1 220px; }
.linkbox { display: grid; gap: 6px; }
.editor { max-width: 860px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row .field { flex: 1 1 160px; }
.row .field.narrow { flex: 0 0 110px; }
.row .field.grow { flex: 3 1 240px; }
input[type=color] { width: 100%; height: 42px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.themes { display: flex; gap: 6px 22px; flex-wrap: wrap; }
.detail h2 { font-size: 18px; margin: 0 0 4px; }
.detail .answer-view { margin: 18px 0; }

.ng-modes { display: flex; gap: 6px; margin: 0 0 10px; }
.ng-modes button { width: 40px; height: 34px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer; font-size: 15px; }
.ng-modes button.on { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }

.mini { display: inline-grid; grid-template-columns: repeat(var(--cols), 13px); grid-auto-rows: 13px; border: 1px solid var(--fg); background: var(--bg); }
.mini i { font-style: normal; font-size: 9px; line-height: 13px; text-align: center; box-shadow: inset -1px -1px 0 var(--line); }
.mini i.block { background: var(--fg); box-shadow: none; }
.mini-pixels { grid-template-columns: repeat(var(--cols), 7px); grid-auto-rows: 7px; }
.mini-pixels i { box-shadow: none; }
.mini-pixels i.on { background: var(--fg); }
.answer.solved { opacity: .9; }
.answer.solved input:disabled, .answer.solved textarea:disabled { color: var(--fg); -webkit-text-fill-color: var(--fg); opacity: 1; }
