/* Yuki Golf LAB — 計測機器風ダークスタイル（spec.md 13章） */

[hidden] {
  display: none !important;
}

:root {
  --bg: #0a0b0d;
  --surface: #14161a;
  --surface-2: #1c1f25;
  --line: #2a2e36;
  --text: #f3f5f8;
  --muted: #8a919e;
  --dim: #5b6270;
  --accent: #ff6b1a;
  --accent-soft: rgba(255, 107, 26, 0.14);
  --good: #34d17a;
  --good-soft: rgba(52, 209, 122, 0.13);
  --bad: #ff5a52;
  --bad-soft: rgba(255, 90, 82, 0.13);
  --left: #4da3ff;
  --right: #ffb020;
  --r: 14px;
  --r-sm: 10px;
  --num: -apple-system, "SF Pro Display", "Helvetica Neue", "Hiragino Sans", sans-serif;
  --jp: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--jp);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  position: relative;
}

.view[hidden] {
  display: none !important;
}

/* 数字用 tabular-nums */
.num {
  font-family: var(--num);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.unit {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-left: 2px;
}

/* ===== エラー・通知バナー（spec 13-3） ===== */
.error-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bad);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
  min-height: 44px;
}

.error-banner[hidden] {
  display: none !important;
}

.error-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  padding: 8px 12px;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
}

.lab-notice-banner {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 14px;
  margin: 10px 12px 0;
  border-radius: var(--r-sm);
  font-size: 13px;
  line-height: 1.4;
}

/* ===== 共通ヘッダー・バー ===== */
.top-header, .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  background: transparent;
  border-bottom: 1px solid var(--line);
}

.top-header .app-title, .bar .title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.header-back-btn, .link-btn, .bar .back {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
}

.header-back-btn:active, .link-btn:active {
  color: var(--text);
}

.bar .meta {
  color: var(--muted);
  font-size: 12px;
}

/* ===== カード ===== */
.card {
  background: var(--surface);
  border-radius: var(--r);
  margin: 10px 12px;
  padding: 14px;
  border: 1px solid var(--line);
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

.sub-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.4;
}

.field-group {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* 入力コントロール */
.input-control {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  outline: none;
  font-family: inherit;
}

.input-control:focus {
  border-color: var(--accent);
}

select.input-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238a919e' d='M1.4 0L6 4.6 10.6 0 12 1.4l-6 6-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ===== チップ（spec 13-3） ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.chip.good {
  background: var(--good-soft);
  color: var(--good);
}

.chip.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.chip.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.chip.dim {
  background: var(--surface-2);
  color: var(--muted);
}

/* ===== タイル（spec 13-3） ===== */
.tiles {
  display: grid;
  gap: 8px;
}

.tiles.c5 {
  grid-template-columns: repeat(5, 1fr);
}

.tiles.c3 {
  grid-template-columns: repeat(3, 1fr);
}

.tiles.c2 {
  grid-template-columns: repeat(2, 1fr);
}

.tile {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 8px 8px 7px;
  border: 1px solid transparent;
  min-height: 52px;
}

.tile .label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tile .val {
  font-family: var(--num);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.1;
  color: var(--text);
}

.tile .sub {
  font-size: 10px;
  color: var(--dim);
  margin-top: 2px;
}

.tile.hl {
  background: var(--accent);
  border-color: var(--accent);
}

.tile.hl .label, .tile.hl .sub, .tile.hl .unit {
  color: rgba(0, 0, 0, 0.65);
}

.tile.hl .val {
  color: #111;
}

/* ===== ボタン ===== */
.primary-btn, .secondary-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

.primary-btn {
  background: var(--accent);
  color: #111;
}

.primary-btn:active {
  opacity: 0.85;
}

.secondary-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary-btn:active {
  background: var(--line);
}

.primary-btn:disabled, .secondary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== 画面1: ラウンド開始（setup-view） ===== */
.setup-entry-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin: 10px 12px;
  cursor: pointer;
}

.setup-entry-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.setup-entry-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.setup-entry-arrow {
  color: var(--dim);
  font-size: 18px;
}

.new-course-panel {
  background: var(--surface-2);
  padding: 12px;
  border-radius: var(--r-sm);
  margin-bottom: 12px;
  border: 1px solid var(--line);
}

.course-holes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.course-hole-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.course-hole-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.course-hole-select {
  padding: 6px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text);
}

