:root {
  --bg: #f6f3ee;
  --surface: #fffdf9;
  --surface-2: #efebe3;
  --text: #1f1d1a;
  --muted: #7a746b;
  --line: #e4ded3;
  --accent: #b5542d;
  --accent-soft: #f3e2d8;
  --star: #c98a1a;
  --ok: #3b7a57;
  --ok-soft: #dfeee4;
  --warn: #9a3b3b;
  --warn-soft: #f4dcdc;
  --hold: #6b6f8a;
  --hold-soft: #e5e6f1;
  --shadow: 0 10px 30px rgba(40, 30, 10, .12);
  --radius: 14px;
  --font: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --surface: #1f1d1a; --surface-2: #27251f; --text: #ece7de; --muted: #9b958a;
    --line: #322f29; --accent: #e0825a; --accent-soft: #3a261d; --star: #e0ad3e;
    --ok: #7fc39b; --ok-soft: #1f3328; --warn: #e08787; --warn-soft: #3a2222; --hold: #a3a7c7; --hold-soft: #25273a;
    --shadow: 0 10px 30px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --surface: #1f1d1a; --surface-2: #27251f; --text: #ece7de; --muted: #9b958a;
  --line: #322f29; --accent: #e0825a; --accent-soft: #3a261d; --star: #e0ad3e;
  --ok: #7fc39b; --ok-soft: #1f3328; --warn: #e08787; --warn-soft: #3a2222; --hold: #a3a7c7; --hold-soft: #25273a;
  --shadow: 0 10px 30px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; overscroll-behavior-y: contain; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---- header ---- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 4px; padding: 8px 10px 0; }
