/* ======================================================================
   ez_table / base.css — デザイントークン・共通レイアウト・共通コンポーネント
   ルールは docs/DESIGN.md。以降のツールもこのトークンだけを使う。
   ====================================================================== */

/* ---------- トークン（ライト。全色をここで定義し、ダークは同名を上書き） ---------- */
:root {
  color-scheme: light;

  --bg:        #eef1f7;   /* ページ背景（わずかに青みのある無彩色） */
  --surface:   #ffffff;   /* 面 */
  --surface-2: #f6f8fb;   /* 面の中の一段沈んだ領域（表ヘッダ・入力） */
  --line:      #d4dbe8;   /* 罫線 */
  --line-soft: #e6ebf3;   /* 淡い罫線（表の行間） */
  --text:      #141924;   /* 本文 */
  --muted:     #5b6479;   /* 補助文字 */

  --et:        #8a6412;   /* エオルゼア側＝金 */
  --et-soft:   #f5ecd6;   /* 金の淡い面 */
  --et-line:   #d9c48e;
  --rt:        #28539f;   /* 現実側＝青 */
  --rt-soft:   #e3eaf8;   /* 青の淡い面 */
  --rt-line:   #a9bde3;

  --ok:        #2e7d32;
  --warn:      #b36b00;
  --danger:    #b3261e;
  --danger-soft: #fbe9e7;

  --shadow:    0 1px 2px rgba(20, 25, 36, .06), 0 6px 20px rgba(20, 25, 36, .06);
  --focus:     0 0 0 3px rgba(40, 83, 159, .28);

  --font-head: "Zen Old Mincho", "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", YuMincho, "Noto Serif JP", serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", YuGothic, Meiryo, "Noto Sans JP", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --radius:    14px;
  --radius-sm: 8px;
  --gutter:    16px;
  --maxw:      1120px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:        #0d1017;
    --surface:   #151a24;
    --surface-2: #1b2130;
    --line:      #2a3345;
    --line-soft: #222a3a;
    --text:      #e6ebf4;
    --muted:     #96a1b6;
    --et:        #e8bd66;
    --et-soft:   #2a2312;
    --et-line:   #5c4a1e;
    --rt:        #8fb4ff;
    --rt-soft:   #16223a;
    --rt-line:   #2e4a80;
    --ok:        #7ee08a;
    --warn:      #ffc466;
    --danger:    #ff8a80;
    --danger-soft: #3a1c1a;
    --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --focus:     0 0 0 3px rgba(143, 180, 255, .35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0d1017;
  --surface:   #151a24;
  --surface-2: #1b2130;
  --line:      #2a3345;
  --line-soft: #222a3a;
  --text:      #e6ebf4;
  --muted:     #96a1b6;
  --et:        #e8bd66;
  --et-soft:   #2a2312;
  --et-line:   #5c4a1e;
  --rt:        #8fb4ff;
  --rt-soft:   #16223a;
  --rt-line:   #2e4a80;
  --ok:        #7ee08a;
  --warn:      #ffc466;
  --danger:    #ff8a80;
  --danger-soft: #3a1c1a;
  --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --focus:     0 0 0 3px rgba(143, 180, 255, .35);
}

/* ---------- リセット・基本 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 .5em;
  letter-spacing: .01em;
}
h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--rt); text-decoration-thickness: 1px; text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
code, kbd, .num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
small, .small { font-size: .85em; }
.muted { color: var(--muted); }
.et { color: var(--et); }
.rt { color: var(--rt); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

/* ---------- レイアウト ---------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
@media (min-width: 640px) { :root { --gutter: 24px; } }
main.container { flex: 1; padding-block: 20px 40px; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-between { justify-content: space-between; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }

/* ---------- 共通ヘッダ／フッタ ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.site-header .container {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  min-height: 56px; padding-block: 8px;
}
.brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .02em;
  color: var(--text);
  text-decoration: none;
}
.brand b { color: var(--et); font-weight: 700; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-inline-end: auto; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: .95rem; padding: 4px 2px; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--et); }
.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .85rem;
}
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding-block: 18px; }

/* ---------- パネル ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
@media (max-width: 480px) { .panel { padding: 14px 14px; } }
.panel-et { border-top: 3px solid var(--et); }
.panel-rt { border-top: 3px solid var(--rt); }
.panel-soft { background: var(--surface-2); box-shadow: none; }

/* ---------- eyebrow ---------- */
.eyebrow {
  display: block;
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
  font-family: var(--font-body);
}
.eyebrow.et { color: var(--et); }
.eyebrow.rt { color: var(--rt); }

/* ---------- ボタン ---------- */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: .92rem; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--et); border-color: var(--et); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #1a1408; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #1a1408; } }
.btn-primary:hover { filter: brightness(1.08); background: var(--et); border-color: var(--et); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { min-height: 30px; padding: 3px 10px; font-size: .85rem; }
.btn-icon { padding-inline: 8px; min-width: 36px; }

/* ---------- トグルスイッチ ---------- */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--line); border: 1px solid var(--line);
  position: relative; transition: background .15s;
  flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: transform .15s;
}
.switch input:checked + .track { background: var(--et); border-color: var(--et); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

/* ---------- 入力・セレクト ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.input, .select, select, input[type="text"], input[type="number"], input[type="time"] {
  appearance: none;
  font: inherit; font-size: .95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: 36px;
  padding: 4px 10px;
  max-width: 100%;
}
input[type="number"] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
select {
  padding-inline-end: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.input:focus, .select:focus, select:focus, input:focus { outline: none; box-shadow: var(--focus); border-color: var(--rt); }

/* ---------- 表 ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.tbl th, table.tbl td { padding: 6px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
table.tbl th { font-size: .78rem; color: var(--muted); font-weight: 600; background: var(--surface-2); letter-spacing: .04em; }
table.tbl td.num, table.tbl th.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- プログレスバー ---------- */
.bar { height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--et); border-radius: 999px; width: 0; }

/* ---------- タグ・バッジ ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.tag.et { color: var(--et); border-color: var(--et-line); background: var(--et-soft); }
.tag.rt { color: var(--rt); border-color: var(--rt-line); background: var(--rt-soft); }
.tag.ok { color: var(--ok); }
.tag.danger { color: var(--danger); background: var(--danger-soft); }

/* ---------- トースト ---------- */
.toasts {
  position: fixed; inset-inline: 0; bottom: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding-inline: var(--gutter);
  pointer-events: none; z-index: 1000;
}
.toast {
  pointer-events: auto;
  max-width: min(100%, 480px);
  background: var(--text); color: var(--bg);
  border-radius: 12px; padding: 10px 16px;
  box-shadow: var(--shadow);
  font-size: .92rem;
  animation: toast-in .2s ease-out;
}
.toast.et { background: var(--et); color: #fff; }
.toast.danger { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- カード（ツール一覧） ---------- */
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  color: inherit; text-decoration: none;
  transition: transform .12s, border-color .12s;
}
a.card:hover { transform: translateY(-2px); border-color: var(--et-line); }
.card h2 { font-size: 1.1rem; margin-bottom: 6px; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; }
.card.soon { opacity: .6; box-shadow: none; }
.card.soon h2 { color: var(--muted); }

/* ---------- テーマトグル ---------- */
.theme-toggle { font-size: 1rem; }

/* ---------- モーション配慮 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: 0s !important; }
}
