/* Plate Labeling. Light and dark from the system setting. The frame area is
   dark in both, so plates and corners read the same way. */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #16181d;
  --muted: #5e6573;
  --line: #dfe2e8;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --bad: #b91c1c;
  --radius: 10px;
  /* the frame area */
  --margin: #1b1e24;            /* outside where corners may go */
  --margin-allowed: #2c313a;    /* the 25 % around the image: corners of cut-off plates */
  --loading: #3a404b;
  --plate: #22d3ee;
  --current: #facc15;
  --selected: #22c55e;          /* the selected plate (Delete removes it) */
  --hover: #ef4444;             /* the corner under the cursor: it can be dragged */
  --tint: rgba(160, 160, 160, .18);   /* inside the plate under the cursor: a click selects it */
  --optional: #9ca3af;          /* review: a plate too small to count (dashed) */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #181b21;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --line: #2a2f38;
    --accent: #6d8dfa;
    --accent-text: #0f1115;
    --bad: #f87171;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }

button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }

/* login */
.login-page { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.login { width: min(360px, 100%); padding: 24px; display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 20px; }
.field { display: grid; gap: 4px; }
.field label { color: var(--muted); font-size: 13px; }
.field input {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.error { color: var(--bad); margin: 0; min-height: 1.4em; }

/* the labeling screen: bar, frame, help line */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; white-space: nowrap;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; }
.progress { color: var(--muted); }
.message { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }   /* one line: a wrapping bar would resize the frame */
.message.bad { color: var(--bad); }
.actions { display: flex; gap: 8px; }
.me { color: var(--muted); }
.me a { color: var(--accent); }
.stage { position: relative; min-height: 0; background: var(--margin); }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; display: block; }
.done {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #e8eaee; font-size: 18px;
}
.help { padding: 6px 16px; color: var(--muted); font-size: 12px; background: var(--panel); border-top: 1px solid var(--line); }

/* the labeling guide (guide.html) */
body.guide { height: auto; }
.guide-page { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
.guide-page h1 { margin: 8px 0; }
.guide-page h2 { margin-top: 28px; }
.guide-page .lead { color: var(--muted); font-size: 15px; }
.guide-page li { margin-bottom: 8px; }
.guide-page table { border-collapse: collapse; width: 100%; }
.guide-page th, .guide-page td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.guide-page dt { font-weight: 600; margin-top: 14px; }
.guide-page dd { margin: 4px 0 0; color: var(--muted); }
.guide-page a { color: var(--accent); }
kbd { font: 12px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--panel); }
.swatch { font-weight: 600; }
.swatch.red { color: #ef4444; }
.swatch.green { color: #22c55e; }

/* panels over the frame: tutorial home, results, tag picker */
.overlay {
  position: absolute; inset: 24px; margin: auto; max-width: 760px; max-height: calc(100% - 48px);
  overflow: auto; padding: 20px 24px; height: fit-content;
}
.overlay h2 { margin: 0 0 8px; }
.overlay p { margin: 8px 0; }
.overlay .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.overlay table { border-collapse: collapse; width: 100%; margin-top: 8px; }
.overlay th, .overlay td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.overlay tr.click { cursor: pointer; }
.overlay tr.click:hover { background: var(--bg); }
.overlay .grade { font-size: 32px; font-weight: 700; }
.overlay .pass { color: #15803d; }
.overlay .fail { color: var(--bad); }
.overlay .tags { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 8px; }
.overlay label { display: flex; gap: 6px; align-items: center; }
.tag { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); margin-right: 4px; }
.review-label { position: absolute; top: 8px; padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 13px; pointer-events: none; }
.compare-actions {
  position: absolute; left: 0; right: 0; bottom: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}

/* the admin dashboard (admin.html) */
body.admin { height: auto; min-height: 100%; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 4px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.tabs a.on { background: var(--bg); font-weight: 600; }
.admin-page { padding: 16px; }
.cards { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; min-width: 120px; color: var(--muted); }
.card-value { font-size: 22px; font-weight: 700; color: var(--text); }
table.grid { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); }
table.grid th, table.grid td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid tr.click { cursor: pointer; }
table.grid tr.click:hover { background: var(--bg); }
.pass { color: #15803d; } .fail { color: var(--bad); }
.hint { color: var(--muted); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 10px; }
.filters label { display: grid; gap: 2px; color: var(--muted); font-size: 12px; }
.filters select, .filters input { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.frame-view { position: fixed; inset: 0; background: var(--margin); display: grid; grid-template-rows: auto 1fr auto; z-index: 10; }
.frame-head, .frame-info { padding: 8px 16px; background: var(--panel); color: var(--text); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.frame-info p { margin: 0; }
#frame-canvas { width: 100%; height: 100%; display: block; min-height: 0; }
.shortcuts { position: fixed; right: 16px; top: 64px; z-index: 5; padding: 14px 18px; width: min(620px, calc(100% - 32px)); max-height: calc(100% - 120px); overflow: auto; }
.shortcuts td:first-child { width: 45%; }
.shortcuts h2 { margin: 0 0 8px; font-size: 16px; }
.shortcuts table { border-collapse: collapse; }
.shortcuts td { padding: 3px 10px 3px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.shortcuts td:last-child { white-space: nowrap; }
.help kbd, .shortcuts kbd { font: 12px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--panel); }