.brand { font-size: 18px; margin: 0 4px; font-weight: 700; letter-spacing: .02em; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; font-size: 20px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active, .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.tabs { display: flex; gap: 2px; padding: 4px 10px 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { padding: 10px 12px 10px; font-weight: 600; color: var(--muted); border-bottom: 2.5px solid transparent; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tabs button.active { color: var(--text); border-color: var(--accent); }
.tabs .cnt { font-weight: 600; font-size: 12px; color: var(--muted); }
.tabs .cnt:empty { display: none; }
.chips { display: flex; gap: 6px; padding: 8px 10px 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { padding: 5px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.chips button.active { background: var(--text); color: var(--bg); }
.chips button b { font-weight: 600; margin-left: 4px; opacity: .8; }
.searchbar { display: flex; gap: 6px; padding: 6px 10px 10px; }
.searchbar input { flex: 1; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }

/* ---- list ---- */
.list { max-width: 760px; margin: 0 auto; padding: 8px 10px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.daysep { display: flex; align-items: center; gap: 10px; margin: 10px 2px 2px; font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.daysep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.daysep:first-child { margin-top: 2px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 6px; text-align: left; width: 100%; position: relative; }
.card:active { transform: scale(.995); }
.card.focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.card.read { opacity: .55; }
.card .meta { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.card .meta .feed { font-weight: 600; color: var(--text); opacity: .75; }
.card h3 { margin: 0; font-size: 16.5px; line-height: 1.4; font-weight: 700; }
.card .excerpt { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .summary { font-size: 14px; color: var(--text); background: var(--surface-2); border-radius: 8px; padding: 6px 10px; }
.badge { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; font-weight: 700; letter-spacing: .02em; }
.badge.A { background: var(--ok-soft); color: var(--ok); }
.badge.B { background: var(--warn-soft); color: var(--warn); }
.badge.C { background: var(--hold-soft); color: var(--hold); }
.badge.clip { background: var(--accent-soft); color: var(--accent); }
.star { color: var(--star); }
.card-tools { position: absolute; right: 8px; top: 8px; display: flex; gap: 2px; opacity: 0; }
.card:hover .card-tools, .card.focus .card-tools { opacity: 1; }
.card-tools button { width: 32px; height: 32px; border-radius: 8px; color: var(--muted); display: grid; place-items: center; }
.card-tools button:hover { background: var(--surface-2); color: var(--text); }
@media (pointer: coarse) { .card-tools { display: none; } }
.card .check { display: none; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); background: var(--surface); place-items: center; font-size: 14px; color: #fff; }
body.selecting .card { padding-left: 44px; }
body.selecting .card .check { display: grid; }
body.selecting .card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
body.selecting .card.selected .check { background: var(--accent); border-color: var(--accent); }
body.selecting .card-tools { display: none; }
body.selecting .list { padding-bottom: calc(80px + var(--safe-b)); }
.pill-btn { padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line); font-size: 13.5px; font-weight: 600; color: var(--muted); margin-right: 2px; white-space: nowrap; }
.pill-btn:hover { background: var(--surface-2); color: var(--text); }
#btn-select.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.selbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 18; display: flex; align-items: center; gap: 6px; padding: 8px 12px calc(8px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,0,0,.08); }
.selbar .text-btn { padding: 8px 12px; font-size: 13.5px; }
.selbar .selcount { font-weight: 700; font-size: 14px; }
.selbar > button:not(.text-btn):not(.icon-btn) { padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; }
.selbar > button[disabled] { opacity: .4; }
@media (min-width: 900px) { body.sidebar-open .selbar { left: 300px; } body.has-article .selbar { right: min(760px, 62vw); } }
.list-foot { max-width: 760px; margin: 0 auto; padding: 0 10px 40px; display: flex; justify-content: center; gap: 10px; }
.text-btn { padding: 10px 16px; border-radius: 10px; background: var(--surface-2); color: var(--text); font-weight: 600; text-decoration: none; font-size: 14.5px; }
.text-btn:hover { filter: brightness(.97); }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty b { display: block; font-size: 32px; margin-bottom: 8px; }

/* ---- drawer ---- */
.drawer { position: fixed; inset: 0; z-index: 30; }
.drawer-bg { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.drawer-body { position: absolute; left: 0; top: 0; bottom: 0; width: min(320px, 86vw); background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; padding-bottom: var(--safe-b); }
.drawer-head { display: flex; align-items: center; gap: 2px; padding: 12px 10px 8px 16px; border-bottom: 1px solid var(--line); }

#drawer-feeds { flex: 1; overflow-y: auto; padding: 6px 0; }
.drawer-cat { padding: 6px 16px 2px 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 4px; cursor: pointer; }
.drawer-cat:hover { color: var(--text); }
.drawer-cat .caret { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: var(--muted); font-size: 12px; transition: transform .15s; }
.drawer-cat .caret:hover { background: var(--surface-2); color: var(--text); }
.drawer-cat.collapsed .caret { transform: rotate(-90deg); }
.drawer-cat.active .cat-title { color: var(--accent); }
.drawer-cat:hover .cat-title { color: var(--text); }
.drawer-cat .cat-title { flex: 1; }
.drawer-feed { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 8px 16px; font-size: 14.5px; }
.drawer-feed:hover, .drawer-feed.active { background: var(--surface-2); }
.drawer-feed .n { color: var(--muted); font-size: 12.5px; }
.drawer-feed.err { color: var(--warn); }
.drawer-foot { border-top: 1px solid var(--line); padding: 10px 16px 12px; display: grid; gap: 6px; }
.drawer-foot #ai-status { line-height: 1.4; }
.drawer-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-btn { padding: 2px 0; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.link-btn:hover { color: var(--text); }
.drawer-links .dot { color: var(--line); }

/* ---- article ---- */
.article { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.article-bar { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
.article-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.article-inner { max-width: 680px; margin: 0 auto; padding: 18px 18px 40px; }
.article .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.article h2 { font-size: 22px; line-height: 1.35; margin: 8px 0 14px; }
.ai-box { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 14.5px; }
.ai-box .r { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.content { font-size: 17px; line-height: 1.8; word-break: break-word; }
.content img, .content video, .content iframe { max-width: 100%; height: auto; border-radius: 8px; }
.content p { margin: 0 0 1em; }
.content pre { overflow-x: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; font-size: 14px; }
.content blockquote { border-left: 3px solid var(--line); margin: 0 0 1em; padding-left: 12px; color: var(--muted); }
.content table { max-width: 100%; display: block; overflow-x: auto; }
.article-end { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0 18px; }
.feedback { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.feedback button { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-size: 13.5px; }
.feedback button.active { background: var(--text); color: var(--bg); }
.article-actions { display: flex; justify-content: space-around; border-top: 1px solid var(--line); background: var(--surface); padding: 6px 0 calc(6px + var(--safe-b)); }
.article-actions button { display: grid; justify-items: center; gap: 2px; padding: 6px 14px; border-radius: 10px; font-size: 11.5px; color: var(--muted); min-width: 72px; }
.article-actions button .ic { font-size: 20px; line-height: 1.1; }
.article-actions button.on { color: var(--accent); }
.article-actions button#act-star.on { color: var(--star); }
.article-actions button:active { background: var(--surface-2); }

/* ---- shortcuts panel (PC のみ・常時表示・折りたたみ可) ---- */
.keys-panel { position: fixed; right: 16px; bottom: 16px; z-index: 28; width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; overflow: hidden; }
.keys-head { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 8px 12px; font-weight: 700; font-size: 12.5px; color: var(--muted); background: var(--surface-2); }
.keys-caret { transition: transform .15s; }
.keys-panel.collapsed .keys-caret { transform: rotate(-90deg); }
.keys-panel.collapsed .keys-body { display: none; }
.keys-panel.collapsed { width: 44px; height: 44px; border-radius: 50%; }
.keys-panel.collapsed .keys-head { width: 44px; height: 44px; padding: 0; justify-content: center; font-size: 18px; color: var(--accent); }
.keys-panel.collapsed .keys-label { font-size: 0; }
.keys-panel.collapsed .keys-label::before { content: "⌨"; font-size: 18px; }
.keys-panel.collapsed .keys-caret { display: none; }
.keys-body { padding: 8px 12px 10px; display: grid; gap: 5px; }
.keys-body > div { display: flex; align-items: center; gap: 4px; }
.keys-body span { margin-left: 6px; color: var(--text); }
.keys-panel.off { display: none; }
@media (pointer: coarse), (max-width: 700px) { .keys-panel { display: none; } }
kbd { display: inline-block; min-width: 20px; text-align: center; padding: 0 5px; border-radius: 5px; background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; }

/* ---- sheets (フィード追加 / フィード操作) ---- */
.drawer-add { border-top: 1px solid var(--line); }
.drawer-add { display: flex; gap: 6px; padding: 8px 12px; }
.drawer-add .text-btn { flex: 1; text-align: center; display: block; padding: 9px 6px; white-space: nowrap; font-size: 14px; }
#btn-reorder.on { background: var(--accent); color: #fff; }
.mv { display: none; gap: 2px; margin-left: auto; }
.mv button { width: 28px; height: 28px; border-radius: 6px; color: var(--muted); font-size: 14px; }
.mv button:hover { background: var(--bg); color: var(--text); }
.mv button[disabled] { opacity: .25; }
body.reordering .mv { display: flex; }
body.reordering .drawer-feed .n, body.reordering .drawer-cat .n { display: none; }
body.reordering .drawer-feed, body.reordering .drawer-cat { cursor: default; }
.reorder-hint { padding: 6px 16px; font-size: 12px; color: var(--muted); }
.drawer-feed { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.sheet { position: fixed; inset: 0; z-index: 36; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet-body { position: relative; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; background: var(--surface); border-radius: 18px 18px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); box-shadow: var(--shadow); animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-body { border-radius: 18px; padding-bottom: 18px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.field { display: grid; gap: 4px; margin: 10px 0; font-size: 13.5px; color: var(--muted); }
.field input, .field select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 15px; width: 100%; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.sheet-actions .primary { padding: 10px 18px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; }
.sheet-actions .primary[disabled] { opacity: .5; }
.sheet-actions .text-btn { padding: 10px 14px; }
.sheet .error { color: var(--warn); margin: 6px 0 0; min-height: 1.2em; }
.sheet-list { display: grid; }
.sheet-list button { text-align: left; padding: 12px 6px; border-bottom: 1px solid var(--line); font-size: 15.5px; }
.sheet-list button:last-child { border-bottom: 0; }
.sheet-list button.danger { color: var(--warn); }
.sheet-list button[disabled] { opacity: .45; }
.drawer-cat { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: default; }
.sheet-sub { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.cands { display: grid; gap: 6px; margin: 6px 0; }
.cands label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.cands label small { display: block; color: var(--muted); word-break: break-all; }

/* ---- login / toast ---- */
.login { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.login form { width: min(360px, 100%); display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); }
.login h1 { margin: 0; font-size: 24px; }
.login input { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
.login button { padding: 12px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; }
.login .error { color: var(--warn); margin: 0; min-height: 1.2em; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 50; font-size: 14.5px; box-shadow: var(--shadow); max-width: 90vw; }
.toast a { color: inherit; text-decoration: underline; margin-left: 8px; }

@media (min-width: 900px) {
  .article { left: auto; width: min(760px, 62vw); border-left: 1px solid var(--line); box-shadow: var(--shadow); }
  body.has-article .list, body.has-article .top { margin-right: min(760px, 62vw); }
  .list { padding-top: 12px; }

  /* サイドバー表示中: ドロワーを左に常設し、body 全体を右へずらす（一覧は残り幅の中央に収まる） */
  body.sidebar-open { padding-left: 300px; }
  body.sidebar-open .drawer { position: fixed; inset: 0 auto 0 0; width: 300px; z-index: 15; }
  body.sidebar-open .drawer-bg { display: none; }
  body.sidebar-open .drawer-body { width: 300px; box-shadow: none; border-right: 1px solid var(--line); }
  body.sidebar-open.has-article .article { width: min(720px, calc(60vw - 180px)); }
  body.sidebar-open.has-article .list, body.sidebar-open.has-article .top { margin-right: min(720px, calc(60vw - 180px)); }
  
}
