/* おちてる.net — 「運行情報ボード」（2026-11-20 オーナー決定。Google Stitch の案を元に作り直し）
   駅の発車標・運行情報板がモチーフ。
   - ヘッダーと各ボードの見出し帯は、ライト・ダークとも紺（案内板の筐体）。ロゴと点灯部分は水色の LED
   - 見出しは「日本語＋英字の小見出し」（駅の案内表示の作法）。時刻・件数は等幅数字
   - カテゴリは路線色（[data-line="1"〜"8"]）で見分ける。路線色は状態の色（赤・緑・黄・灰）とは別
   - 状態は色・文字・アイコンの 3 つで示す。角は小さく（4px）、影は使わず線で区切る */

/* ロゴ専用。DotGothic16（SIL OFL、logo-font-OFL.txt）の「おちてる.net」7 文字分だけの部分セット */
@font-face {
  font-family: "Ochiteru Logo";
  src: url("logo-font.woff2") format("woff2");
  font-display: swap;
  unicode-range: U+2E, U+65, U+6E, U+74, U+304A, U+3061, U+3066, U+308B;
}

:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --row-alt: #f7f9fb;
  --text: #121a26;
  --muted: #556274;
  --border: #d4dbe4;
  --hair: #e4e9ef;
  --link: #1559c0;

  /* 案内板の筐体（ライト・ダーク共通で暗い） */
  --canopy: #0d1726;
  --canopy-2: #142138;
  --canopy-line: #24344d;
  --canopy-text: #e8f4ff;
  --canopy-muted: #9fb3c8;
  --led: #6fe3f2;
  --lamp: #2a3a52;
  --lamp-off: #3d4f69;

  /* 選択中のタブ */
  --switch-on: #0d1726;
  --switch-on-text: #6fe3f2;

  /* 状態の色 */
  --incident: #c92a2a;
  --incident-bg: #fff1f1;
  --incident-strong: #e03131;
  --ok: #2b8a3e;
  --ok-bg: #ebfbee;
  --unknown: #9a5b00;
  --unknown-bg: #fff4d6;
  --none: #5b6573;
  --none-bg: #eef0f3;

  /* 路線色（カテゴリ） */
  --line-1: #e8590c;
  --line-2: #1c7ed6;
  --line-3: #0c8599;
  --line-4: #7048e8;
  --line-5: #c2255c;
  --line-6: #5c940d;
  --line-7: #9c6644;
  --line-8: #3b5bdb;

  --radius: 4px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  --font-mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, "Roboto Mono", monospace;
  --font-logo: "Ochiteru Logo", "BIZ UDGothic", "MS Gothic", "Osaka-Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070c14;
    --surface: #101826;
    --row-alt: #131d2c;
    --text: #e3e9f1;
    --muted: #97a5b7;
    --border: #233046;
    --hair: #1b2737;
    --link: #84b8ff;
    --canopy: #0d1726;
    --canopy-2: #16233a;
    --canopy-line: #2a3b56;
    --switch-on: #6fe3f2;
    --switch-on-text: #07121c;
    --incident: #ff8787;
    --incident-bg: #2c1416;
    --incident-strong: #fa5252;
    --ok: #69db7c;
    --ok-bg: #12261a;
    --unknown: #ffd43b;
    --unknown-bg: #2e2610;
    --none: #a3acb9;
    --none-bg: #1f2733;
    --line-1: #ff922b;
    --line-2: #4dabf7;
    --line-3: #3bc9db;
    --line-4: #9775fa;
    --line-5: #f06595;
    --line-6: #94d82d;
    --line-7: #c49a7a;
    --line-8: #748ffc;
    color-scheme: dark;
  }
}
/* ボタンでダークを選んだとき（theme.js が <html data-theme="dark"> を付ける）。上と同じ値 */
:root[data-theme="dark"] {
  --bg: #070c14;
  --surface: #101826;
  --row-alt: #131d2c;
  --text: #e3e9f1;
  --muted: #97a5b7;
  --border: #233046;
  --hair: #1b2737;
  --link: #84b8ff;
  --canopy: #0d1726;
  --canopy-2: #16233a;
  --canopy-line: #2a3b56;
  --switch-on: #6fe3f2;
  --switch-on-text: #07121c;
  --incident: #ff8787;
  --incident-bg: #2c1416;
  --incident-strong: #fa5252;
  --ok: #69db7c;
  --ok-bg: #12261a;
  --unknown: #ffd43b;
  --unknown-bg: #2e2610;
  --none: #a3acb9;
  --none-bg: #1f2733;
  --line-1: #ff922b;
  --line-2: #4dabf7;
  --line-3: #3bc9db;
  --line-4: #9775fa;
  --line-5: #f06595;
  --line-6: #94d82d;
  --line-7: #c49a7a;
  --line-8: #748ffc;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
}

