:root {
  color-scheme: light;
  --bg:        #f7f5f0;
  --plane:     #f0ede5;
  --surface:   #ffffff;
  --surface-2: #faf8f3;
  --ink:       #1c1b17;
  --ink-2:     #58554b;
  --ink-3:     #8d8a7c;
  --line:      #e5e1d5;
  --line-2:    #d8d3c3;
  --weight:    #2a5f9e;
  --weight-fill: rgba(42,95,158,0.10);
  --fat:       #c65a1e;
  --fat-fill:  rgba(198,90,30,0.10);
  --muscle:    #1c8f63;
  --muscle-fill: rgba(28,143,99,0.10);
  --warn:      #a83a2c;
  --warn-fill: rgba(168,58,44,0.08);
  --shadow: 0 1px 2px rgba(28,27,23,0.04), 0 6px 20px -8px rgba(28,27,23,0.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:        #121110;
    --plane:     #0c0b0a;
    --surface:   #1a1917;
    --surface-2: #201f1c;
    --ink:       #f3f1ea;
    --ink-2:     #c2beb0;
    --ink-3:     #8d8a7c;
    --line:      #2c2a25;
    --line-2:    #38352d;
    --weight:    #6fa3e8;
    --weight-fill: rgba(111,163,232,0.14);
    --fat:       #ef9257;
    --fat-fill:  rgba(239,146,87,0.14);
    --muscle:    #4bc394;
    --muscle-fill: rgba(75,195,148,0.14);
    --warn:      #e2867a;
    --warn-fill: rgba(226,134,122,0.14);
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 10px 30px -10px rgba(0,0,0,0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #121110;
  --plane:     #0c0b0a;
  --surface:   #1a1917;
  --surface-2: #201f1c;
  --ink:       #f3f1ea;
  --ink-2:     #c2beb0;
  --ink-3:     #8d8a7c;
  --line:      #2c2a25;
  --line-2:    #38352d;
  --weight:    #6fa3e8;
  --weight-fill: rgba(111,163,232,0.14);
  --fat:       #ef9257;
  --fat-fill:  rgba(239,146,87,0.14);
  --muscle:    #4bc394;
  --muscle-fill: rgba(75,195,148,0.14);
  --warn:      #e2867a;
  --warn-fill: rgba(226,134,122,0.14);
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 10px 30px -10px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--ink-3);
  text-transform: uppercase;
}
h1 {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: clamp(28px, 4.2vw, 38px);
  margin: 6px 0 4px;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
.subtitle {
  color: var(--ink-2);
  font-size: 14.5px;
  margin: 0 0 32px;
}
.tabular { font-variant-numeric: tabular-nums; }

/* nav */
.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.nav a {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  text-decoration: none;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.nav a:hover { color: var(--ink); }
.nav a.active { background: var(--weight-fill); color: var(--weight); border-color: var(--weight); }
.nav .nav-user {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
}
.nav .nav-logout {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.nav .nav-logout:hover { color: var(--ink); border-color: var(--ink-3); }

/* stat tiles */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}
.goals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 36px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.tile-label {
  font-size: 12.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tile-value {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 27px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tile-unit { font-size: 14px; color: var(--ink-2); font-weight: 400; margin-left: 2px; }
.tile-delta {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.goal-tile .bar-track {
  margin-top: 12px;
  height: 6px;
  border-radius: 3px;
  background: var(--line-2);
  position: relative;
  overflow: hidden;
}
.goal-tile .bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--weight);
  border-radius: 3px;
}
.goal-tile .bar-caption {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
}

/* section headers */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 44px 0 14px;
}
.section-head h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}
.section-head .hint {
  font-size: 12px;
  color: var(--ink-3);
}

/* charts */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px 10px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  position: relative;
}
.chart-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 2px;
}
.chart-range {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 6px;
}
/* 実測／移動平均の凡例。線の見た目をそのまま小さく再現する */
.chart-legend {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-3);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i {
  display: inline-block;
  width: 16px;
  height: 0;
  border-top-style: solid;
}
.chart-legend .lg-raw i { border-top-width: 1.5px; opacity: 0.35; }
.chart-legend .lg-avg i { border-top-width: 2.5px; }
.chart-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 700 / 168;
}
.chart-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; cursor: crosshair; }
.gridline { stroke: var(--line); stroke-width: 1; }
.tick-label { fill: var(--ink-3); font-size: 10.5px; font-variant-numeric: tabular-nums; }
/* 実測値の線。移動平均を重ねるので、こちらは細く薄くして背景に回す。 */
.series-line { fill: none; stroke-width: 1.5; stroke-opacity: 0.35; }
/* 移動平均の線（傾向）。こちらを主役にする。 */
.series-avg { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.series-area { stroke: none; }
.end-point { stroke: var(--surface); stroke-width: 2; }
/* 最新値のラベル。折れ線や目盛りの上に重なることがあるので、
   背景色で縁取りして下の線を抜く（paint-order で塗りより先に縁を描く）。 */
.end-label {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 14px;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3.5px;
  stroke-linejoin: round;
}
.end-label-unit { font-size: 10px; font-weight: 400; }
.crosshair-line { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0; }
.hover-dot { opacity: 0; stroke: var(--surface); stroke-width: 2; }
/* 目標帯・目標線の注記。色はグラフごとに fill 属性で指定するため、
   ここでは fill を指定しない（CSSはpresentation attributeより強く、
   ここで色を決めるとグラフ側の指定が効かなくなる）。 */
.target-note {
  font-size: 11px;
  opacity: 0.85;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  line-height: 1.5;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity .08s ease;
  z-index: 5;
  font-variant-numeric: tabular-nums;
}
.tooltip .t-date { color: var(--ink-3); font-size: 10.5px; display: block; }

/* table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
/* 一覧の高さ。固定380pxだと画面が広くても8行程度しか見えないため、
   ビューポート追随にして表示行数を増やす（上限は付ける）。 */
.table-scroll {
  max-height: min(62vh, 640px);
  overflow-y: auto;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 480px;
}
.meal-table { min-width: 0; }
thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: right;
  font-weight: 700;
  color: var(--ink-2);
  padding: 9px 16px;
  font-size: 11.5px;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
thead th:first-child, td:first-child { text-align: left; }
tbody td {
  text-align: right;
  padding: 7px 16px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--surface-2); }
