/* =========================================================
   Wideweb — 気象図と相場表のように、情報を一目で読む
   ========================================================= */

:root {
  color-scheme: light;
  --paper: #edf1f4;
  --card: #ffffff;
  --card-2: #f5f8fa;
  --ink: #0e1b2c;
  --ink-2: #44546a;
  --ink-3: #6b7b91;
  --line: #d5dde6;
  --line-2: #e5ebf0;
  --accent: #0a7c86;
  --accent-soft: #d9eff1;
  --on-accent: #ffffff;
  --up: #d3312b;
  --down: #1f5fd1;
  --rail: #0e1b2c;
  --rail-ink: #e8eef5;
  --rail-dim: #8fa1b8;
  --rail-up: #ff7d75;
  --rail-down: #7fb0ff;
  --scrim: rgba(7, 14, 24, 0.82);
  --shadow: 0 1px 2px rgba(14, 27, 44, 0.06), 0 8px 24px -12px rgba(14, 27, 44, 0.18);

  --radius: 10px;
  --radius-sm: 6px;

  --font-head: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Noto Sans CJK JP", Meiryo, sans-serif;
  --font-body: "IBM Plex Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans CJK JP", Meiryo, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0a121e;
    --card: #121c2c;
    --card-2: #182438;
    --ink: #e8eef6;
    --ink-2: #a8b6c9;
    --ink-3: #7a8aa3;
    --line: #243249;
    --line-2: #1b2639;
    --accent: #4fc3cc;
    --accent-soft: #12333a;
    --on-accent: #06222a;
    --up: #ff7d75;
    --down: #7fb0ff;
    --rail: #060b13;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0a121e;
  --card: #121c2c;
  --card-2: #182438;
  --ink: #e8eef6;
  --ink-2: #a8b6c9;
  --ink-3: #7a8aa3;
  --line: #243249;
  --line-2: #1b2639;
  --accent: #4fc3cc;
  --accent-soft: #12333a;
  --on-accent: #06222a;
  --up: #ff7d75;
  --down: #7fb0ff;
  --rail: #060b13;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 120px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 400 15px/1.7 var(--font-body);
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 10px; }

.shell {
  width: min(1240px, calc(100% - 48px));
  margin-inline: auto;
}

#news, #weather, #fx, #services { scroll-margin-top: 120px; }

/* =========================
   為替速報の帯（自動で流れ続ける）
   ========================= */
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  font-size: 12.5px;
}

.rail-inner {
  display: flex;
  align-items: center;
  height: 40px;
}

.tape {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  /* 左右どちらの端も同じようにフェードさせる */
  mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent);
}

.tape-track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  width: max-content;
  animation: tapeScroll var(--tape-duration, 40s) linear infinite;
  will-change: transform;
}
.tape-track.is-static { animation: none; padding-left: 40px; }
.tape:hover .tape-track { animation-play-state: paused; }

@keyframes tapeScroll {
  to { transform: translateX(-50%); }
}

.tape-track li {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
  margin-right: 32px;
  white-space: nowrap;
}

