/* 要約ちゃん: 読みやすさ優先。ダークモードは端末の設定に合わせる */
:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f2ece2;
  --text: #2b2622;
  --text-2: #6f665d;
  --text-3: #9a9087;
  --line: #e6ddd1;
  --accent: #e0702f;
  --accent-soft: #fbe6d8;
  --accent-text: #b4521a;
  --star: #e8a317;
  --danger: #d64541;
  --ok: #3a8f5c;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 2px 10px rgba(60, 40, 20, .05);
  --radius: 14px;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181614;
    --surface: #221f1c;
    --surface-2: #2c2824;
    --text: #ece6de;
    --text-2: #b0a79d;
    --text-3: #807870;
    --line: #37322d;
    --accent: #f08a4b;
    --accent-soft: #3d2a1e;
    --accent-text: #f5a878;
    --star: #f0b83a;
    --danger: #ef6b67;
    --ok: #62b886;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent-text); }
[hidden] { display: none !important; }
svg.i { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* --- 骨組み --- */
#app { min-height: 100dvh; }
.main {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(var(--safe-t)) 0 calc(var(--tabbar-h) + var(--safe-b) + 24px);
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  min-height: 52px;
  padding: calc(6px + var(--safe-t)) 16px 6px;
  margin-top: calc(-1 * var(--safe-t));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar h1 { font-size: 20px; margin: 0; flex: 1; font-weight: 800; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 13px; color: var(--text-2); font-weight: 500; margin-left: 6px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; color: var(--text-2); }
.icon-btn:active { background: var(--surface-2); }
.text-btn { padding: 8px 12px; border-radius: 10px; color: var(--accent-text); font-weight: 600; font-size: 15px; }
.text-btn:active { background: var(--accent-soft); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--text-3); position: relative; text-decoration: none;
}
.tab.on { color: var(--accent); }
.tab .count {
  position: absolute; top: 4px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.tab-brand { display: none; }

@media (min-width: 900px) {
  .tabbar {
    top: 0; right: auto; width: 220px; height: auto; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 20px 12px; border-top: 0; border-right: 1px solid var(--line);
  }
  .tab { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 15px; padding: 10px 14px; border-radius: 12px; color: var(--text-2); }
  .tab.on { background: var(--accent-soft); color: var(--accent-text); }
  .tab .count { position: static; margin-left: auto; }
  .tab-brand { display: block; font-weight: 800; font-size: 20px; padding: 4px 14px 18px; }
  .main { padding-left: 220px; max-width: calc(760px + 220px); padding-bottom: 40px; }
  .fab { right: calc(50% - 470px + 110px) !important; bottom: 32px !important; }
  .selbar { left: 220px !important; }
  .toast { bottom: 28px !important; }
}

/* --- ホーム --- */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { padding: 5px 14px; border-radius: 8px; font-size: 14px; color: var(--text-2); font-weight: 600; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 12px; border-radius: 999px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2); white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip small { opacity: .75; margin-left: 3px; }
.banner {
  margin: 8px 16px 12px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--text); font-size: 14px; display: flex; gap: 10px; align-items: center;
}
.banner p { margin: 0; flex: 1; }
.banner .btn { flex: none; }

.day { font-size: 13px; font-weight: 700; color: var(--text-2); padding: 18px 20px 6px; letter-spacing: .04em; }
.list { display: flex; flex-direction: column; gap: 10px; padding: 0 16px; }
.empty { text-align: center; color: var(--text-3); padding: 60px 24px; font-size: 15px; }
.empty b { display: block; font-size: 40px; margin-bottom: 8px; }
.more { display: block; margin: 16px auto; }

.swipe { position: relative; border-radius: var(--radius); overflow: hidden; }
.swipe-act {
  position: absolute; inset: 0; display: flex; justify-content: flex-end; align-items: stretch;
  background: var(--danger); border-radius: var(--radius);
}
.swipe-act button { color: #fff; font-weight: 700; font-size: 14px; width: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.card {
  position: relative; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px 12px; touch-action: pan-y; transition: transform .22s ease; display: flex; gap: 12px;
}
.card.dragging { transition: none; }
.card .body { flex: 1; min-width: 0; }
.card h3 { margin: 0 0 4px; font-size: 16.5px; line-height: 1.45; font-weight: 700; }
.card.read h3 { color: var(--text-2); font-weight: 600; }
.card .lead { margin: 0; font-size: 14px; color: var(--text-2); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--text-3); min-width: 0; }
.meta .g { color: var(--accent-text); background: var(--accent-soft); padding: 1px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.meta .d { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .t { margin-left: auto; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 8px; }
.card.read .dot { visibility: hidden; }
.star-mini { color: var(--star); font-size: 14px; }
.card.pending { background: var(--surface-2); box-shadow: none; }
.card.pending h3 { color: var(--text-2); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; flex: none; margin-top: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.card.failed { border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.card.failed .err { color: var(--danger); font-size: 13.5px; margin: 2px 0 8px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 11px; font-weight: 600; font-size: 15px;
  background: var(--surface-2); color: var(--text);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 13.5px; border-radius: 9px; }
.btn:disabled { opacity: .5; }
.check {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); flex: none; margin-top: 2px;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.card.selected .check { background: var(--accent); border-color: var(--accent); }
.card.selected { outline: 2px solid var(--accent); }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 25;
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(224, 112, 47, .4);
}
.fab svg.i { width: 26px; height: 26px; stroke-width: 2.4; }

.selbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  display: flex; justify-content: space-around; align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line);
}
.selbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text-2); padding: 4px 10px; }
.selbar button:disabled { opacity: .35; }
.selbar .del { color: var(--danger); }