tbody tr.is-latest td { font-weight: 700; }
.wk-sun { color: var(--fat); }
.wk-sat { color: var(--weight); }

footer {
  margin-top: 28px;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.7;
}

/* nutrition */
.macro-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.macro-grid .tile-value { font-size: 24px; }
.macro-note { font-size: 12px; color: var(--ink-2); margin: 2px 0 0; }
.day-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  margin: 4px 0 18px;
  background: var(--surface);
}
.day-toggle button {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
}
.day-toggle button.active { background: var(--ink); color: var(--bg); }
.day-toggle button:focus-visible { outline: 2px solid var(--weight); outline-offset: 2px; }

.equip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 20px;
}
.chk-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.chk-pill input { width: 14px; height: 14px; accent-color: var(--weight); flex: none; }
.chk-pill:has(input:checked) { color: var(--ink); font-weight: 700; border-color: var(--weight); background: var(--weight-fill); }
.chk-pill.strong:has(input:checked) { color: var(--warn); border-color: var(--warn); background: var(--warn-fill); }
.chk-pill.is-disabled { opacity: .45; }
.chk-pill input:disabled { cursor: not-allowed; }

.day-config-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin: 4px 0 20px;
}
.day-config-grid .cell {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 8px;
  box-shadow: var(--shadow);
}
.day-config-grid .dow {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  text-align: center;
  margin-bottom: 1px;
}
.day-config-grid .chk {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
}
.day-config-grid .chk input {
  width: 13px;
  height: 13px;
  accent-color: var(--weight);
  flex: none;
}
.day-config-grid .chk:has(input:checked) { color: var(--ink); font-weight: 700; }
.day-config-grid .chk-rest { color: var(--warn); border-top: 1px solid var(--line); padding-top: 6px; margin-top: 1px; }
.day-config-grid .chk-rest input { accent-color: var(--warn); }
.day-config-grid .chk-rest:has(input:checked) { color: var(--warn); font-weight: 700; }

.alert-banner {
  border: 1px solid var(--warn);
  border-left: 4px solid var(--warn);
  background: var(--warn-fill);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 4px 0 20px;
}
.alert-banner .alert-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--warn);
  letter-spacing: .02em;
  margin-bottom: 6px;
}
.alert-banner ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.7;
}
.alert-banner ul li::marker { color: var(--warn); }

