:root {
  color-scheme: light dark;
  --bg: light-dark(#f3f4f7, #111318);
  --surface: light-dark(#ffffff, #1b1e25);
  --ink: light-dark(#202633, #f3f4f7);
  --muted: light-dark(#566173, #b4bece);
  --border: light-dark(#d8dce4, #363c49);
  --grid: light-dark(#e7eaf0, #2a303b);
  --cross: light-dark(#bac3d1, #4b5567);
  --accent: light-dark(#215bdd, #83b3ff);
  --accent-text: light-dark(#fff, #101b30);
  --active: light-dark(#b04412, #ffb05c);
  --highlight: light-dark(#e8efff, #252f43);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-block: 12px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--active); outline-offset: 3px; }
main {
  width: 100%; max-width: max(280px, calc(100svh - 150px)); margin: auto;
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 4px 6px; color: var(--ink); font-size: 17px; font-weight: 650; letter-spacing: -.3px; }
.brand img { display: block; flex-shrink: 0; }
footer { padding-top: 12px; }
.credit { margin: 4px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.credit a { display: inline-flex; align-items: center; min-height: 44px; color: inherit; text-underline-offset: 3px; }
.credit a:hover { color: var(--ink); }
.credit a:focus-visible { outline: 2px solid var(--active); outline-offset: 3px; border-radius: 3px; }
.share-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 12px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-size: 15px; font-weight: 600; }
.share-button:hover { filter: brightness(.94); }
.share-button:disabled { opacity: .65; cursor: default; }
#share-url { display: block; width: 100%; min-height: 44px; margin-top: 8px; padding: 10px; font-size: 16px; border: 1px solid var(--cross); border-radius: 8px; background: var(--surface); color: var(--ink); }
.map {
  position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); padding: 4px 4px 0 0; container-type: inline-size;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.plot { grid-column: 2; grid-row: 1; width: 100%; aspect-ratio: 1; }
.axis-side { grid-column: 1; grid-row: 1; position: relative; min-width: 0; min-height: 0; }
.axis-left { position: absolute; left: 50%; top: 50%; width: calc(100cqw - 52px); transform: translate(-50%, -50%) rotate(-90deg); }
.axis-bottom { grid-column: 2; grid-row: 2; }
.plot svg { display: block; width: 100%; height: 100%; touch-action: pan-y; user-select: none; overflow: visible; }
.grid { stroke: var(--grid); stroke-width: 1; }
.cross { stroke: var(--cross); stroke-width: 1; }
.frame { fill: none; stroke: var(--border); stroke-width: 1; }
.pin { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.pin.active { fill: var(--active); }
.halo { fill: var(--active); fill-opacity: .12; stroke: var(--active); stroke-opacity: .65; }
.pin-hit { fill: transparent; cursor: pointer; }
.pin-hit:focus-visible { outline: none; stroke: var(--active); stroke-width: 2; stroke-dasharray: 3 3; }
.pin-label { font-size: 12px; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; cursor: pointer; }
.pin-label.active { fill: var(--active); font-weight: 600; }
.tick { font: 11px ui-sans-serif, sans-serif; fill: var(--muted); pointer-events: none; }
.axis {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: transparent; border-radius: 7px; color: var(--accent);
  font-size: 14px; line-height: 1.4; font-weight: 600; min-height: 44px; padding: 8px; text-align: center;
}
.axis-edit { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 30px; height: 44px; padding: 6px; margin-block: -8px; border: 0; border-radius: 6px; background: transparent; color: var(--accent); }
.axis-edit-icon { width: 17px; height: 17px; }
.axis-name { cursor: text; min-width: 2ch; caret-color: var(--ink); overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.axis-left .axis-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.axis:hover, .axis:focus-within { background: var(--highlight); }
.axis-name:focus { outline: none; text-decoration: none; }
.axis-side:focus-within .axis-left {
  left: 6px; width: min(360px, calc(100cqw - 12px)); transform: translateY(-50%); z-index: 4;
  justify-content: space-between; text-align: left; font-size: 16px;
  background: var(--surface); border: 1px solid var(--cross); box-shadow: 0 3px 14px #0003;
}
.axis-side:focus-within .axis-name { display: block; overflow: auto; max-height: 12em; }
@media (hover: hover) {
  /* Keep the original gutter as the hover target so the label never flickers. */
  .axis-side:hover .axis-left {
    left: 6px; width: min(360px, calc(100cqw - 12px)); transform: translateY(-50%); z-index: 4;
    justify-content: space-between; text-align: left; font-size: 16px;
    background: var(--surface); border: 1px solid var(--cross); box-shadow: 0 3px 14px #0003;
  }
  .axis-side:hover .axis-name { display: block; overflow: auto; max-height: 12em; }
}
.composer { display: block; width: 100%; margin: 6px 0 4px; border: 1px solid var(--cross); border-radius: 8px; background: var(--surface); color: var(--ink); padding: 11px 12px; font-size: 16px; min-height: 48px; text-align: left; }
.composer::placeholder { color: var(--muted); opacity: 1; }
.composer:hover { border-color: var(--accent); color: var(--ink); }
.status { font-size: 13px; color: var(--active); margin: 8px 0; line-height: 1.4; overflow-wrap: anywhere; }
.phrase-row { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); min-height: 48px; }
.phrase-row.selected { background: var(--highlight); border-radius: 6px; }
.phrase-select { border: 0; background: transparent; color: var(--ink); display: flex; gap: 10px; align-items: center; text-align: left; flex: 1; min-width: 0; padding: 10px 8px; font-size: 14px; min-height: 48px; }
.phrase-select .text { overflow-wrap: anywhere; line-height: 1.4; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.selected .dot { background: var(--active); outline: 1px solid var(--active); outline-offset: 3px; }
.delete, .retry, .icon-button { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border: 0; background: transparent; color: var(--muted); min-height: 44px; min-width: 44px; border-radius: 7px; font-size: 22px; }
.delete:hover, .icon-button:hover { background: var(--highlight); color: var(--active); }
.retry { font-size: 13px; color: var(--active); }
.loading .dot { background: var(--muted); opacity: .5; }
.loading-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.point-card { position: absolute; z-index: 3; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 16px); padding: 2px 2px 2px 12px; border: 1px solid var(--cross); border-radius: 8px; background: var(--surface); box-shadow: 0 3px 14px #0003; }
.confidence { color: var(--muted); font-size: 12px; white-space: nowrap; }
.confidence strong { margin-left: 5px; color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.point-card .point-delete { color: var(--ink); }
@media (max-width: 600px) {
  main { max-width: none; padding-inline: max(4px, env(safe-area-inset-left)) max(4px, env(safe-area-inset-right)); padding-top: max(4px, env(safe-area-inset-top)); }
}