/* ===== 画面2: スコア入力（scoring-view） ===== */
.scoring-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100dvh;
  padding-bottom: 10px;
}

.scoring-header {
  padding: 4px 12px 0;
}

.scoring-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.course-info-text {
  font-size: 12px;
  color: var(--muted);
}

.hole-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 4px 4px 10px;
}

.hole-no-wrap {
  display: flex;
  flex-direction: column;
}

.hole-no {
  font-size: 56px;
  font-weight: 700;
  line-height: 0.9;
  color: var(--text);
}

.hole-no small {
  font-size: 18px;
  color: var(--muted);
  font-weight: 600;
  margin-left: 4px;
}

.par-seg {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.seg {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
}

.seg.on {
  background: var(--text);
  color: #111;
}

.score-total-wrap {
  text-align: right;
}

.score-total-wrap .val {
  font-size: 34px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

/* スコアカード帯（spec 13-4） */
.strip {
  background: var(--surface);
  border-radius: var(--r);
  padding: 10px 10px 8px;
  margin: 6px 0 10px;
  border: 1px solid var(--line);
}

.strip-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.strip-stats {
  font-size: 11px;
  color: var(--dim);
}

.strip-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  margin-top: 6px;
}

.sh {
  text-align: center;
  border-radius: 7px;
  padding: 6px 0 4px;
  background: var(--surface-2);
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.sh .h {
  font-size: 9px;
  color: var(--dim);
}

.sh .s {
  font-family: var(--num);
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
  color: var(--text);
}

.sh.under .s {
  color: var(--good);
}

.sh.even .s {
  color: var(--text);
}

.sh.bogey .s {
  color: var(--text);
}

.sh.double .s {
  color: var(--bad);
}

.sh.empty .s {
  color: var(--dim);
}

.sh.cur {
  outline: 2px solid var(--accent);
}

/* 親指ゾーン・入力ボタン（spec 13-3, 13-4） */
.thumb-zone {
  padding: 0 12px;
}

.input-block {
  margin-bottom: 8px;
}

.input-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 8px 4px 6px;
}

.input-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.clear-btn {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 6px;
  min-height: 36px;
}

.clear-btn:active {
  color: var(--text);
}

.keys {
  display: grid;
  gap: 6px;
}

.keys.k6 {
  grid-template-columns: repeat(6, 1fr);
}

.keys.k5 {
  grid-template-columns: repeat(5, 1fr);
}

.keys.k4 {
  grid-template-columns: repeat(4, 1fr);
}

.keys.k3 {
  grid-template-columns: repeat(3, 1fr);
}

.key {
  height: 48px;
  min-height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--num);
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}

.key:active {
  background: var(--line);
}

.key.on {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.key.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  font-size: 15px;
}

.split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.nav-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px 14px;
}

.nav-btn {
  height: 50px;
  min-height: 44px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  cursor: pointer;
}

.nav-btn.primary {
  background: var(--text);
  color: #111;
  border-color: var(--text);
}

/* ホール一覧選択モーダル / パネル */
.hole-jump-panel {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  background: var(--surface-2);
  padding: 10px;
  border-radius: var(--r-sm);
  margin: 6px 0;
  border: 1px solid var(--line);
}

.hole-jump-item,
.jump-hole-btn {
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
}

.hole-jump-item.is-current,
.jump-hole-btn.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.hole-jump-item.is-filled,
.jump-hole-btn.is-filled {
  border-color: var(--dim);
}