.order-note {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: .01em;
  margin-top: -4px;
}
.day-card .block { display: flex; flex-direction: column; gap: 8px; }
.day-card .block-divider { height: 1px; background: var(--line); margin: 1px 0; }
.day-card.suggest-rest { border-style: dashed; border-color: var(--warn); }
.tag-suggest { background: var(--warn-fill); color: var(--warn); align-self: flex-start; }
.rest-btn {
  margin-top: 2px;
  align-self: flex-start;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--warn);
  background: var(--warn-fill);
  border: 1px solid var(--warn);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
}
.rest-btn:hover { opacity: .82; }
.rest-btn.undo {
  color: var(--ink-2);
  background: var(--surface-2);
  border-color: var(--line);
}
.forced-note {
  font-size: 10px;
  font-weight: 700;
  color: var(--warn);
}

.today-wrap { margin-bottom: 8px; }
.today-card {
  max-width: 380px;
  padding: 22px 22px 20px;
}
.today-card .today-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--weight);
  text-transform: uppercase;
}
.today-card .dow { font-size: 13.5px; margin-top: 2px; }
.today-card .focus { font-size: 21px; }

.meal-table td:first-child, .meal-table th:first-child { text-align: left; white-space: nowrap; }
.meal-table td.food { text-align: left; white-space: normal; color: var(--ink-2); font-variant-numeric: normal; }
/* 説明用の表（トレーニング方針など）は全列を左揃えにする */
.help-table td, .help-table th { text-align: left; white-space: normal; }

/* weekly training */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.day-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 13px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100%;
}
.day-card .dow { font-size: 11.5px; color: var(--ink-3); font-weight: 700; }
.day-card .focus { font-family: "Fraunces", serif; font-weight: 600; font-size: 16px; text-wrap: balance; }
.tag {
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: .02em;
}
.tag-strength { background: var(--weight-fill); color: var(--weight); }
.tag-dance    { background: var(--muscle-fill); color: var(--muscle); }
.tag-cardio   { background: var(--fat-fill); color: var(--fat); }
.tag-rest     { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line); }
.day-card ul { margin: 0; padding-left: 16px; font-size: 12px; color: var(--ink-2); line-height: 1.65; }
.day-card ul li::marker { color: var(--ink-3); }
.day-card .placeholder-note { font-size: 10.5px; color: var(--ink-3); font-style: italic; }

/* forms (settings page) */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}
.field input,
.field select {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.field input:focus-visible,
.field select:focus-visible { outline: 2px solid var(--weight); outline-offset: 1px; }
.field .field-note { font-size: 11px; color: var(--ink-3); }
.field-full { grid-column: 1 / -1; }

/* buttons */
.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}
.btn-primary { background: var(--weight); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.btn-secondary:hover { color: var(--ink); }
.btn-sm { font-size: 12px; padding: 5px 11px; }

/* 説明を開閉する「?」ボタン */
.help-toggle {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
  flex: none;
}
.help-toggle:hover { color: var(--ink); border-color: var(--ink-2); }
.help-toggle.is-open { background: var(--weight); border-color: var(--weight); color: #fff; }

/* import page */
.upload-box {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 26px;
  text-align: center;
  background: var(--surface);
  margin-bottom: 12px;
}
.upload-box p { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-2); }
.upload-box input[type=file] { font-size: 13px; }
.upload-status {
  font-size: 12.5px;
  color: var(--ink-2);
  min-height: 1.4em;
  margin: 0 0 24px;
}
.review-table td { padding: 6px 8px; }
.review-table input {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}
.qr-raw {
  width: 100%;
  min-height: 80px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  box-sizing: border-box;
}

@media (max-width: 620px) {
  .form-grid { grid-template-columns: 1fr; }
  .page { padding: 20px 16px 48px; }
  .stats { grid-template-columns: 1fr; }
  .goals { grid-template-columns: 1fr; }
  .macro-grid { grid-template-columns: 1fr 1fr; }
  .week-grid { grid-template-columns: 1fr; }
  .day-config-grid { grid-template-columns: repeat(4, 1fr); }

  /* 見出しと補足テキストが1行に収まらず文字単位で折り返すのを防ぐ */
  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  /* 横スクロールできるテーブルであることを示すフェード */
  .table-wrap::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 18px;
    background: linear-gradient(to right, transparent, var(--surface));
    pointer-events: none;
  }
}
@media (max-width: 480px) {
  .day-config-grid { grid-template-columns: repeat(2, 1fr); }
  .day-config-grid .chk { font-size: 11.5px; gap: 7px; }
  .day-config-grid .chk input { width: 15px; height: 15px; }
}
@media (min-width: 621px) and (max-width: 860px) {
  .week-grid { grid-template-columns: repeat(4, 1fr); }
  .day-config-grid { grid-template-columns: repeat(4, 1fr); }
}