a { color: var(--link); }
a.external { position: relative; }  /* 中の読み上げ用テキストをリンク内に収める */
a.external::after { content: "↗"; display: inline-block; margin-left: 2px; font-size: .85em; text-decoration: none; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* 路線色: 要素に --line を持たせる */
[data-line="1"] { --line: var(--line-1); }
[data-line="2"] { --line: var(--line-2); }
[data-line="3"] { --line: var(--line-3); }
[data-line="4"] { --line: var(--line-4); }
[data-line="5"] { --line: var(--line-5); }
[data-line="6"] { --line: var(--line-6); }
[data-line="7"] { --line: var(--line-7); }
[data-line="8"] { --line: var(--line-8); }

/* 英字の小見出し（駅の案内表示の二か国語表記） */
.en, .en-tag, .list-head i {
  font-family: var(--font-mono); font-style: normal; font-weight: 600;
  font-size: .68rem; letter-spacing: .14em; text-transform: uppercase;
}

/* ---------------------------------------------------------------- ヘッダー（案内板の帯） */
.site-header {
  background: var(--canopy); color: var(--canopy-text);
  border-bottom: 2px solid #000;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
  padding: 14px 0;
}
.header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; }
.site-title { margin: 0; font-size: 1.85rem; line-height: 1.1; font-weight: 400; flex: 0 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--led); text-decoration: none; white-space: nowrap; }
.brand:focus-visible { outline: 3px solid var(--led); outline-offset: 4px; border-radius: 4px; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 auto; }
.lamp-frame { fill: var(--lamp); }
.lamp-off { fill: var(--lamp-off); }
.lamp-on { fill: var(--led); }
.brand-word { font-family: var(--font-logo); letter-spacing: .08em; text-shadow: 0 0 10px rgba(111, 227, 242, .35); }
.brand-tld { font-size: .62em; color: var(--canopy-muted); letter-spacing: .02em; margin-left: 1px; text-shadow: none; }