/* --- 記事 --- */
.article { padding: 8px 20px 20px; }
.article h1 { font-size: 23px; line-height: 1.45; margin: 6px 0 10px; font-weight: 800; letter-spacing: .01em; }
.a-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13.5px; color: var(--text-2); margin-bottom: 18px; }
.genre-btn { color: var(--accent-text); background: var(--accent-soft); padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.src { display: flex; align-items: center; gap: 6px; font-size: 13.5px; padding: 10px 12px; margin: 0 0 18px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); text-decoration: none; overflow: hidden; }
.src span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prose { font-size: 17px; line-height: 1.95; letter-spacing: .01em; overflow-wrap: anywhere; }
.prose p { margin: 0 0 1.1em; }
.prose h2 { font-size: 18.5px; line-height: 1.5; margin: 1.8em 0 .6em; padding-left: 12px; border-left: 4px solid var(--accent); font-weight: 800; }
.prose h3 { font-size: 17px; margin: 1.4em 0 .4em; font-weight: 800; }
.prose ul, .prose ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.prose li { margin: .35em 0; padding-left: .1em; line-height: 1.7; }
.prose li::marker { color: var(--accent); font-weight: 700; }
.prose li > ul, .prose li > ol { margin: .2em 0 .3em; }
.prose li > ul li { font-size: 16px; color: var(--text-2); }
.prose strong { background: linear-gradient(transparent 62%, var(--accent-soft) 62%); font-weight: 700; }
.prose .note { font-size: 13.5px; color: var(--text-3); }
/* 「ざっくり言うと」のように、太字だけの段落の直後の箇条書きは囲みにする */
/* （太字だけの段落には app.js が kicker を付ける） */
.prose p.kicker + ul {
  background: var(--surface-2); border-radius: 14px; padding: 12px 16px 12px 2.1em; margin-top: -.5em;
}
.prose p.kicker { margin-bottom: .8em; }
.prose p.kicker > strong { background: none; color: var(--accent-text); font-size: 15px; letter-spacing: .04em; }
.prose blockquote {
  margin: 0 0 1.1em; padding: 10px 16px; border-left: 4px solid var(--line); border-radius: 0 12px 12px 0;
  background: var(--surface-2); color: var(--text-2); font-size: 16px;
}
.prose blockquote p { margin: 0; }
.prose blockquote + p:has(> em:only-child), .prose blockquote + p { margin-top: -.4em; }
.prose hr { border: 0; border-top: 1px dashed var(--line); margin: 1.6em 0; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
.prose .table-wrap { overflow-x: auto; margin: 0 0 1.2em; border-radius: 12px; border: 1px solid var(--line); }
.prose table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.55; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
.prose td { white-space: normal; min-width: 5em; }
.prose th { background: var(--surface-2); font-weight: 700; font-size: 13.5px; color: var(--text-2); }
.prose tr:last-child td { border-bottom: 0; }
.a-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.a-actions button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--text-2); flex: 1; }
.a-actions button.on { color: var(--star); }
.a-actions button.on svg { fill: var(--star); }
@media (min-width: 900px) {
  .a-actions { left: 220px; }
}
.status-box { margin: 30px 20px; padding: 20px; border-radius: var(--radius); background: var(--surface); text-align: center; color: var(--text-2); }
.status-box .spinner { margin: 0 auto 12px; width: 24px; height: 24px; }