/* login */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.login-overlay[hidden] { display: none; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 26px;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 {
  font-size: 22px;
  margin: 2px 0 4px;
}
.login-card input {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
}
.login-card input:focus-visible { outline: 2px solid var(--weight); outline-offset: 1px; }
.login-card button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: var(--weight);
  color: #fff;
  cursor: pointer;
}
.login-card button:hover { opacity: .9; }
.login-error {
  color: var(--warn);
  font-size: 12.5px;
  margin: 0;
}

/* ---------------- 記録ページ ---------------- */

/* 表示期間の切り替え（セグメンテッドコントロール） */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 4px;
  margin-bottom: 18px;
}
.seg button {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--weight); color: #fff; }
.seg button:focus-visible { outline: 2px solid var(--weight); outline-offset: 1px; }

/* タイルの2行目（通算の増減など、主役ではない補足） */
.tile-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
/* タイル下部の「目標まで あと◯」。増減（直近の動き）とは別の情報なので
   区切り線で分ける。 */
.tile-goal {
  font-size: 11.5px;
  color: var(--ink-2);
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed var(--line);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

/* 増減の色分け。目標に近づく向きなら緑、遠ざかるなら赤、変化なしは無彩色。
   目標が現在値とほぼ同じ（維持目標）のときも良し悪しを付けない。 */
.delta-good { color: var(--muscle); }
.delta-bad  { color: var(--warn); }
.delta-flat { color: var(--ink-3); }

/* 記録一覧の操作列 */
td.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn-sm { margin-left: 4px; }
.row-actions .btn-danger { background: var(--warn-fill); color: var(--warn); border: 1px solid var(--warn); }
tbody tr.is-editing { background: var(--weight-fill); }
tbody tr.is-editing td { border-bottom: none; }
.edit-input {
  font-family: inherit;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  width: 84px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.edit-input:focus-visible { outline: 2px solid var(--weight); outline-offset: 1px; }
.row-error { color: var(--warn); font-size: 11.5px; }

/* 詳細ボディデータの展開行 */
tbody tr.detail-row td { background: var(--surface-2); text-align: left; padding: 12px 16px; }
.detail-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 18px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}
.detail-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  border-bottom: 1px dotted var(--line);
  padding-bottom: 3px;
}
.detail-list li b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-row summary { font-size: 12px; color: var(--ink-2); cursor: pointer; }

/* 見出し右の補足＋操作ボタン */
.section-head-actions {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

/* 記録一覧から1日分を足すためのパネル */
.add-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 4px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.add-panel .form-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.add-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 14px;
}
.add-note { font-size: 11.5px; color: var(--ink-3); margin: 0; }

.empty-note {
  background: var(--surface);
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-2);
  font-size: 13.5px;
}

@media (max-width: 620px) {
  .add-panel .form-grid { grid-template-columns: 1fr 1fr; }
  .section-head-actions { flex-direction: column; align-items: flex-start; gap: 8px; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1; padding: 7px 8px; }
  .detail-list { grid-template-columns: 1fr 1fr; }
}

/* ---------------- AIコーチの所見カード ---------------- */

.coach-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink-3);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
/* コンディションの3段階。左の帯だけで色分けする（本文は読みやすさ優先で通常色） */
.coach-card.coach-good    { border-left-color: var(--muscle); }
.coach-card.coach-normal  { border-left-color: var(--weight); }
.coach-card.coach-caution { border-left-color: var(--warn); }

