/* ===================================================================
   共通部品（仕様書 2章）。角丸は 0。丸くするのはアバター・駒・点・バッジだけ。
   =================================================================== */

/* ───────── ボタン（4段階） ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 22px;
  border: 0; border-radius: 0;
  font-weight: 700; font-size: 15px; text-decoration: none; text-align: center;
  line-height: 1.3;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; }
.btn-lg { min-height: var(--btn-h); font-size: 16px; padding: 0 28px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--aqua); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4AB2DA; }
.btn-dark { background: var(--slate); color: #fff; }
.btn-dark:hover:not(:disabled) { background: var(--slate-divider); }
.btn-outline { background: var(--surface); color: var(--slate); box-shadow: inset 0 0 0 2px var(--slate); }
.btn-outline:hover:not(:disabled) { background: var(--bg); }
.btn-outline-light { background: transparent; color: #fff; box-shadow: inset 0 0 0 2px #fff; }
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.12); }
.btn-text {
  min-height: var(--tap); padding: 0 6px; background: none;
  color: var(--slate); text-decoration: underline; text-underline-offset: 3px; font-weight: 600;
}
.btn-danger-text { color: var(--red-text); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 0; }
.btn-pair { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }

/* ───────── セグメント切り替え ───────── */
.segmented {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  box-shadow: inset 0 0 0 1px var(--slate);
}
.segmented.block { display: grid; width: 100%; }
.segmented button, .segmented label {
  min-height: var(--tap); padding: 0 18px; border: 0; background: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--slate); cursor: pointer; font-size: 14px;
}
.segmented [aria-pressed="true"], .segmented [aria-checked="true"], .segmented input:checked + span {
  background: var(--slate); color: #fff;
}
.segmented label { padding: 0; }
.segmented label span { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 0 18px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:focus-visible + span { outline: 3px solid var(--aqua); outline-offset: -3px; }

/* ───────── タブ ───────── */
.tabs { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; min-height: var(--tap); padding: 0 18px; border: 0;
  background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.tab[aria-selected="true"], .tab[aria-pressed="true"] { background: var(--aqua); color: #fff; box-shadow: none; }
.tabs.underline { border-bottom: 1px solid var(--line); }
.tabs.underline .tab { background: none; box-shadow: inset 0 -3px 0 transparent; }
.tabs.underline .tab[aria-selected="true"] { color: var(--ink); background: none; box-shadow: inset 0 -3px 0 var(--aqua); }
.tabs.slate { background: var(--slate); }
.tabs.slate .tab { flex: 1 1 0; background: none; color: #DCE3EA; box-shadow: inset -1px 0 0 var(--slate-divider); }
.tabs.slate .tab[aria-selected="true"], .tabs.slate .tab[aria-pressed="true"] { background: var(--aqua); color: #fff; }

/* ───────── スイッチ ───────── */
.switch { position: relative; display: inline-block; width: 52px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line-input); transition: background 0.15s ease; }
.switch span::after {
  content: ''; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; background: #fff;
  transition: transform 0.15s ease;
}
.switch input:checked + span { background: var(--aqua); }
.switch input:checked + span::after { transform: translateX(24px); }
.switch input:focus-visible + span { outline: 3px solid var(--aqua); outline-offset: 2px; }

/* ───────── ステッパー ───────── */
.stepper { display: inline-grid; grid-template-columns: 44px minmax(64px, auto) 44px; height: 44px; box-shadow: inset 0 0 0 1px var(--line-input); }
.stepper button { border: 0; background: none; font-size: 18px; color: var(--slate); }
.stepper button:hover:not(:disabled) { background: var(--bg); }
.stepper button:disabled { opacity: 0.35; }
.stepper input, .stepper output {
  border: 0; border-left: 1px solid var(--line-input); border-right: 1px solid var(--line-input);
  text-align: center; font-weight: 700; color: var(--ink); width: 100%; min-width: 0;
  display: flex; align-items: center; justify-content: center; background: none;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ───────── スライダー ───────── */
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: none; margin: 0; }
.slider::-webkit-slider-runnable-track { height: 6px; background: linear-gradient(to right, var(--aqua) var(--fill, 50%), var(--aqua-track) var(--fill, 50%)); }
.slider::-moz-range-track { height: 6px; background: var(--aqua-track); }
.slider::-moz-range-progress { height: 6px; background: var(--aqua); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -11px; border-radius: 50%;
  background: #fff; box-shadow: inset 0 0 0 3px var(--slate), 0 1px 4px rgba(47, 58, 70, 0.25);
}
.slider::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--slate); background: #fff; box-sizing: border-box;
}

/* ───────── 入力欄 ───────── */
.field { display: grid; gap: 6px; }
.field-label { font-weight: 700; color: var(--ink); font-size: 14px; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 8px 12px;
  border: 1px solid var(--line-input); border-radius: 0; background: var(--surface);
}
.input::placeholder, .textarea::placeholder { color: var(--text-placeholder); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--aqua); outline-offset: -1px; border-color: var(--aqua); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.form-error { color: var(--red-text); font-size: 14px; min-height: 1.5em; }

/* ───────── カード・スレートの帯 ───────── */
.card { background: var(--surface); box-shadow: var(--shadow-card); min-width: 0; }
.card-body { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line-light);
}
.card-head h2, .card-head h3 { font-size: 16px; }
.card-head.slate { background: var(--slate); border-bottom: 0; color: #fff; min-height: 48px; padding: 10px 20px; }
.card-head.slate h2, .card-head.slate h3 { color: #fff; }
.card-head.aqua { background: var(--aqua); border-bottom: 0; color: #fff; }
.card-head.aqua h2, .card-head.aqua h3 { color: #fff; }
@media (max-width: 767px) {
  .card-body { padding: 16px; }
  .card-head { padding: 12px 16px; }
  .card-head h2, .card-head h3 { font-size: 15px; }
}

.slate-band {
  display: flex; align-items: stretch; min-height: 48px;
  background: var(--slate); color: #fff;
}
.slate-band > * { flex: 1 1 0; display: flex; align-items: center; justify-content: center; }
.slate-band > * + * { box-shadow: inset 1px 0 0 var(--slate-divider); }
.slate-band button {
  border: 0; background: none; color: #fff; min-height: 48px; min-width: var(--tap);
}
.slate-band button:hover:not(:disabled) { background: var(--slate-divider); }
.slate-band button:disabled { opacity: 0.35; }

/* ───────── 案内メッセージ ───────── */
.notice {
  background: var(--aqua-pale); box-shadow: inset 4px 0 0 var(--aqua);
  padding: 10px 14px 10px 18px; color: var(--ink); font-size: 14px; line-height: 1.6;
  min-height: 44px; display: flex; align-items: center;
}
.notice:empty::before { content: '\00a0'; }
.notice.error { background: #FDECEF; box-shadow: inset 4px 0 0 var(--red-text); }
.page-error { margin-bottom: var(--gap); }

/* ───────── 札・バッジ ───────── */
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  font-size: 11.5px; font-weight: 700; background: var(--line-light); color: var(--text); white-space: nowrap;
}
.tag.aqua { background: var(--aqua); color: #fff; }
.tag.slate { background: var(--slate); color: #fff; }
.tag.outline { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--aqua); color: var(--aqua-text); }

.result-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 56px; height: 26px; padding: 0 10px; font-size: 12px; font-weight: 700;
}
.result-badge.win { background: var(--aqua); color: #fff; }
.result-badge.loss { background: var(--slate); color: #fff; }
.result-badge.draw { background: var(--line-light); color: var(--text); }
.result-badge.live { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--aqua); color: var(--aqua-text); }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ───────── ダイアログ ───────── */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(47, 58, 70, 0.45);
  display: flex; align-items: center; justify-content: center; padding: var(--gutter);
}
.dialog { width: 100%; max-width: 440px; background: var(--surface); box-shadow: var(--shadow-pop); }
.dialog-head { background: var(--aqua); color: #fff; padding: 14px 20px; }
.dialog-head.slate { background: var(--slate); }
.dialog-head h2 { color: #fff; font-size: 17px; }
.dialog-body { padding: 20px; display: grid; gap: 10px; color: var(--text); }
.dialog-body strong { color: var(--ink); }
.dialog-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; padding: 0 20px 20px; }
.dialog-actions.stacked { grid-auto-flow: row; }

/* 局面・棋譜の書き出し／読み込み（ui/exchangeDialog.js） */
.dialog:has(.exchange-body) { max-width: 560px; }
.exchange-body { display: grid; gap: 14px; }
.exchange-section { display: grid; gap: 6px; }
.exchange-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.exchange-head h3 { font-size: 14px; color: var(--ink); }
.exchange-text {
  min-height: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.5;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.exchange-body code { font-size: 12px; overflow-wrap: anywhere; }
.exchange-body .notice.error { margin: 0; }

/* ───────── リスト ───────── */
.list { list-style: none; }
.list > li { border-bottom: 1px solid var(--line-light); }
.list > li:last-child { border-bottom: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; min-height: 56px; }
.list-row .grow { flex: 1 1 auto; min-width: 0; }
a.list-row { color: inherit; text-decoration: none; }
a.list-row:hover { background: var(--bg); }

.empty { padding: 20px; color: var(--text-sub); text-align: center; }

/* ───────── コピー欄 ───────── */
.copy-field { display: flex; align-items: stretch; min-height: var(--tap); box-shadow: inset 0 0 0 1px var(--line-input); }
.copy-field code {
  flex: 1 1 auto; min-width: 0; padding: 10px 12px; font-size: 13px; color: var(--ink);
  overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.5;
}
.copy-field button { flex: none; width: var(--tap); border: 0; background: var(--slate); color: #fff; display: flex; align-items: center; justify-content: center; }
.copy-field button:hover { background: var(--slate-divider); }
.toast-line { min-height: 1.5em; font-size: 13px; color: var(--aqua-text); font-weight: 600; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block { padding: 64px 16px; text-align: center; color: var(--text-sub); }

/* ───────── 動かす枚数の吹き出し ───────── */
.count-pop {
  position: absolute; z-index: 120; min-width: 160px;
  background: var(--surface); box-shadow: var(--shadow-pop);
}
.count-pop-head { background: var(--slate); color: #fff; font-size: 13px; font-weight: 700; padding: 8px 14px; }
.count-pop-body { display: flex; gap: 6px; padding: 10px; }
.count-pop-body button {
  width: var(--tap); height: var(--tap); border: 0; background: var(--bg);
  font-weight: 700; font-size: 17px; color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-input);
}
.count-pop-body button:hover, .count-pop-body button:focus-visible, .count-pop-body button.is-default {
  background: var(--aqua); color: #fff; box-shadow: none;
}
.count-pop::after {
  content: ''; position: absolute; left: calc(var(--tail-x, 50%) - 8px);
  border: 8px solid transparent;
}
.count-pop[data-side="above"]::after { top: 100%; border-top-color: var(--surface); }
.count-pop[data-side="below"]::after { bottom: 100%; border-bottom-color: var(--slate); }
.count-pop[data-side="none"] { position: fixed; }
.btn-pair > .btn { padding-left: 12px; padding-right: 12px; white-space: nowrap; }
.tag:empty { display: none; }
.result-badge { white-space: nowrap; }

/* ───────── 見出しの上のアクアの線 ───────── */
.accent-title::before {
  content: ''; display: block; width: 46px; height: 4px; background: var(--aqua); margin-bottom: 14px;
}

/* ───────── 色の付いたアイコンの帯（入口の一覧） ───────── */
.tone-aqua { background: var(--aqua); color: #fff; }
.tone-slate { background: var(--slate); color: #fff; }
.tone-soft { background: var(--aqua-soft); color: #fff; }
.tone-softer { background: var(--aqua-softer); color: #fff; }
.tile-list { list-style: none; }
.tile-list > li + li { border-top: 2px solid var(--line-light); }
.tile-row {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: stretch;
  min-height: 96px; color: inherit; text-decoration: none; background: var(--surface);
}
.tile-row:hover { background: var(--bg); }
.tile-icon { display: flex; align-items: center; justify-content: center; }
.tile-icon svg { width: 28px; height: 28px; }
.tile-text { display: grid; align-content: center; gap: 4px; padding: 14px 20px; line-height: 1.4; }
.tile-text strong { color: var(--ink); font-size: 17px; }
.tile-text span { color: var(--text-sub); font-size: 14px; }
.tile-chevron { display: flex; align-items: center; padding-right: 20px; color: var(--text-sub); }
@media (max-width: 767px) {
  .tile-row { grid-template-columns: 84px minmax(0, 1fr) auto; min-height: 84px; }
  .tile-text { padding: 12px 16px; }
  .tile-text strong { font-size: 16px; }
  .tile-text span { font-size: 13px; }
  .tile-chevron { padding-right: 14px; }
}