/* --- 未読まとめ読み --- */
.stack-item { background: var(--surface); margin: 0 12px 14px; border-radius: 18px; box-shadow: var(--shadow); padding: 4px 8px 12px; }
.stack-item .article { padding: 14px 12px 4px; }
.stack-item .article h1 { font-size: 21px; }
.stack-item.done-read { opacity: .75; }
.stack-end { text-align: center; padding: 18px 16px 30px; }
.read-mark { font-size: 12.5px; color: var(--ok); font-weight: 700; text-align: right; padding: 0 14px; min-height: 18px; }

/* --- ノート・設定 --- */
.group { background: var(--surface); border-radius: var(--radius); margin: 0 16px 18px; box-shadow: var(--shadow); overflow: hidden; }
.group-title { font-size: 13px; font-weight: 700; color: var(--text-2); padding: 16px 20px 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); min-height: 52px; width: 100%; text-align: left; text-decoration: none; color: inherit; }
.item:last-child { border-bottom: 0; }
.item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .num { color: var(--text-3); font-size: 14px; }
.item .hint { color: var(--text-3); font-size: 13px; }
.item-desc { font-size: 13px; color: var(--text-2); padding: 0 16px 14px; margin: -4px 0 0; }
.folder-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; flex: none; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 0 16px 14px; }
.progress div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.big-num { font-size: 26px; font-weight: 800; }

/* --- シート（下から出る窓）・トースト --- */
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; overflow: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 10px 18px calc(18px + var(--safe-b));
  animation: up .2s ease;
}
@media (min-width: 900px) {
  .sheet-back { align-items: center; }
  .sheet { border-radius: 20px; }
}
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-size: 18px; margin: 4px 0 12px; }
.sheet .opts { display: flex; flex-direction: column; }
.sheet .opt { padding: 13px 6px; border-bottom: 1px solid var(--line); text-align: left; display: flex; align-items: center; gap: 10px; }
.sheet .opt:last-child { border-bottom: 0; }
.sheet .opt.on { color: var(--accent-text); font-weight: 700; }
.sheet .opt.danger { color: var(--danger); }
.field { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; }
textarea.field { min-height: 130px; resize: vertical; line-height: 1.6; }
.sheet .row { display: flex; gap: 8px; margin-top: 12px; }
.sheet .row .btn { flex: 1; }
.sheet .msg { font-size: 14px; color: var(--text-2); margin: 10px 2px 0; min-height: 1.4em; }
.file-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 14px; color: var(--text-2); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  background: #2d2926; color: #fff; border-radius: 14px; padding: 11px 14px 11px 18px;
  display: flex; align-items: center; gap: 14px; font-size: 14.5px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  max-width: calc(100% - 32px); animation: up .2s ease;
}
.toast button { color: #ffb783; font-weight: 700; padding: 4px 6px; white-space: nowrap; }
@keyframes up { from { transform: translate(var(--tx, 0), 30px); opacity: 0; } }
.toast { --tx: -50%; }
@keyframes fade { from { opacity: 0; } }

/* --- ログイン --- */
.login { max-width: 360px; margin: 0 auto; padding: 18vh 24px 40px; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 20px; box-shadow: var(--shadow); }
.login h1 { font-size: 24px; margin: 14px 0 6px; }
.login p { color: var(--text-2); font-size: 14px; margin: 0 0 22px; }
.login .btn { width: 100%; margin-top: 12px; padding: 12px; }
.login .err { color: var(--danger); font-size: 14px; min-height: 1.5em; margin-top: 10px; }