.tape-placeholder { color: var(--rail-dim); }
.tape-pair { font-weight: 600; color: var(--rail-dim); letter-spacing: 0.02em; }
.tape-rate { font-weight: 600; color: #fff; }
.tape-chg { font-size: 11.5px; color: var(--rail-dim); }
.tape-chg.up { color: var(--rail-up); }
.tape-chg.down { color: var(--rail-down); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}
.btn-ghost { border-color: var(--line); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-solid { background: var(--accent); color: var(--on-accent); }
.btn-solid:hover { opacity: 0.88; }

.theme-toggle {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--ink-2); color: var(--ink); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }

:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* =========================
   ヘッダー
   ========================= */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.header-main {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-wordmark {
  font-family: var(--font-head);
  font-size: 25px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}



.header-sub { border-top: 1px solid var(--line-2); }

.category-bar {
  height: 48px;
  overflow-x: auto;
  scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }

.category-track {
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  height: 48px;
  will-change: transform;
}

/* マウス操作のPC：端へ寄せるとゆっくり周回する */
.category-bar.is-loop {
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 36px, #000 calc(100% - 36px), transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 36px, #000 calc(100% - 36px), transparent);
}

/* 動きを減らす設定のPC：折り返してすべて表示 */
.category-bar.is-wrap { height: auto; overflow: visible; }
.category-bar.is-wrap .category-track { flex-wrap: wrap; width: auto; height: auto; padding-block: 8px; }

.category-bar button {
  flex-shrink: 0;
  height: 30px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.category-bar button:hover { border-color: var(--line); color: var(--ink); }
.category-bar button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
  font-weight: 600;
}
.category-note { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* =========================
   レイアウト
   ========================= */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
  gap: 36px;
  padding-block: 32px 80px;
}
.main-column, .sidebar { min-width: 0; }

/* ニュース見出し */
.news-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.news-toolbar h1 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.news-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
  color: var(--ink-3);
  font-size: 12.5px;
}

.news-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.news-status.is-error .dot { background: var(--up); }

.feed-count { margin-left: 4px; padding-left: 12px; border-left: 1px solid var(--line); }
.feed-count:empty { display: none; }

.news-search {
  display: flex;
  align-items: center;
  width: 320px;
  flex-shrink: 0;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.search-input-wrap svg.search-icon {
  position: absolute;
  left: 12px;
  width: 14px;
  height: 14px;
  color: var(--ink-3);
  pointer-events: none;
}

.news-search input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 30px 0 34px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.news-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.news-search input::placeholder { color: var(--ink-3); }
.news-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.search-clear {
  position: absolute;
  right: 7px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--line-2);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1;
}
.search-clear:hover { background: var(--line); color: var(--ink); }

.news-section.section-highlight,
.panel.section-highlight {
  animation: sectionPing 1.1s ease-out;
}
@keyframes sectionPing {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; }
}

/* =========================
   記事
   ========================= */
.story-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  min-height: 320px;
}

.story-list > .message { grid-column: 1 / -1; }
.story-list.is-updating { opacity: 0.45; transition: opacity 0.15s ease; }

.story { min-width: 0; }
.story--lead { grid-column: 1 / -1; }
.story--row { grid-column: 1 / -1; }

.story-link {
  display: block;
  height: 100%;
  color: inherit;
}

.story-thumb {
  position: relative;
  overflow: hidden;
  background: var(--card-2);
}
.story-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.story-link:hover .story-thumb img { transform: scale(1.035); }

.story-thumb-fallback {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
  height: 100%;
  padding: 12px;
  color: var(--ink-3);
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--ink) 4%, transparent) 14px 15px),
    var(--card-2);
}
.story-thumb-fallback svg { width: 22px; height: 22px; opacity: 0.7; }
.story-thumb-fallback span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
}

.story-title {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: -0.005em;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 12px;
  color: var(--ink-3);
}
.source-chip { color: var(--ink-2); font-weight: 600; }
.category-chip {
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.7;
}
.story-time { font-variant-numeric: tabular-nums; }

