/* Crater Counter: the planetary mapping lab. The survey monitor (orbital image pair, legend, log strip, contact inset,
   reference) on the left; the survey log (steps and controls) on the right. Art from art.js; colors from --cc-* below,
   light and dark. */
html {
  --cc-land1: #c9c6bd; --cc-land2: #9c998f; --cc-mare1: #6f7480; --cc-mare2: #545964; --cc-blotch: #5d5a52; --cc-grain: #4a4740;
  --cc-bowl-lit: #e9e6dc; --cc-bowl-mid: #8e8b82; --cc-bowl-dark: #3f3d38; --cc-ejecta: #f1efe6; --cc-rim: #fbfaf4; --cc-shadow: #26241f;
  --cc-pit: #5f5c55; --cc-ridge: #8a909c; --cc-lava-edge: #3a3e47; --cc-veil: rgba(20, 26, 44, .55);
  --cc-frame-line: #1d2742; --cc-corner: #3fd2ff; --cc-scan: #7fe3ff; --cc-tally: #ffb703; --cc-tally-ring: #1d2742;
  --cc-ink: #1b2236; --cc-panel1: #f7f8fc; --cc-panel2: #e9edf7; --cc-accent: #3d4f8a; --cc-ok: #13704a; --cc-bad: #b3261e;
  --cc-chip: #ffffff; --cc-chip-on: #dfe5f7; --cc-chip-line: #9aa6c4; --cc-bezel1: #2a3350; --cc-bezel2: #161c30; --cc-screen-ink: #e9f3ff;
  --cc-lavatag: #2f3542; --cc-lavatag-ink: #ffe2b8;
}
html.cc-mars {
  --cc-land1: #d39a6a; --cc-land2: #a8643b; --cc-mare1: #7b4a35; --cc-mare2: #5d3526; --cc-blotch: #6d3a1f; --cc-grain: #5b301b;
  --cc-bowl-lit: #f0c39a; --cc-bowl-mid: #a5623a; --cc-bowl-dark: #4a2414; --cc-ejecta: #f6d2ae; --cc-rim: #fff3e4; --cc-pit: #6a3a22; --cc-ridge: #b17859;
}
html[data-theme="dark"] {
  --cc-veil: rgba(4, 8, 20, .6); --cc-frame-line: #8fa3d9;
  --cc-ink: #e7ecf8; --cc-panel1: #1e2335; --cc-panel2: #181c2b; --cc-accent: #a9b8ff; --cc-ok: #4fd08c; --cc-bad: #ff8a80;
  --cc-chip: #151927; --cc-chip-on: #2b3459; --cc-chip-line: #4f5a80; --cc-bezel1: #0f1322; --cc-bezel2: #070a14;
}

