:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e3e3e3;
  --surface: #f6f7f9;
  --accent: #ea580c;
  --accent-fg: #ffffff;
  --danger: #b42318;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --fg: #e8e8e8;
    --muted: #9aa0a6;
    --border: #33363b;
    --surface: #1e2126;
    --accent: #fb923c;
    --accent-fg: #1a1a1a;
    --danger: #f7a39a;
  }
}

* { box-sizing: border-box; }

/* display を指定した要素でも hidden 属性で確実に消えるようにする */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.6;
}

a { color: var(--accent); }

.app { max-width: 1280px; margin: 0 auto; }

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.bar { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
h1 { margin: 0; font-size: 18px; }
.bar-actions { display: flex; gap: 4px; }

/* 指で押せる大きさを確保する。iOS の推奨は44px以上 */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

.bar-actions button { min-width: 44px; padding: 0; border: none; background: transparent; font-size: 20px; }

/* 16px 未満だと iOS が入力時に勝手に拡大する */
input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
}

.search-bar { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; }
.search-bar .muted { white-space: nowrap; }

.tabs { display: flex; }
.tab {
  flex: 1;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}
.tab.is-active { border-bottom-color: var(--accent); color: var(--fg); font-weight: 600; }

#list-pane { padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }

.notices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
}
.notice button { flex-shrink: 0; }

.mark-all { width: 100%; margin-top: 12px; }

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

.card {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 14px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.card[aria-current="true"] { background: var(--surface); }
.card.is-read { opacity: 0.55; }
.card-title { display: block; font-size: 16px; font-weight: 600; line-height: 1.45; }
.card-summary {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; color: var(--muted); font-size: 12px; }

.badge { padding: 0 6px; border-radius: 4px; background: var(--accent); color: var(--accent-fg); font-size: 11px; line-height: 18px; }
.badge.muted-badge { border: 1px solid var(--border); background: var(--surface); color: var(--muted); }

.list-more { width: 100%; margin: 16px 0; }
.empty { padding: 48px 16px; text-align: center; }
.muted { color: var(--muted); font-size: 14px; }

#detail-pane { padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.back { margin-top: 12px; }
#detail h2 { margin: 12px 0 4px; font-size: 20px; line-height: 1.45; }
#detail p { margin: 4px 0; }
.summary { margin-top: 12px !important; font-size: 15px; }

.ai { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: var(--surface); }
.ai h3 { margin: 0 0 8px; color: var(--accent); font-size: 14px; }
.ai-points { margin: 8px 0 0; padding-left: 1.2em; }
.ai-points li { margin: 4px 0; }
.ai .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.error-text { color: var(--danger); }

.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 20;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  transform: translateX(-50%);
}

@keyframes spin { to { transform: rotate(360deg); } }
#refresh.is-spinning { animation: spin 1s linear infinite; }

dialog {
  width: 92%;
  max-width: 480px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
}
dialog h2 { margin-top: 0; }
dialog label { display: block; margin: 12px 0 4px; font-size: 14px; }
dialog .actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }

/* スマホ: 一覧と詳細を切り替えて表示する */
@media (max-width: 899px) {
  #detail-pane, #detail-empty { display: none; }
  body.is-detail #detail-pane { display: block; }
  body.is-detail #list-pane,
  body.is-detail .tabs,
  body.is-detail .search-bar { display: none; }
}

/* PC: 左に一覧、右に詳細の2列。それぞれが独立してスクロールする */
@media (min-width: 900px) {
  .app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
  .top { position: static; }
  .panes { display: grid; flex: 1; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); min-height: 0; }
  #list-pane, #detail-pane { overflow-y: auto; }
  #list-pane { border-right: 1px solid var(--border); }
  #detail-pane { padding: 0 32px 32px; }
  .back { display: none; }
}