/* 先頭記事：画像に見出しを重ねる */
.story--lead .story-link {
  position: relative;
  display: block;
  min-height: 380px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card-2);
}
.story--lead .story-thumb {
  position: absolute;
  inset: 0;
}
.story--lead .story-thumb-fallback {
  align-items: flex-start;
  justify-content: flex-start;
  background:
    repeating-linear-gradient(135deg, transparent 0 18px, rgba(255, 255, 255, 0.05) 18px 19px),
    linear-gradient(135deg, #12304a, #0a7c86);
  color: rgba(255, 255, 255, 0.7);
}
.story--lead .story-body {
  position: absolute;
  inset: auto 0 0 0;
  /* タイトルの少し上から下へ向けて、なめらかに暗くしていく（段差が出ないよう多段階） */
  padding: 72px 28px 26px;
  color: #fff;
  background: linear-gradient(
    180deg,
    rgba(7, 14, 24, 0) 0%,
    rgba(7, 14, 24, 0.22) 18%,
    rgba(7, 14, 24, 0.5) 40%,
    rgba(7, 14, 24, 0.76) 66%,
    rgba(7, 14, 24, 0.9) 100%
  );
  text-shadow: 0 1px 12px rgba(7, 14, 24, 0.45);
}
.story--lead .story-title {
  max-width: 34em;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.38;
  letter-spacing: -0.015em;
  -webkit-line-clamp: 3;
}
.story--lead .story-meta { margin-top: 12px; color: rgba(255, 255, 255, 0.78); }
.story--lead .source-chip { color: #fff; }
.story--lead .category-chip { border-color: rgba(255, 255, 255, 0.4); }

/* 2番目・3番目：画像上・見出し下のカード */
.story--card .story-link {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.story--card .story-link:hover { border-color: var(--ink-3); }
.story--card .story-thumb { aspect-ratio: 16 / 9; }
.story--card .story-body { padding: 14px 16px 16px; }
.story--card .story-title { font-size: 17px; -webkit-line-clamp: 3; }
.story--card .story-meta { margin-top: 10px; }

/* 4番目以降：見出し左・画像右の一覧 */
.story--row .story-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.story--row .story-body { flex: 1; min-width: 0; }
.story--row .story-title { font-size: 16px; -webkit-line-clamp: 2; }
.story--row .story-meta { margin-top: 8px; }
.story--row .story-thumb {
  flex-shrink: 0;
  width: 128px;
  height: 80px;
  border-radius: var(--radius-sm);
}
.story--row .story-link:hover .story-title {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* 読み込み中の骨組み */
.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--line-2) 25%, var(--card-2) 50%, var(--line-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton--lead { grid-column: 1 / -1; height: 380px; }
.skeleton--card { height: 240px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.feed-actions {
  display: flex;
  justify-content: center;
  padding-top: 28px;
}

.more-button {
  min-width: 220px;
  padding: 11px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.more-button:hover:not(:disabled) { border-color: var(--ink-2); }
.more-button:disabled { opacity: 0.5; cursor: default; }

.message {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 240px;
  padding: 32px;
  text-align: center;
  color: var(--ink-2);
  font-size: 14px;
}
.message button {
  padding: 9px 20px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.message button:hover { border-color: var(--ink-2); }

/* =========================
   サイドバー・パネル
   ========================= */
.sidebar { display: grid; gap: 18px; }

.panel {
  padding: 18px 20px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.widget-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.widget-heading h2 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0;
}

/* 天気：天候で色合いが変わる */
.weather-card {
  --sky: var(--accent);
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--sky) 20%, var(--card)) 0%, var(--card) 65%),
    var(--card);
  transition: background 0.5s ease;
}
.weather-card[data-sky="sunny"] { --sky: #f2a81d; }
.weather-card[data-sky="partly"] { --sky: #e0b04a; }
.weather-card[data-sky="cloudy"] { --sky: #8a9bb0; }
.weather-card[data-sky="rain"] { --sky: #3b7de0; }
.weather-card[data-sky="thunderstorm"] { --sky: #7a55d6; }
.weather-card[data-sky="snow"] { --sky: #6fc3e6; }
.weather-card[data-sky="sleet"] { --sky: #5aa3c9; }

.weather-date {
  margin: 0 0 6px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
}


.location-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin: 8px 0 0 -8px;
  padding: 4px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}
.location-button:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.location-button svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--ink-2); }
.location-button svg.chevron-icon { color: var(--ink-3); }
.location-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weather-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 10px;
}
.weather-primary-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.weather-glyph {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  font-size: 40px;
  line-height: 1;
}
.weather-glyph svg { width: 56px; height: 56px; }

.weather-primary-text { min-width: 0; }
.weather-primary-text strong {
  display: block;
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.3;
}
.weather-primary-text span { color: var(--ink-3); font-size: 12.5px; }

.temperature-row { display: grid; gap: 2px; text-align: right; }
.temp-box { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; }
.temp-box span { color: var(--ink-3); font-size: 12px; }
.temp-box strong { font-family: var(--font-head); font-weight: 900; line-height: 1.1; }
.temp-box .high { font-size: 28px; color: var(--up); }
.temp-box .low { font-size: 18px; color: var(--down); }

.weather-summary { margin: 4px 0 8px; color: var(--ink-2); font-size: 13px; line-height: 1.7; }
.rain { margin: 0 0 14px; color: var(--ink-2); font-size: 12.5px; font-weight: 500; }

.day-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
}
.day-strip:empty { display: none; }

.day-cell {
  min-width: 0;
  padding: 8px 2px 9px;
  text-align: center;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--card) 70%, transparent);
  border: 1px solid var(--line-2);
}
.day-cell b { display: block; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.day-cell .glyph { display: grid; place-items: center; height: 30px; margin: 4px auto; font-size: 20px; }
.day-cell .glyph svg { width: 28px; height: 28px; }
.day-cell small { display: block; color: var(--ink-2); font-size: 11.5px; font-weight: 500; white-space: nowrap; }

.weather-updated { margin: 12px 0 0; color: var(--ink-3); font-size: 11.5px; }
.weather-error { color: var(--up); }

/* 為替 */
.fx-live { color: var(--ink-3); font-size: 11.5px; }
.fx-live::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}
.fx-live.is-stale::before { background: var(--ink-3); }

.fx-list { list-style: none; margin: 8px 0 0; padding: 0; }

.fx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 8px;
  margin-inline: -8px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--line-2);
}
.fx-item:last-child { border-bottom: 0; }

@keyframes fxFlashUp { 0% { background-color: color-mix(in srgb, var(--up) 22%, transparent); } 100% { background-color: transparent; } }
@keyframes fxFlashDown { 0% { background-color: color-mix(in srgb, var(--down) 22%, transparent); } 100% { background-color: transparent; } }
.fx-item.flash-up { animation: fxFlashUp 1.2s ease-out; }
.fx-item.flash-down { animation: fxFlashDown 1.2s ease-out; }

.fx-pair { display: flex; flex-direction: column; min-width: 0; }
.fx-pair strong { font-size: 14px; font-weight: 600; line-height: 1.3; }
.fx-pair small { color: var(--ink-3); font-size: 11.5px; }

.fx-values { text-align: right; }
.fx-rate { display: block; font-family: var(--font-head); font-size: 18px; font-weight: 900; line-height: 1.25; }
.fx-diff { display: inline-block; color: var(--ink-3); font-size: 12px; font-weight: 500; }
.fx-diff.up { color: var(--up); }
.fx-diff.down { color: var(--down); }

.fx-extra-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.36s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.26s ease;
}
.fx-extra-wrap.is-open { grid-template-rows: 1fr; opacity: 1; }
.fx-extra-inner { overflow: hidden; }
.fx-list-extra { margin-top: 0; border-top: 1px solid var(--line-2); }

.fx-more-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 10px;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}
.fx-more-button:hover { border-color: var(--ink-2); color: var(--ink); }
.fx-more-button svg { width: 14px; height: 14px; transition: transform 0.2s ease; }
.fx-more-button[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Wikipedia */
.wiki-card { position: relative; z-index: 20; }
.wiki-form { position: relative; margin-top: 12px; }

.wiki-input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.wiki-input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.wiki-input-group input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 0;
  background: transparent;
  font-size: 13.5px;
  outline: none;
}
.wiki-input-group input::placeholder { color: var(--ink-3); }
.wiki-input-group input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.wiki-lang {
  flex-shrink: 0;
  height: 40px;
  padding: 0 6px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}
