/* =========================================================
 * Harmony Talk — 結果・比較・経過の画面とグラフ
 * ========================================================= */

/* ---------- 結果画面の上部固定 ---------- */

.sticky-head {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-bottom: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line);
}

.sticky-head .topbar {
  border-bottom: 0;
}

.result-tabs {
  margin: 0 16px;
}

#sec-overview,
#sec-time,
#sec-numbers {
  scroll-margin-top: 124px;
}

.context-line {
  color: var(--text-soft);
  font-size: 13px;
}

.context-line .strong {
  color: var(--text);
}

/* ---------- 概要 ---------- */

.overview-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.score-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.score-cell + .score-cell {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.score-value span {
  font-size: 36px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.score-value small {
  margin-left: 4px;
  color: var(--text-soft);
  font-size: 13px;
}

.score-label {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 12px;
}

.compare-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.mini-label {
  color: var(--text-soft);
  font-size: 11.5px;
}

.mini-value {
  margin-top: 3px;
  font-size: 14px;
}

.mini-value.is-muted {
  color: var(--text-soft);
  font-size: 12.5px;
}

.today-trials {
  display: flex;
  gap: 6px;
  margin: 0 -2px;
  padding: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.today-trials::-webkit-scrollbar {
  display: none;
}

.trial-cell {
  display: flex;
  flex: 0 0 104px;
  flex-direction: column;
  gap: 1px;
  padding: 8px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.trial-cell.is-current {
  border-color: var(--primary);
  background: var(--surface);
  cursor: default;
}

.trial-cell-head {
  color: var(--text-soft);
  font-size: 11px;
}

.trial-cell.is-current .trial-cell-head {
  color: var(--primary);
  font-weight: 600;
}

.trial-cell-value {
  font-size: 15px;
  font-weight: 600;
}

.trial-cell-sub {
  color: var(--text-soft);
  font-size: 11px;
}

.today-caption {
  margin-top: 4px;
}

/* ---------- 主要指標タイル ---------- */

.tile-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.tile-label,
.tile-sub {
  color: var(--text-soft);
  font-size: 11px;
}

.tile-sub {
  line-height: 1.4;
}

.tile-value span {
  font-size: 22px;
  font-weight: 600;
}

.tile-value small {
  margin-left: 3px;
  color: var(--text-soft);
  font-size: 11px;
}

.tile-bar {
  position: relative;
  height: 6px;
  margin: 5px 0;
  border-radius: 3px;
  background: #e7ebee;
}

.tile-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.tile-tick {
  position: absolute;
  top: -4px;
  width: 1px;
  height: 14px;
  background: var(--text-soft);
}

.tile-spacer {
  height: 16px;
}

/* ---------- 時間変化 ---------- */

.chart-card {
  padding: 16px 0 12px;
}

.chart-card > .card-head {
  padding: 0 16px;
}

.chart {
  width: 100%;
  min-height: 40px;
}

.chart svg {
  display: block;
}

.chart-empty {
  display: block;
  padding: 20px 16px;
}

.readout {
  margin: 10px 12px 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.readout-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.readout-time {
  color: var(--accent-strong);
  font-size: 12.5px;
  font-weight: 600;
}

.readout-hint {
  color: var(--text-soft);
  font-size: 11px;
}

.readout-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.readout-grid span,
.readout-grid em {
  display: block;
  color: var(--text-soft);
  font-size: 10.5px;
  font-style: normal;
}

.readout-grid strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.time-charts {
  border-radius: 12px;
}

.time-charts:focus-visible {
  outline-offset: -2px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 2px;
}

.chart-head-first {
  padding-top: 0;
}

.chart-head h3 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
}

.chart-unit {
  color: var(--text-soft);
  font-size: 11px;
  text-align: right;
}

.chart-legend,
.chart-summary {
  margin: 2px 0 0;
  padding: 0 16px;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.6;
}

.chart-summary {
  margin-top: 6px;
  color: var(--text);
  font-size: 12.5px;
}

.card > .chart-summary {
  padding: 0;
}

.toggle {
  display: inline-flex;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.toggle button {
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 11.5px;
}

.toggle button[aria-pressed="true"] {
  background: var(--primary);
  color: #ffffff;
}

/* ---------- SVG グラフ ---------- */

.ht-chart {
  overflow: visible;
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
}

.ht-chart.is-scrubbable {
  cursor: crosshair;
  touch-action: pan-y;
}

.ht-chart text {
  fill: var(--text-soft);
  font-size: 11px;
}

.ht-chart .t-strong {
  fill: var(--text);
  font-weight: 600;
}

.ht-chart .t-ink {
  fill: var(--text);
}

.ht-chart .gutter-label,
.ht-chart .band-label,
.ht-chart .row-label {
  font-size: 10.5px;
}

.ht-chart .band-label {
  fill: var(--accent-strong);
}

.ht-chart .cov-label {
  fill: var(--text);
  font-size: 10px;
}

.ht-chart .grid { stroke: var(--grid); stroke-width: 1; }
.ht-chart .axis { stroke: var(--axis); stroke-width: 1; }
.ht-chart .zero { stroke: #7f8a93; stroke-width: 1; stroke-dasharray: 4 3; }
.ht-chart .sep { stroke: #f0f2f5; stroke-width: 1; }
.ht-chart .ref-line { stroke: #8a949d; stroke-width: 1; stroke-dasharray: 3 3; }
.ht-chart .boundary { stroke: var(--text-soft); stroke-width: 1; stroke-dasharray: 2 2; }
.ht-chart .short-sep { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.ht-chart .band { fill: var(--accent-soft); }
.ht-chart .nodata { fill: var(--nodata); }
.ht-chart .crosshair { stroke: var(--accent); stroke-width: 1.5; }
.ht-chart .avg-line { stroke: var(--primary); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.55; }
.ht-chart .temporal-tick { stroke: var(--primary); stroke-width: 1; }
.ht-chart .temporal-mark { fill: var(--primary); }

/* 系列（role）ごとの色。Reference は破線 */
.ht-chart .series { --c: var(--primary); }
.ht-chart .role-previous-1 { --c: var(--series-prev1); }
.ht-chart .role-previous-2 { --c: var(--series-prev2); }
.ht-chart .role-previous-3 { --c: var(--series-prev3); }
.ht-chart .role-reference { --c: var(--series-ref); }
.ht-chart .role-off { --c: #dfe5ea; }
.ht-chart .role-short { --c: var(--axis); }

.ht-chart .series .line {
  fill: none;
  stroke: var(--c);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ht-chart .role-subject .line { stroke-width: 2.2; }
.ht-chart .role-reference .line { stroke-dasharray: 5 3; }

.ht-chart .series .area {
  fill: var(--primary);
  opacity: 0.08;
}

.ht-chart .series .dot {
  fill: #ffffff;
  stroke: var(--c);
  stroke-width: 1.8;
}

.ht-chart .role-previous-1 .dot,
.ht-chart .role-previous-2 .dot,
.ht-chart .role-previous-3 .dot {
  fill: var(--c);
  stroke: none;
}

.ht-chart .series .dot.is-selected { fill: var(--c); }
.ht-chart .series .dot.is-low { stroke-dasharray: 2 1.5; }

.ht-chart .series .bar { fill: var(--c); opacity: 0.32; }
.ht-chart .series .bar.is-selected { opacity: 1; }

.ht-chart .series .cap {
  stroke: var(--c);
  stroke-width: 2.5;
  stroke-dasharray: 4 2;
}

.ht-chart .series .span-bar { fill: var(--c); }

.ht-chart .voiced { fill: var(--primary); }
.ht-chart .cov { fill: var(--accent); }

.ht-chart .nl-track { stroke: var(--line-strong); stroke-width: 4; stroke-linecap: round; }
.ht-chart .nl-bracket { stroke: var(--text-soft); stroke-width: 1; }
.ht-chart .nl-window { fill: var(--primary); opacity: 0.45; }
.ht-chart .nl-avg { fill: #ffffff; stroke: var(--primary); stroke-width: 1.6; }
.ht-chart .nl-temporal { fill: var(--primary); }

.ht-chart .tdot { fill: #ffffff; stroke: var(--primary); stroke-width: 1.8; }
.ht-chart .tdot.kind-temporal { fill: var(--primary); }
.ht-chart .tdot.is-current { stroke-width: 2.6; }
.ht-chart .tmark { stroke: var(--text-soft); stroke-width: 1.8; }
.ht-chart .median { stroke: var(--series-prev1); stroke-width: 2.5; }
.ht-chart .median-link { fill: none; stroke: var(--series-prev1); stroke-width: 1.5; stroke-dasharray: 4 3; }

.ht-chart .tbar { fill: var(--primary); opacity: 0.45; }
.ht-chart .tbar.kind-short { fill: var(--axis); opacity: 1; }
.ht-chart .tbar.is-current { opacity: 1; }

.ht-chart .rbar { fill: var(--primary); opacity: 0.35; }
.ht-chart .rbar.is-current { opacity: 1; }

/* ---------- 要約・数値 ---------- */

.kv-list {
  margin: 6px 0 0;
  font-size: 13px;
}

.kv-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.kv-list > div:last-child {
  border-bottom: 0;
}

.kv-list dt {
  flex: 0 0 auto;
  color: var(--text-soft);
}

.kv-list dd {
  margin: 0;
  text-align: right;
}

.numbers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.detail-card summary {
  min-height: 46px;
  padding: 13px 14px;
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.detail-card > .kv-list,
.detail-card > .prob-list,
.detail-card > .ref-grid {
  padding: 4px 14px 10px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th,
.data-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  padding-left: 14px;
  text-align: left;
}

.data-table th:last-child,
.data-table td:last-child {
  padding-right: 14px;
}

.data-table th {
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 500;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tfoot td {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--text-soft);
}

.data-table tfoot td.strong {
  color: var(--text);
}

.data-table tr.is-selected td {
  background: var(--accent-soft);
  font-weight: 600;
}

.data-table tr.is-strong td {
  font-weight: 600;
}

.row-tag {
  margin-left: 4px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 400;
}

.table-note {
  margin: 0;
  padding: 8px 14px 12px;
  color: var(--text-soft);
  font-size: 11.5px;
  line-height: 1.6;
}

.table-card {
  padding: 4px 0 0;
}

.prob-row {
  display: grid;
  grid-template-columns: 64px 1fr 52px;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 12.5px;
}

.prob-label {
  color: var(--text-soft);
}

.prob-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #e7ebee;
}

.prob-fill {
  height: 100%;
  background: var(--primary);
  opacity: 0.45;
}

.prob-row.is-argmax .prob-fill {
  opacity: 1;
}

.prob-row.is-argmax .prob-label,
.prob-row.is-argmax .prob-value {
  color: var(--text);
  font-weight: 600;
}

.prob-value {
  text-align: right;
}

.prob-list .table-note {
  padding: 6px 0 0;
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  text-align: center;
}

.ref-grid span,
.ref-grid strong {
  display: block;
}

.ref-grid span {
  color: var(--text-soft);
  font-size: 11px;
}

.ref-grid strong {
  margin-top: 4px;
  font-size: 17px;
  font-weight: 600;
}

.info-note {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text-soft);
}

.info-note svg {
  flex: 0 0 auto;
  margin-top: 1px;
}

.info-note p {
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
}

.info-note.plain {
  display: block;
  border-color: transparent;
  background: var(--surface-soft);
  font-size: 12px;
  line-height: 1.7;
}

/* ---------- 比較 ---------- */

.session-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.session-nav strong {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.trial-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12.5px;
}

.trial-chip.is-on {
  border-color: var(--primary);
  color: var(--text);
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 4px;
  border-radius: 2px;
  background: var(--c, #dfe5ea);
}

.swatch.role-subject { --c: var(--primary); }
.swatch.role-previous-1 { --c: var(--series-prev1); }
.swatch.role-previous-2 { --c: var(--series-prev2); }
.swatch.role-previous-3 { --c: var(--series-prev3); }
.swatch.role-off { --c: #dfe5ea; }

/* ---------- 対象者ホーム ---------- */

.session-section {
  margin-top: 4px;
}

.session-list {
  display: flex;
  flex-direction: column;
}

#home-f0-card .chart-summary {
  margin-top: 6px;
}