.coach-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.coach-badge { font-size: 13.5px; font-weight: 700; }
.coach-good .coach-badge    { color: var(--muscle); }
.coach-normal .coach-badge  { color: var(--weight); }
.coach-caution .coach-badge { color: var(--warn); }
.coach-meta { font-size: 11.5px; color: var(--ink-3); margin-right: auto; }

.coach-summary { font-size: 13.5px; line-height: 1.85; margin: 0 0 14px; }

.coach-sub {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: .04em;
  margin: 16px 0 7px;
}

.coach-signals {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: grid;
  gap: 6px;
}
.coach-signals li {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) minmax(90px, 0.9fr) 1.4fr;
  gap: 10px;
  align-items: baseline;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border-left: 3px solid var(--ink-3);
}
.coach-signals .tone-good { border-left-color: var(--muscle); }
.coach-signals .tone-bad  { border-left-color: var(--warn); }
.coach-signals .tone-flat { border-left-color: var(--line-2); }
.coach-signals .sig-label   { color: var(--ink-2); }
.coach-signals .sig-value   { font-variant-numeric: tabular-nums; }
.coach-signals .sig-reading { color: var(--ink-3); }

.coach-policy { font-size: 13.5px; line-height: 1.85; margin: 0; }

.coach-menu { display: grid; gap: 10px; }
.coach-block {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.coach-block-title { font-size: 12.5px; font-weight: 700; margin-bottom: 6px; }
.coach-block ul { margin: 0; padding-left: 1.15em; }
.coach-block li { font-size: 12.5px; line-height: 1.8; }
.coach-block li::marker { color: var(--ink-3); }
.coach-block-note { font-size: 11.5px; color: var(--ink-2); margin: 7px 0 0; }

.coach-cautions ul { margin: 0; padding-left: 1.15em; }
.coach-cautions li { font-size: 12.5px; line-height: 1.8; color: var(--ink-2); }
.coach-cautions li::marker { color: var(--warn); }

.coach-disclaimer {
  font-size: 11px;
  color: var(--ink-3);
  margin: 16px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

/* 未生成のときの案内 */
.coach-prompt {
  background: var(--surface);
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.coach-prompt p { margin: 0; font-size: 13px; color: var(--ink-2); flex: 1 1 240px; }
.coach-status { font-size: 12.5px; color: var(--ink-2); }
.coach-status.is-error { color: var(--warn); }

@media (max-width: 620px) {
  .coach-signals li { grid-template-columns: 1fr; gap: 2px; }
}

/* 記録一覧の詳細行に埋め込むAIコーチの所見 */
.detail-coach { margin-top: 12px; }
.detail-coach .coach-card { margin-bottom: 0; }

/* ---------------- 取り込みページ：プレビューとレビュー編集 ---------------- */

/* 選択した画像のサムネイル。どれが解析済みか・失敗したかを示す */
.shot-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.shot-preview {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.shot-preview img {
  display: block;
  width: 100%;
  height: 92px;
  object-fit: cover;
  background: var(--surface-2);
}
.shot-preview figcaption {
  font-size: 10.5px;
  padding: 5px 7px;
  color: var(--ink-3);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.shot-preview .prev-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shot-preview.is-busy  { border-color: var(--weight); }
.shot-preview.is-done  { border-color: var(--muscle); }
.shot-preview.is-error { border-color: var(--warn); }
.shot-preview.is-done .prev-state  { color: var(--muscle); }
.shot-preview.is-error .prev-state { color: var(--warn); }

/* レビュー画面の詳細項目・機種固有データの編集フォーム */
.review-detail td, .review-table details { text-align: left; }
.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px 12px;
  margin-top: 10px;
}
.mini-field { display: flex; flex-direction: column; gap: 3px; }
.mini-field span { font-size: 11px; color: var(--ink-2); }
.mini-field input {
  font-family: inherit;
  font-size: 12.5px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}
.mini-field input:focus-visible { outline: 2px solid var(--weight); outline-offset: 1px; }
.review-table summary { font-size: 12px; color: var(--ink-2); cursor: pointer; padding: 4px 0; }

/* QRのリアルタイムスキャン */
.qr-scanner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.qr-stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}
.qr-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* 中央の枠。ここに合わせてもらうと中央の等倍走査に当たりやすい */
.qr-reticle {
  position: absolute;
  inset: 20%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.28);
  pointer-events: none;
}