.header-lead { flex: 1 1 22em; min-width: 0; border-left: 1px solid var(--canopy-line); padding-left: 20px; }
.site-lead { margin: 0; font-size: .95rem; font-weight: 600; }
.site-sub { margin: 2px 0 0; color: var(--canopy-muted); font-size: .8rem; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
.en-tag { color: var(--led); border: 1px solid var(--canopy-line); padding: 0 6px; font-size: .62rem; }

.updated {
  margin: 0; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  background: var(--canopy-2); border: 1px solid var(--canopy-line); border-radius: var(--radius);
  padding: 6px 12px; font-size: .8rem; color: var(--canopy-muted); white-space: nowrap;
}
.updated time { color: var(--led); font-size: .95rem; font-weight: 600; }
.updated-interval { border-left: 1px solid var(--canopy-line); padding-left: 8px; }
.led { width: 8px; height: 8px; border-radius: 50%; background: #40c057; box-shadow: 0 0 6px #40c057; }

/* ライト／ダークの切り替え（案内板のスイッチ風） */
.theme-toggle {
  position: relative; /* 中の読み上げ用テキストをボタン内に収める */
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: .8rem; font-weight: 600; white-space: nowrap; cursor: pointer;
  color: var(--canopy-text); background: var(--canopy-2);
  border: 1px solid var(--canopy-line); border-radius: var(--radius); padding: 6px 12px;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { border-color: var(--led); color: var(--led); }
.theme-toggle:focus-visible { outline: 3px solid var(--led); outline-offset: 2px; }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }
.theme-toggle[data-next="dark"] .icon-sun, .theme-toggle[data-next="light"] .icon-moon { display: none; }

.main { display: flex; flex-direction: column; gap: 28px; padding-top: 24px; }

/* ---------------------------------------------------------------- ボード（紺の見出し帯＋本体） */
.board { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.board[hidden] { display: none; }
.board-bar {
  margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  background: var(--canopy); color: var(--canopy-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
  padding: 10px 16px; font-size: 1.05rem;
}
.board-bar .en { color: var(--canopy-muted); }
.board-bar .en::before { content: "/"; margin-right: 10px; color: var(--canopy-line); }
.lamp { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); flex: 0 0 auto; }
.bar-count {
  margin-left: auto; font-family: var(--font-mono); font-size: .8rem; font-weight: 700;
  background: var(--incident-strong); color: #fff; padding: 1px 10px; border-radius: 2px;
}
.bar-count::before { content: "発生中 "; font-family: var(--font); }
.board-body { padding: 16px; }

/* ---------------------------------------------------------------- 現在発生中 */
.now.has-incident { border-color: var(--incident-strong); }
.now.has-incident .lamp { background: var(--incident-strong); box-shadow: 0 0 8px var(--incident-strong); }
.now.has-incident .board-body { background: var(--incident-bg); }

.now-empty { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 700; color: var(--ok); }
.now-empty-icon {
  display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 2px;
  background: var(--ok-bg); border: 1px solid var(--ok); font-size: .9em;
}
.now-loading { margin: 0; color: var(--muted); }
.now-empty.is-stale { color: var(--unknown); }
.now-empty.is-stale .now-empty-icon { background: var(--unknown-bg); border-color: var(--unknown); }

/* 情報が古いときの警告（取得が止まっているかもしれない） */
.stale {
  margin: 0; display: flex; align-items: flex-start; gap: 10px;
  background: var(--unknown-bg); color: var(--text);
  border: 2px solid var(--unknown); border-radius: var(--radius); padding: 12px 16px; font-size: .9rem;
}
.stale[hidden] { display: none; }
.stale strong { color: var(--unknown); }
.stale-icon {
  flex: 0 0 auto; display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; margin-top: 1px;
  border-radius: 2px; background: var(--unknown); color: var(--surface); font-family: var(--font-mono); font-weight: 700;
}
/* ヘッダーの更新ランプも黄色にする */
.is-stale .led { background: #fab005; box-shadow: 0 0 6px #fab005; }
.is-stale .now:not(.has-incident) .lamp { background: var(--unknown); box-shadow: 0 0 6px var(--unknown); }

.now-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.now-list:has(.now-empty), .now-list:has(.now-loading) { display: block; }
.now-item {
  background: var(--surface); border: 2px solid var(--incident-strong); border-left-width: 8px;
  border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.now-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.now-service { margin: 0; font-size: 1.25rem; }
.now-item .incident-title { font-size: 1.02rem; font-weight: 600; }
.now-foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; font-size: .85rem; }
.now-foot .official-link {
  background: var(--switch-on); color: var(--switch-on-text); text-decoration: none; font-weight: 700;
  padding: 5px 12px; border-radius: 2px;
}
.now-foot .official-link:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

.now-scope:empty { display: none; }
.now-scope { margin: 12px 0 0; color: var(--muted); font-size: .82rem; }

/* カテゴリの札（路線色の四角つき） */
.chip, .card-cat {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; color: var(--muted); white-space: nowrap;
  border: 1px solid var(--border); border-radius: 2px; padding: 0 6px; background: var(--surface);
}
.chip[data-line]::before, .card-cat::before { content: ""; width: 6px; height: 6px; background: var(--line, var(--muted)); }

/* ---------------------------------------------------------------- 直近の復旧 */
.recovered-list { list-style: none; margin: 0; padding: 0; }
.recovered-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding: 9px 16px; border-top: 1px solid var(--hair); }
.recovered-item:first-child { border-top: 0; }
.recovered-item:nth-child(even) { background: var(--row-alt); }
.recovered-service { font-weight: 700; min-width: 9em; display: inline-flex; align-items: center; gap: 8px; }
.recovered-service::before { content: ""; width: 4px; height: 1.05em; background: var(--line, var(--muted)); }
.recovered-item .incidents { flex: 1 1 18em; }
.recovered-item .incident { border-top: 0; padding-top: 0; }

/* ---------------------------------------------------------------- サービス別の状況 */
.section-title { margin: 0 0 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; font-size: 1.25rem; }
.section-title .en { color: var(--muted); }
.section-title .en::before { content: "/"; margin-right: 10px; color: var(--border); }

/* カテゴリのタブ: 切り替えスイッチ風。数が増えても折り返して全部見える */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.tab {
  position: relative; /* 中の読み上げ用テキスト（visually-hidden）をタブ内に収める */
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font: inherit; font-size: .88rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 2px;
  padding: 5px 11px; cursor: pointer;
}
.tab[data-line]::before { content: ""; width: 8px; height: 8px; background: var(--line); flex: 0 0 auto; }
.tab:hover { border-color: var(--muted); }
.tab:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.tab[aria-selected="true"] { background: var(--switch-on); border-color: var(--switch-on); color: var(--switch-on-text); font-weight: 700; }
.tab-count { font-family: var(--font-mono); font-size: .75rem; padding: 0 5px; border-radius: 2px; background: var(--bg); color: var(--muted); }
.tab[aria-selected="true"] .tab-count { background: rgba(127, 140, 160, .25); color: inherit; }
.tab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--incident-strong); }

.panel:focus-visible { outline: 3px solid var(--link); outline-offset: 4px; border-radius: var(--radius); }

/* 一覧: 発車標のように 1 サービス 1 行。列は 状態 | サービス | 最新の発表 | 公式・取得時刻 */
.list-head, .card { grid-template-columns: 11em 13em minmax(0, 1fr) 10em; column-gap: 16px; }
.list-head {
  display: grid; align-items: center;
  background: var(--canopy); color: var(--canopy-text);
  border-radius: var(--radius) var(--radius) 0 0; padding: 9px 16px; font-size: .78rem; font-weight: 700;
}
.list-head span { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.list-head span:last-child { justify-content: flex-end; }
.list-head i { color: var(--canopy-muted); font-size: .6rem; }

.grid { border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--surface); overflow: hidden; }

.card { display: grid; align-items: start; padding: 11px 16px; border-top: 1px solid var(--hair); }
.card:first-child { border-top: 0; }
.card:nth-child(even) { background: var(--row-alt); }
.card.state-incident { background: var(--incident-bg); box-shadow: inset 4px 0 0 var(--incident-strong); }

.card-head { display: contents; }
.badge { grid-column: 1; grid-row: 1 / span 3; justify-self: start; }
.card-name { grid-column: 2; grid-row: 1 / span 3; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.card-title {
  margin: 0; min-width: 0; max-width: 100%;
  display: flex; align-items: center; gap: 8px; font-size: 1rem; overflow-wrap: anywhere;
}
.card-title::before { content: ""; flex: 0 0 auto; width: 4px; height: 1.15em; background: var(--line, var(--muted)); }
.card-cat { margin-left: 12px; }
.card-note, .card > .incidents, .history { grid-column: 3; min-width: 0; }
.card-foot {
  grid-column: 4; grid-row: 1 / span 3; display: flex; flex-direction: column; align-items: flex-end; gap: 0;
  font-size: .85rem; white-space: nowrap;
}
.card > .incidents + .history, .card-note + .incidents { margin-top: 4px; }

/* 状態の札: 角ばった表示器。アイコンは反転した四角 */
.state-incident { --st: var(--incident); --st-bg: var(--incident-bg); }
.state-ok { --st: var(--ok); --st-bg: var(--ok-bg); }
.state-unknown { --st: var(--unknown); --st-bg: var(--unknown-bg); }
.state-not_collected { --st: var(--none); --st-bg: var(--none-bg); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 700; white-space: nowrap;
  color: var(--st); background: var(--st-bg);
  padding: 2px 8px 2px 2px; border: 1px solid var(--st); border-radius: 2px;
}
.badge-icon {
  display: inline-grid; place-items: center; width: 1.45em; height: 1.45em; border-radius: 1px;
  background: var(--st); color: var(--surface); font-family: var(--font-mono);
}

.card-note { margin: 0; color: var(--muted); font-size: .85rem; }

.incidents { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.incident { font-size: .9rem; border-top: 1px dashed var(--border); padding-top: 6px; }
.card > .incidents > .incident:first-child, .now-item .incident:first-child { border-top: 0; padding-top: 0; }
.incident-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: .8rem; color: var(--muted); }
.incident-meta time { font-size: .95em; }
.incident-status { font-weight: 700; }
.incident-status.active { color: var(--incident); }
.incident-status.resolved { color: var(--ok); }
.incident-status.overseas { color: var(--muted); }
.ago { color: var(--incident); font-weight: 600; }
.incident-title { overflow-wrap: anywhere; }

.history summary { cursor: pointer; font-size: .85rem; color: var(--link); }
.history[open] summary { margin-bottom: 6px; }

.fetched { color: var(--muted); font-family: var(--font-mono); font-size: .78rem; }

/* スマホ: 1 行目にサービス名と状態、その下にカテゴリ・発表・公式リンク */
@media (max-width: 720px) {
  .header-inner { gap: 10px 16px; }
  .site-title { font-size: 1.55rem; }
  .brand-mark { width: 32px; height: 32px; }
  .header-lead { flex-basis: 100%; border-left: 0; padding-left: 0; }
  .updated { padding: 4px 10px; font-size: .75rem; order: 3; }
  /* 切り替えボタンはロゴと同じ行の右端に */
  .theme-toggle { order: 1; margin-left: auto; padding: 5px 10px; }
  .header-lead { order: 2; }
  .board-bar .en::before, .section-title .en::before { display: none; }
  .main { gap: 24px; padding-top: 16px; }
  .board-body { padding: 12px; }
  .now-list { grid-template-columns: 1fr; }

  .list-head { display: none; }
  .grid { border-top: 1px solid var(--border); border-radius: var(--radius); }
  .card { grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; padding: 12px; }
  .card-name { grid-column: 1; grid-row: 1; }
  .badge { grid-column: 2; grid-row: 1; }
  .card-note, .card > .incidents, .history { grid-column: 1 / -1; margin-top: 8px; }
  .card-foot { grid-column: 1 / -1; grid-row: auto; flex-direction: row; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin-top: 8px; white-space: normal; }
}
@media (max-width: 400px) {
  .badge { font-size: .72rem; }
}

/* ---------------------------------------------------------------- その他 */
.load-error { margin: 0; color: var(--incident); font-weight: 700; }

.notice { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; font-size: .88rem; }
.notice-title { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.notice-icon {
  display: inline-grid; place-items: center; width: 1.3em; height: 1.3em; border-radius: 2px;
  background: var(--unknown); color: var(--surface); font-family: var(--font-mono); font-size: .85em;
}
.notice p { margin: 0; color: var(--muted); }

.site-footer { margin-top: 40px; padding: 20px 0 32px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .82rem; }
.site-footer p { margin: 4px 0; }
.site-footer .copyright { margin-top: 12px; }