/* ===== 画面3: 履歴（history-view） ===== */
.phase-hero {
  padding: 16px;
  border-radius: var(--r);
  margin: 0 12px 10px;
  background: linear-gradient(160deg, #1f1610 0%, var(--surface) 55%);
  border: 1px solid rgba(255, 107, 26, 0.25);
}

.phase-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.phase-big {
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.phase-big span {
  color: var(--accent);
}

.phase-target {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 14px 0 4px;
}

.step {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}

.step.done {
  background: var(--good);
}

.step.now {
  background: var(--accent);
}

.steps-label {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  font-size: 10px;
  color: var(--dim);
}

.cond {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.cond:first-of-type {
  border-top: none;
}

.cond .name {
  font-size: 13px;
  color: var(--text);
}

.cond .goal {
  font-size: 11px;
  color: var(--dim);
}

.cond .v {
  font-size: 20px;
  font-weight: 600;
  text-align: right;
  color: var(--text);
}

.meter {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  margin-top: 6px;
  position: relative;
  overflow: hidden;
}

.meter i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 2px;
  background: var(--bad);
}

.meter i.ok {
  background: var(--good);
}

.trend {
  width: 100%;
  border-collapse: collapse;
}

.trend th {
  font-size: 10px;
  color: var(--dim);
  font-weight: 600;
  text-align: right;
  padding: 0 0 6px;
  letter-spacing: 0.06em;
}

.trend th:first-child {
  text-align: left;
}

.trend td {
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.trend td.n {
  text-align: right;
  font-family: var(--num);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.delta {
  font-size: 10px;
  margin-left: 4px;
}

.delta.better {
  color: var(--good);
}

.delta.worse {
  color: var(--bad);
}

.round-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
  min-height: 48px;
}

.round-item:first-of-type {
  border-top: none;
}

.round-item .date {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.round-item .date b {
  display: block;
  font-size: 17px;
  color: var(--text);
  font-family: var(--num);
}

.round-item .course {
  font-size: 13px;
  color: var(--text);
}

.round-item .stats {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.round-item .sc {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
}

.round-item .sc.tentative {
  font-size: 16px;
  color: var(--muted);
}

/* ===== 画面4: 計測ラボ（lab-view） ===== */
.lab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.seg-unit {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px;
  border: 1px solid var(--line);
}

.seg-unit button {
  background: transparent;
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  min-height: 36px;
}

.seg-unit button.on {
  background: var(--text);
  color: #111;
}

.club-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 12px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.club-tabs::-webkit-scrollbar {
  display: none;
}

.ctab {
  flex: 0 0 auto;
  padding: 8px 14px;
  min-height: 44px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--num);
  font-weight: 700;
  font-size: 14px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.ctab.on {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.carry-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 4px;
}

.carry-hero .val {
  font-size: 60px;
  font-weight: 600;
  line-height: 0.95;
  color: var(--text);
}

.carry-hero .val .unit {
  font-size: 18px;
}

.range {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

/* ばらつきの図（SVG） */
.dispersion-wrap {
  margin: 12px -4px 0;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 10px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dispersion-svg {
  width: 100%;
  max-width: 380px;
  height: 220px;
}

.dispersion-empty {
  padding: 40px 10px;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}

/* 目標カード（spec 13-6） */
.target-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  align-items: center;
}

.target-row:first-child {
  border-top: none;
}

.target-label-group .target-name {
  font-size: 13px;
  color: var(--text);
}

.target-label-group .target-goal-text {
  font-size: 11px;
  color: var(--dim);
  margin-top: 2px;
}

.target-val {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--num);
  color: var(--text);
  text-align: right;
}

.target-val.achieved {
  color: var(--good);
}

.band {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  position: relative;
  margin-top: 6px;
}

.band .goal-zone {
  position: absolute;
  top: -2px;
  bottom: -2px;
  background: var(--good-soft);
  border: 1px solid rgba(52, 209, 122, 0.5);
  border-radius: 3px;
}

.band .now-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
  transform: translateX(-2px);
}

/* 折りたたみ可能な取り込みエリア */
details.lab-import-collapsible {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin: 10px 12px;
  overflow: hidden;
}

details.lab-import-collapsible summary {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  min-height: 44px;
  display: flex;
  align-items: center;
}

details.lab-import-collapsible[open] summary {
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

/* 貼り付け確認カード */
.confirm-summary-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.confirm-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.confirm-label {
  color: var(--muted);
  font-size: 12px;
}

.confirm-val {
  color: var(--text);
  text-align: right;
  white-space: pre-line;
}

.confirm-warning-text {
  color: var(--bad);
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

/* バックアップ・データ管理（spec 14-4） */
.backup-status-text {
  font-size: 13px;
  color: var(--muted);
}

.backup-status-text.warning {
  color: var(--bad);
  font-weight: 700;
}

/* Claude 用書き出し範囲セグメント（spec 14-3） */
.seg-group {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 2px;
  border: 1px solid var(--line);
}

.seg-group .seg-btn {
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: calc(var(--r-sm) - 2px);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.seg-group .seg-btn.on {
  background: var(--accent);
  color: #111;
  font-weight: 700;
}