/* ── layout ── */
.cc { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(616px, 1fr) minmax(360px, 412px); grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: 'mon log' 'under log'; gap: 0 12px; padding: 10px; color: var(--tlg-text); font-size: 16px; overflow: auto; }
.cc *, .cc *::before, .cc *::after { box-sizing: border-box; }
.cc input, .cc button { font: inherit; }
.cc-left { grid-area: mon; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 8px 8px 6px;
  background: linear-gradient(var(--cc-bezel1), var(--cc-bezel1) 70%, #222a45); border-radius: 16px 16px 0 0; box-shadow: 0 -1px 8px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .08);
  color: var(--cc-screen-ink); }
html[data-theme="dark"] .cc-left { background: linear-gradient(var(--cc-bezel1), var(--cc-bezel1) 70%, #121729); }
.cc-panel { grid-area: log; display: flex; flex-direction: column; gap: 5px; min-height: 0; overflow: auto; padding: 8px 12px;
  background: linear-gradient(var(--cc-panel1), var(--cc-panel2)); color: var(--cc-ink); border: 3px solid var(--cc-accent);
  border-radius: 14px; box-shadow: 0 3px 8px rgba(0, 0, 0, .16); }

/* monitor header */
.cc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cc-body { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 999px; background: rgba(255, 255, 255, .1); font-weight: 700; }
.cc-body-ball { fill: #c9c6bd; stroke: #fff; stroke-width: 1.2; }
.cc-body-pit { fill: #8e8b82; }
.cc.is-mars .cc-body-ball { fill: #d39a6a; }
.cc.is-mars .cc-body-pit { fill: #8d4a26; }
.cc-head-l { margin-left: auto; font-weight: 700; opacity: .9; }
.cc-tabs { display: flex; gap: 6px; }
.cc-tab { min-height: 40px; padding: 4px 12px; border: 2px solid #5a6a9a; border-radius: 10px; background: #1f2843; color: var(--cc-screen-ink); font-weight: 700; cursor: pointer; }
.cc-tab:hover:not(:disabled) { border-color: var(--cc-corner); }
.cc-tab.is-on { background: #e9f3ff; color: #14203d; border-color: var(--cc-corner); box-shadow: 0 0 0 2px rgba(63, 210, 255, .35); }
.cc-tab.is-on::before { content: '▸ '; }
.cc-tab:disabled { cursor: default; opacity: .75; }
.cc-tab.is-on:disabled { opacity: 1; }
.cc-tab:focus-visible, .cc-chip:focus-visible, .cc-stepbtn:focus-visible, .cc-log:focus-visible, .cc input:focus-visible,
.cc-scene:focus-visible, .cc summary:focus-visible { outline: 3px solid var(--tlg-focus, #ffb703); outline-offset: 2px; }

/* the image pair: drawn 1:1 (600 × 290); narrow screens scroll sideways */
.cc-scene { flex: none; overflow-x: auto; overflow-y: hidden; border-radius: 10px; background: #0b1020; padding: 4px 0; }
.cc-map { display: block; margin: 0 auto; }
.cc-map text { font-family: inherit; }
.cc-t-region { font-size: 18px; font-weight: 800; fill: var(--cc-screen-ink); }
.cc-t-area { font-size: 17px; font-weight: 700; fill: var(--cc-screen-ink); }
.cc-t-veil { font-size: 18px; font-weight: 700; fill: #fff; }
.cc-lavatag rect { fill: var(--cc-lavatag); stroke: #ffb27a; stroke-width: 1.5; }
.cc-lavatag text { font-size: 16px; font-weight: 700; fill: var(--cc-lavatag-ink); }
.cc-corner { fill: none; stroke: var(--cc-corner); stroke-width: 3; stroke-linecap: round; }
.cc-crater { cursor: pointer; }
.cc.is-locked .cc-crater, .cc.is-logged .cc-crater { cursor: default; }
.cc-hit { fill: transparent; }
.cc-tally { fill: var(--cc-tally); stroke: var(--cc-tally-ring); stroke-width: 2; opacity: 0; transition: opacity .12s; }
.cc-crater.is-tallied .cc-tally { opacity: 1; }
.cc-crater:hover .cc-hit { fill: rgba(127, 227, 255, .18); }
.cc.is-locked .cc-crater:hover .cc-hit, .cc.is-logged .cc-crater:hover .cc-hit { fill: transparent; }
.cc-cnum { font-size: 16px; font-weight: 800; text-anchor: middle; fill: #fff; stroke: #10172b; stroke-width: 4px; paint-order: stroke; opacity: 0;
  transform: scale(.4); transition: opacity .18s, transform .18s; }
.cc-crater.is-numbered .cc-cnum { opacity: 1; transform: scale(1); }
.cc-skip { stroke: var(--cc-bad); stroke-width: 2.6; stroke-linecap: round; opacity: 0; }
html[data-theme="dark"] .cc-skip { stroke: #ff8a80; }
.cc-crater.is-skipped { opacity: .75; }
.cc-crater.is-skipped .cc-skip { opacity: 1; }

/* legend */
.cc-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; line-height: 1.2; }
.cc-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cc-legend svg { flex: none; background: #8e8b82; border-radius: 6px; --cc-rim: #fbfaf4; }
.cc-schematic { font-style: italic; opacity: .9; }

/* under the monitor */
.cc-under { grid-area: under; display: grid; grid-template-columns: 1fr; gap: 8px; color: var(--cc-ink); align-items: start; align-content: start;
  min-width: 0; min-height: 0; overflow: auto; padding: 0 8px 8px; border-radius: 0 0 16px 16px; background: linear-gradient(#222a45, var(--cc-bezel2));
  box-shadow: 0 6px 12px rgba(0, 0, 0, .24); }
html[data-theme="dark"] .cc-under { background: linear-gradient(#121729, var(--cc-bezel2)); }
.cc-under.has-contact { grid-template-columns: 322px minmax(0, 1fr); }
.cc-side { display: grid; gap: 8px; min-width: 0; }
.cc-logstrip:empty { display: none; }
.cc-logstrip, .cc-contact, .cc-ref, .cc-about { background: var(--cc-panel1); border-radius: 10px; padding: 8px 10px; }
.cc-logline { margin: 0; line-height: 1.35; }
.cc-contact { margin: 0; display: grid; gap: 4px; }
.cc-contact h3 { margin: 0; font-size: 17px; }
.cc-contact-box { overflow-x: auto; }
.cc-contact-box svg { display: block; }
.cc-contact figcaption { line-height: 1.35; align-self: center; }
.cc-contact-svg text { font-size: 21px; font-weight: 800; fill: #14203d; }
.cc-ct-badge { fill: #fff6d6; stroke: #14203d; stroke-width: 2; }
.cc-contact-svg .cc-ct-lavalabel { fill: #ffe2b8; font-size: 20px; }
.cc-ct-step rect { fill: #14203d; opacity: .9; }
.cc-contact-svg .cc-ct-step text { fill: #fff; font-size: 20px; }
.cc summary { cursor: pointer; font-weight: 700; min-height: 28px; }
.cc-ref p, .cc-about p { margin: 6px 0 0; line-height: 1.4; }
.cc-ref table { border-collapse: collapse; width: 100%; margin: 8px 0 0; font-size: 16px; }
.cc-ref caption { text-align: left; font-weight: 700; padding-bottom: 4px; }
.cc-ref th, .cc-ref td { padding: 3px 8px; border-bottom: 1px solid var(--cc-chip-line); text-align: left; font-variant-numeric: tabular-nums; }
.cc-ref tr.is-bracket td { background: var(--cc-chip-on); font-weight: 700; }
.cc-ref tr.is-bracket td:first-child::before { content: '▸ '; }

/* reveal: density bars */
.cc-result { display: grid; gap: 4px; }
.cc-result-h, .cc-result-n { margin: 0; line-height: 1.3; }
.cc-bar-row { display: grid; grid-template-columns: 22px minmax(60px, 1fr); align-items: center; gap: 0 8px; }
.cc-bar-row .cc-bar-v { grid-column: 2; }
.cc-bar-l { font-weight: 800; }
.cc-bar-track { height: 18px; border-radius: 9px; background: var(--cc-panel2); border: 1px solid var(--cc-chip-line); overflow: hidden; }
.cc-bar-fill { display: block; height: 100%; width: 0; background: repeating-linear-gradient(45deg, #8e9ccc, #8e9ccc 6px, #a8b4dc 6px, #a8b4dc 12px); transition: width .7s ease-out; }
.cc-bar-row.is-older .cc-bar-fill { background: var(--cc-accent); }
.cc-bar-row.is-older .cc-bar-v { font-weight: 800; }
.cc-bar-v { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── survey log (right) ── */
.cc-kicker { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--cc-accent); }
.cc-step { display: grid; gap: 4px; }
.cc-step-b { display: grid; gap: 4px; }
.cc-step-h { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; line-height: 1.2; }
.cc-n { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--cc-accent); color: #fff; font-size: 16px; font-weight: 800; }
html[data-theme="dark"] .cc-n { color: #141a2e; }
.cc-step.is-done .cc-n { background: var(--cc-ok); }
.cc-mark { margin-left: auto; font-weight: 800; }
.cc-mark.is-ok { color: var(--cc-ok); }
.cc-mark.is-bad { color: var(--cc-bad); }
.cc-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cc-region { display: grid; gap: 4px; align-content: start; }
.cc-num { display: grid; gap: 2px; position: relative; }
.cc-num.is-wide { grid-template-columns: auto 1fr auto; align-items: center; column-gap: 10px; margin-top: 2px; }
.cc-num-l { font-weight: 700; }
.cc-stepper, .cc-unitrow { display: flex; align-items: stretch; gap: 4px; }
.cc-stepbtn { flex: none; width: 40px; min-height: 42px; border: 2px solid var(--cc-chip-line); border-radius: 10px; background: var(--cc-chip); color: var(--cc-ink); font-size: 22px; font-weight: 800; line-height: 1; cursor: pointer; }
.cc-stepbtn:hover:not(:disabled) { border-color: var(--cc-accent); }
.cc-stepbtn:disabled { cursor: default; opacity: .55; }
.cc input[type="text"] { min-width: 0; width: 100%; min-height: 42px; padding: 4px 8px; border: 2px solid var(--cc-chip-line); border-radius: 10px; background: var(--cc-chip); color: var(--cc-ink); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cc-stepper input[type="text"] { text-align: center; }
.cc input:disabled { opacity: 1; background: var(--cc-panel2); }
.cc input.is-ok { border-color: var(--cc-ok); }
.cc input.is-bad { border-color: var(--cc-bad); border-style: dashed; }
.cc-unit { align-self: center; white-space: nowrap; font-weight: 700; }
.cc-fmark { position: absolute; right: 2px; top: 0; font-weight: 800; }
.cc-num.is-wide .cc-fmark { position: static; white-space: nowrap; }
.cc-fmark.is-ok { color: var(--cc-ok); }
.cc-fmark.is-bad { color: var(--cc-bad); }
.cc-tip { margin: 0; font-size: 16px; opacity: .85; }
.cc.is-logged .cc-tip, .cc.is-locked .cc-tip { visibility: hidden; }

.cc-chips { display: grid; gap: 5px; }
.cc-chips--3 { grid-template-columns: repeat(3, 1fr); }
.cc-chips--2 { grid-template-columns: 1fr 1fr; }
.cc-chips--cal { grid-template-columns: 1fr 1.35fr 1fr; }
.cc-chip { position: relative; display: flex; align-items: center; justify-content: center; min-height: 42px; min-width: 0; padding: 4px 18px 4px 8px;
  border: 2px solid var(--cc-chip-line); border-radius: 10px; background: var(--cc-chip); color: var(--cc-ink); font-size: 16px; line-height: 1.15; text-align: center; cursor: pointer; }
.cc-chips--tall .cc-chip { min-height: 58px; }
.cc-chip:hover:not(:disabled) { border-color: var(--cc-accent); }
.cc-chip.is-on { border-color: var(--cc-accent); background: var(--cc-chip-on); font-weight: 700; box-shadow: inset 0 0 0 1px var(--cc-accent); }
.cc-chip.is-on::before { content: '●'; position: absolute; right: 5px; top: 2px; font-size: 12px; color: var(--cc-accent); }
.cc-chip-m { position: absolute; right: 5px; bottom: 2px; font-weight: 800; }
.cc-chip.is-key { border-color: var(--cc-ok); box-shadow: inset 0 0 0 2px var(--cc-ok); }
.cc-chip.is-key .cc-chip-m { color: var(--cc-ok); }
.cc-chip.is-wrong { border-color: var(--cc-bad); border-style: dashed; }
.cc-chip.is-wrong .cc-chip-m { color: var(--cc-bad); }
.cc-chip:disabled { cursor: default; opacity: 1; }
.cc-chip.is-on:disabled::before { content: ''; }

.cc-logbar { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 4px; }
.cc-log { flex: none; min-height: 44px; min-width: 140px; padding: 6px 16px; border: 0; border-radius: 10px; background: var(--cc-accent); color: #fff; font-weight: 800; cursor: pointer; }
html[data-theme="dark"] .cc-log { color: #141a2e; }
.cc-log.is-edit { background: transparent; color: var(--cc-accent); box-shadow: inset 0 0 0 2px var(--cc-accent); }
.cc-log:disabled { opacity: .5; cursor: default; }
html[data-theme="dark"] .cc-log.is-edit { color: var(--cc-accent); }
.cc.is-locked .cc-log { opacity: .75; }
.cc-lognote { line-height: 1.25; }

/* Briefing example */
.cc-exwrap { overflow-x: auto; }
.cc-ex { display: block; width: 400px; max-width: none; height: 200px; }
.cc-ex-t { font-size: 17px; font-weight: 700; fill: currentColor; }

/* narrow screens: one column; the image pair scrolls sideways */
@media (max-width: 1040px) {
  .cc { grid-template-columns: minmax(0, 1fr); grid-template-rows: max-content max-content max-content; grid-template-areas: 'mon' 'log' 'under'; gap: 10px; overflow: auto; }
  .cc-left, .cc-under { border-radius: 16px; }
  .cc-under { padding-top: 8px; overflow: visible; }
  .cc-panel { overflow: visible; }
}
@media (max-width: 520px) {
  .cc { padding: 6px; }
  .cc-chips--3 { grid-template-columns: 1fr; }
  .cc-under.has-contact { grid-template-columns: 1fr; }
  .cc-head-l { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cc *, .cc *::before, .cc *::after { transition: none !important; animation: none !important; }
}