.wiki-lang option { background: var(--card); color: var(--ink); }

.wiki-submit {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 40px;
  padding: 0;
  border: 0;
  background: var(--ink);
  color: var(--paper);
}
.wiki-submit:hover { opacity: 0.85; }
.wiki-submit svg { width: 15px; height: 15px; }

.wiki-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 45;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px -12px rgba(7, 14, 24, 0.4);
}
.wiki-results { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.wiki-item { border-bottom: 1px solid var(--line-2); }
.wiki-item:last-child { border-bottom: 0; }
.wiki-item a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; }
.wiki-item a:hover, .wiki-item a.is-selected { background: var(--card-2); }

.wiki-thumb {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--card-2);
  border: 1px solid var(--line-2);
  color: var(--ink-3);
}
.wiki-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wiki-thumb svg { width: 18px; height: 18px; }

.wiki-item-body { flex: 1; min-width: 0; }
.wiki-item-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
}
.wiki-item-title mark {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  color: inherit;
  border-radius: 2px;
}
.wiki-item-desc {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-3);
  font-size: 12px;
}
.wiki-empty { padding: 16px 12px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* リンク */
.links-list { list-style: none; margin: 8px 0 0; padding: 0; }
.links-list li + li { border-top: 1px solid var(--line-2); }
.links-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 2px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
}
.links-list a:hover { color: var(--accent); }
.links-list a svg { width: 14px; height: 14px; color: var(--ink-3); transition: transform 0.15s ease, color 0.15s ease; }
.links-list a:hover svg { color: var(--accent); transform: translate(2px, -2px); }

/* =========================
   フッター
   ========================= */
