/* MSM samurai review site — responsive dark theme for outdoor phone use.
   No web fonts, no third-party CSS: system font stack only. */

:root {
  --bg: #0b0e13;
  --bg-soft: #12161e;
  --panel: #171c26;
  --panel-2: #1e2531;
  --line: #2b3444;
  --text: #eef2f8;
  --muted: #9aa7bb;
  --accent: #58c4ff;
  --accent-2: #7ef0c0;
  --warn: #ffb84d;
  --danger: #ff6b6b;
  --cue: #c792ff;
  --ok: #4fd18b;
  --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

body.modal-open { overflow: hidden; }

a { color: var(--accent); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #04121c; padding: 10px 14px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

header.site-head {
  position: sticky; top: 0; z-index: 30;
  background: rgba(11, 14, 19, 0.96);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px 8px;
  backdrop-filter: blur(6px);
}

h1 { font-size: 1.15rem; margin: 0 0 2px; letter-spacing: 0.02em; }
h2 { font-size: 1rem; margin: 18px 0 8px; }
h3 { font-size: 1.02rem; margin: 0; }

.subline { color: var(--muted); font-size: 0.8rem; word-break: break-all; }

.disclosure {
  background: #2a2113; border: 1px solid #6b5320; color: #ffe6b8;
  border-radius: var(--radius); padding: 8px 10px; font-size: 0.82rem; margin: 8px 0 0;
}
.disclosure strong { color: #ffd37a; }

.storage-warning {
  background: #3a1414; border: 1px solid #7d2a2a; color: #ffd4d4;
  border-radius: var(--radius); padding: 8px 10px; font-size: 0.82rem; margin: 8px 0 0;
}

section.overview { padding: 14px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px;
  margin-bottom: 10px;
}
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px;
}
.stat .k { display: block; color: var(--muted); font-size: 0.72rem; }
.stat .v { display: block; font-size: 1.25rem; font-weight: 700; }
.stat.needs .v { color: var(--danger); }
.stat.reviewed .v { color: var(--ok); }
.stat.unreviewed .v { color: var(--warn); }

.progress { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s ease; }

.control-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 6px; }
.control-label { color: var(--muted); font-size: 0.8rem; margin-right: 2px; }

button, .btn {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 13px; min-height: 42px; cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
button[aria-pressed="true"] { background: #10384f; border-color: var(--accent); color: #dff4ff; font-weight: 600; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 6px 14px 8px; -webkit-overflow-scrolling: touch; }
.tabs .tab { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab-badge {
  display: inline-block; min-width: 22px; text-align: center;
  background: #4a3a12; color: #ffd98a; border-radius: 999px; padding: 0 6px; font-size: 0.74rem;
}
.tab-badge.is-clear { background: #143a26; color: #93f0be; }
.tab-badge.has-needs { background: #4a1616; color: #ffb3b3; }

.summary-table { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px; }
.summary-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; min-height: 40px; font-size: 0.82rem; text-align: left;
}
.summary-name { font-weight: 600; }
.summary-nums { color: var(--muted); font-variant-numeric: tabular-nums; }

main.board { padding: 0 14px 60px; }

.group-head {
  position: sticky; top: 106px; z-index: 10;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; margin: 14px 0 8px;
}
.group-title-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.group-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.group-action { font-weight: 700; color: var(--accent-2); }
.group-direction { font-weight: 700; }
.group-machine { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.02em; }
.group-note { color: var(--muted); font-size: 0.76rem; margin: 4px 0 0; }
.group-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.seq-preview { display: flex; align-items: center; gap: 8px; }
.seq-preview img {
  width: 56px; height: 56px; object-fit: contain;
  background: repeating-conic-gradient(#20242c 0% 25%, #171b22 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--line); border-radius: 8px;
}
.play-btn { min-height: 44px; padding: 6px 12px; font-size: 0.85rem; }

.frame-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.card.is-unreviewed { border-left: 4px solid var(--warn); }
.card.is-reviewed { border-left: 4px solid var(--ok); }
.card.is-needs { border-left: 4px solid var(--danger); background: #1d1418; }

.thumb {
  padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: repeating-conic-gradient(#20242c 0% 25%, #171b22 0% 50%) 50% / 20px 20px;
  cursor: zoom-in; width: 100%; min-height: 44px;
}
.thumb img { display: block; width: 100%; height: auto; }

.card-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.76rem; }
.card-index { font-weight: 700; color: var(--text); }
.card-hash { color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 0.7rem; }

.card-flags { display: flex; flex-wrap: wrap; gap: 4px; }

.badge {
  display: inline-block; font-size: 0.68rem; line-height: 1.3;
  border-radius: 6px; padding: 2px 6px; border: 1px solid;
}
.badge-warning { color: #ffd98a; background: #3a2e12; border-color: #7a611f; }
.badge-defect { color: #ffc2c2; background: #431717; border-color: #8a2c2c; }
.badge-cue { color: #e6d4ff; background: #322148; border-color: #6b45a0; }

.mark { display: none; gap: 12px; flex-wrap: wrap; }
body[data-mode="mark"] .mark { display: flex; }
.mark-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; min-height: 40px; }
.mark-label input { width: 22px; height: 22px; accent-color: var(--accent); }
.mark-needs { color: #ffb3b3; }

.notebox { display: none; flex-direction: column; gap: 6px; }
body[data-mode="note"] .notebox { display: flex; }
.note-input {
  width: 100%; min-height: 66px; resize: vertical; background: #0e1218; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; font-size: 0.86rem;
}
.note-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-actions button { min-height: 40px; padding: 6px 12px; font-size: 0.82rem; }
.note-status { color: var(--accent-2); font-size: 0.74rem; }

.empty-note { color: var(--muted); }

.io-panel {
  margin: 14px 0 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px;
}
.io-panel h2 { margin-top: 0; }
.io-hint { color: var(--muted); font-size: 0.79rem; margin: 6px 0; }
.import-report { white-space: pre-wrap; font-size: 0.79rem; margin: 8px 0 0; font-family: ui-monospace, Consolas, monospace; }
.import-report.is-ok { color: var(--ok); }
.import-report.is-error { color: var(--danger); }

footer.site-foot { border-top: 1px solid var(--line); padding: 14px; color: var(--muted); font-size: 0.76rem; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Lightbox: native <dialog>. */
dialog.lightbox {
  border: 1px solid var(--line); border-radius: var(--radius); background: #05070a; color: var(--text);
  max-width: 100vw; max-height: 100vh; width: 100%; height: 100%; padding: 0; margin: 0;
}
dialog.lightbox::backdrop { background: rgba(0, 0, 0, 0.85); }
.lightbox-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 8px 10px; border-bottom: 1px solid var(--line); background: #0d1117;
}
.lightbox-bar button { min-height: 44px; }
.lightbox-stage {
  overflow: auto; width: 100%; height: calc(100vh - 108px);
  display: flex; align-items: center; justify-content: center;
  background: repeating-conic-gradient(#141820 0% 25%, #0d1117 0% 50%) 50% / 24px 24px;
}
#lightbox-img {
  image-rendering: auto;
  transform-origin: center center;
  transition: transform 0.12s ease-out;
  cursor: zoom-in;
  max-width: 100%;
}
#lightbox-img.is-zoomed { cursor: zoom-out; }
#lightbox-caption { color: var(--muted); font-size: 0.74rem; padding: 6px 10px; word-break: break-all; }
.zoom-level { color: var(--accent-2); font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 60; max-width: min(94vw, 640px); padding: 10px 14px;
  background: #143a26; color: #d6ffe9; border: 1px solid #2f7a55; border-radius: 10px;
  font-size: 0.85rem; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.toast.is-error { background: #3a1414; color: #ffd9d9; border-color: #8a2c2c; }

@media (max-width: 560px) {
  .frame-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .group-head { top: 96px; }
  header.site-head { padding-bottom: 6px; }
}

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