footer { border-top: 1px solid var(--line); background: var(--card); }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0;
}
.footer-inner strong { font-family: var(--font-head); font-size: 18px; font-weight: 900; }
.footer-inner small { display: block; margin-top: 2px; color: var(--ink-3); font-size: 12px; }
.footer-inner nav { display: flex; gap: 22px; color: var(--ink-2); font-size: 13px; }
.footer-inner nav a:hover { color: var(--accent); }

.noscript { margin: 0; padding: 12px 24px; background: var(--accent-soft); text-align: center; font-size: 13px; }

/* =========================
   地域設定ダイアログ
   ========================= */
.dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(7, 14, 24, 0.55);
}
.dialog:not([open]) { display: none; }
.dialog::backdrop { background: rgba(7, 14, 24, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

.dialog-head { position: relative; padding: 22px 60px 16px 24px; border-bottom: 1px solid var(--line-2); }
.dialog-head h2 { margin: 0; font-family: var(--font-head); font-size: 19px; font-weight: 900; }
.dialog-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; }

.dialog-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
}
.dialog-close svg { width: 15px; height: 15px; }
.dialog-close:hover { color: var(--ink); border-color: var(--ink-2); }

.dialog-body { padding: 20px 24px 24px; }

.geo-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 600;
}
.geo-button svg { width: 16px; height: 16px; }
.geo-button:hover:not(:disabled) { border-color: var(--accent); }
.geo-button:disabled { opacity: 0.55; cursor: wait; }

.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--ink-3); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; margin-bottom: 6px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.field select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}
.field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.field select:disabled { opacity: 0.5; }

.dialog-status { min-height: 20px; margin: 6px 0 12px; color: var(--ink-2); font-size: 13px; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions button { padding: 10px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; }
.cancel { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.cancel:hover { color: var(--ink); border-color: var(--ink-2); }
.confirm { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.confirm:hover:not(:disabled) { opacity: 0.85; }
.confirm:disabled { opacity: 0.35; cursor: not-allowed; }

.geo-credit { margin: 16px 0 0; color: var(--ink-3); font-size: 11.5px; text-align: right; }
.geo-credit a { text-decoration: underline; text-underline-offset: 2px; }

/* =========================
   レスポンシブ
   ========================= */
@media (max-width: 1060px) {
  .main-grid { grid-template-columns: minmax(0, 1fr) 320px; gap: 26px; }
  .story--lead .story-title { font-size: 24px; }
}

@media (max-width: 860px) {
  .main-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-top: 24px; }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .weather-card, .wiki-card { grid-column: 1 / -1; }
  .news-toolbar h1 { font-size: 28px; }
}

@media (max-width: 640px) {
  .shell { width: calc(100% - 32px); }

  .rail-inner { height: 36px; }

  .header-main { height: auto; padding-block: 10px 6px; gap: 8px; }
  .brand { gap: 8px; min-width: 0; }
  .brand-wordmark { font-size: 20px; }
  .brand-mark { width: 28px; height: 28px; }
  .btn { height: 32px; padding: 0 10px; font-size: 12.5px; }
  .theme-toggle { width: 32px; height: 32px; }
  .header-actions { gap: 6px; }
  .category-bar { height: 44px; }

  html, #news, #weather, #fx, #services { scroll-padding-top: 130px; scroll-margin-top: 130px; }

  .news-toolbar { flex-direction: column; align-items: stretch; gap: 14px; }
  .news-search { width: 100%; }
  .news-toolbar h1 { font-size: 26px; }

  .story-list { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .story--lead .story-link { min-height: 320px; }
  .story--lead .story-body { padding: 64px 18px 18px; }
  .story--lead .story-title { font-size: 21px; }
  .story--row .story-thumb { width: 104px; height: 70px; }
  .story--row .story-title { font-size: 15px; }
  .skeleton--lead { height: 320px; }

  .sidebar { grid-template-columns: minmax(0, 1fr); }
  .footer-inner nav { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .tape { overflow-x: auto; scrollbar-width: none; }
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- ログイン中のヘッダー表示（PHP版で追加） ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.header-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 14em;
  margin-right: 2px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
}
.header-user svg { width: 18px; height: 18px; flex-shrink: 0; }
.header-user-id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-logout { display: contents; }
@media (max-width: 640px) {
  .header-user { max-width: 7.5em; font-size: 12.5px; }
  .header-user svg { display: none; }
}
