/* Sifft — dark by default, light available. */
:root {
  --sidebar-w: 280px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 8px;
}
:root[data-theme="dark"] {
  --bg: #121315;
  --sidebar: #18191c;
  --surface: #1e1f23;
  --surface-2: #26272c;
  --hover: #232428;
  --line: #2a2b30;
  --text: #ececef;
  --text-2: #b9bac1;
  --muted: #8b8c94;
  --faint: #62636b;
  --accent: #f0a640;
  --accent-ink: #1a1204;
  --accent-soft: rgba(240, 166, 64, .14);
  --danger: #f06a5b;
  --shadow: 0 20px 60px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #fbfbfa;
  --sidebar: #f2f2f0;
  --surface: #ffffff;
  --surface-2: #ecece9;
  --hover: #e8e8e5;
  --line: #e3e3df;
  --text: #19191b;
  --text-2: #3f3f45;
  --muted: #6b6b73;
  --faint: #9a9aa2;
  --accent: #b86b00;
  --accent-ink: #ffffff;
  --accent-soft: rgba(184, 107, 0, .1);
  --danger: #c7372a;
  --shadow: 0 20px 60px rgba(0, 0, 0, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sm svg.i { width: 17px; height: 17px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  transition: opacity .2s;
}
body.reading .sidebar { opacity: .4; }
body.reading .sidebar:hover { opacity: 1; }

.brand { padding: 18px 16px 10px; }
/* Horizontal lockup: gradient mark (logo-mark.svg, 6:5) + wordmark, spaced as in Logos.png */
.brand-link { display: flex; align-items: center; gap: 7px; }
.brand-mark { width: 30px; height: 25px; flex: none; }
.brand-name { font-size: 25px; font-weight: 800; letter-spacing: -.035em; line-height: 1; }

.nav { padding: 6px 8px 4px; display: flex; flex-direction: column; gap: 1px; }
.nav-item, .tree-item {
  display: flex; align-items: center; gap: 12px;
  height: 36px; padding: 0 10px; border-radius: var(--radius);
  color: var(--text-2); position: relative; text-align: left; width: 100%;
}
.nav-item:hover, .tree-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active, .tree-item.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav-item .label, .tree-item .label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-sep { height: 10px; }

.tree-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 12px 6px 18px; font-size: 13px; color: var(--muted);
}
.tree-head-actions { display: flex; gap: 2px; }
.tree { flex: 1; overflow-y: auto; padding: 0 8px 12px; scrollbar-width: thin; }
.tree-item { height: 34px; gap: 10px; padding-left: 8px; }
.tree-item .chev { width: 22px; height: 22px; display: grid; place-items: center; color: var(--muted); border-radius: 5px; }
.tree-item .chev:hover { background: var(--surface-2); }
.tree-item .chev svg { width: 16px; height: 16px; transition: transform .15s; }
.folder.collapsed .chev svg { transform: rotate(-90deg); }
.folder.collapsed .folder-feeds { display: none; }
.folder-feeds .tree-item { padding-left: 40px; }
.row-actions { display: none; align-items: center; gap: 2px; }
.tree-item:hover .row-actions, .tree-item.menu-open .row-actions { display: flex; }
.tree-item:hover .count, .tree-item.menu-open .count { min-width: 0; }
.mini { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 5px; color: var(--muted); }
.mini svg.i { width: 17px; height: 17px; }
.mini:hover { background: var(--surface-2); color: var(--text); }
.tree-item.menu-open { background: var(--hover); color: var(--text); }
@media (hover: none) { .folder-item .row-actions { display: flex; } }

/* Drag and drop */
.tree-item[draggable="true"] { -webkit-user-drag: element; }
.dragging { opacity: .4; }
.folder.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.folder.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.feed-item.drop-before { box-shadow: inset 0 2px 0 var(--accent); border-radius: 0; }
.feed-item.drop-after { box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.folder-item.drop-into, .loose.drop-into { background: var(--accent-soft); outline: 1px dashed var(--accent); }
.folder-empty { padding-left: 40px; display: none; }
body.dragging-feed .folder-empty { display: block; }
.loose-head { padding: 14px 10px 6px; font-size: 13px; color: var(--muted); }
.loose.is-empty { display: none; min-height: 40px; border-radius: var(--radius); }
body.dragging-feed .loose.is-empty { display: block; }

/* Popover menu */
.menu { position: fixed; z-index: 90; }
.menu-panel {
  position: absolute; min-width: 220px; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.menu > .menu-panel:first-child { position: relative; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 38px; padding: 0 12px;
  border-radius: 8px; color: var(--text); font-size: 14.5px; text-align: left;
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--hover); }
.menu-item svg.i { color: var(--muted); width: 19px; height: 19px; }
.menu-item span:not(.sub-chev) { flex: 1; }
.menu-item .sub-chev { display: grid; }
.menu-item .sub-chev svg.i { width: 16px; height: 16px; }
.menu-item.danger, .menu-item.danger svg.i { color: var(--danger); }
.menu-item:disabled { opacity: .35; cursor: default; }
.menu-sep { height: 1px; background: var(--line); margin: 6px -6px; }

/* Manage feeds */
.manage-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; margin: 0 -4px; }
.manage-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.manage-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.modal .manage-row select { height: 32px; font-size: 13px; padding: 0 8px; max-width: 150px; }
.sm-btn { height: 32px; padding: 0 10px; font-size: 13px; }
.tree-item.has-error .label::after { content: " ⚠"; color: var(--danger); font-size: 12px; }
.tree-empty { padding: 8px 12px; color: var(--faint); font-size: 13px; }

.fav {
  width: 18px; height: 18px; border-radius: 4px; flex: none; object-fit: cover;
  display: inline-grid; place-items: center; background: var(--surface-2);
  font-size: 10px; font-weight: 700; color: var(--text-2); text-transform: uppercase;
}

.sidebar-foot {
  border-top: 1px solid var(--line); padding: 8px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sync { font-size: 12px; color: var(--faint); display: flex; align-items: center; gap: 6px; min-width: 0; }
.sync .spin { width: 12px; height: 12px; border: 2px solid var(--faint); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.foot-actions { display: flex; gap: 2px; }

.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border-radius: var(--radius); color: var(--muted);
}
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon-btn.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.topbar { display: none; }
.scrim { display: none; }

/* ---------- Main page ---------- */
.main { min-width: 0; }
.page { max-width: 980px; padding: 36px 48px 80px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-head h1 { font-size: 34px; line-height: 1.15; letter-spacing: -.025em; margin: 0; font-weight: 700; }
.page-head .sub { margin: 8px 0 0; color: var(--muted); font-size: 16px; }
.page-head .sub a { color: var(--text-2); }
.page-head .sub a:hover { color: var(--accent); }
.head-actions { display: flex; align-items: center; gap: 2px; padding-top: 4px; flex: none; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2px; margin-right: 6px; }
.seg button { width: 32px; height: 28px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); }
.seg svg.i { width: 17px; height: 17px; }

.search-box {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; height: 44px; max-width: 520px;
}
.search-box input { flex: 1; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: 16px; }
.search-box svg { color: var(--muted); }

.section-title { font-size: 15px; color: var(--muted); margin: 34px 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 6px; }
.section-title a:hover { color: var(--text); }

.new-pill {
  position: sticky; top: 14px; z-index: 5; width: max-content; margin: 0 auto 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13.5px;
  padding: 7px 16px; border-radius: 999px; cursor: pointer; box-shadow: var(--shadow);
}

/* Cards */
.card {
  display: grid; grid-template-columns: 200px 1fr; gap: 26px;
  padding: 18px 14px; margin: 0 -14px; border-radius: 12px; cursor: pointer; position: relative;
}
.card:hover { background: var(--hover); }
.card.is-sel { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
.thumb { width: 200px; height: 120px; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .fav { width: 36px; height: 36px; font-size: 16px; border-radius: 8px; }
.card-body { min-width: 0; padding-right: 36px; }
.card h3 { font-size: 21px; line-height: 1.25; letter-spacing: -.015em; margin: 0 0 8px; font-weight: 650; }
.card .meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin-bottom: 7px; flex-wrap: wrap; }
.card .meta .fav { width: 16px; height: 16px; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card.is-read h3 { color: var(--muted); font-weight: 500; }
.card.is-read .thumb { opacity: .55; }
.save-btn { position: absolute; top: 16px; right: 10px; opacity: 0; }
.card:hover .save-btn, .save-btn.on, .row:hover .save-btn { opacity: 1; }
.save-btn.on svg { fill: var(--accent); stroke: var(--accent); }

/* Title-only rows */
.row {
  display: grid; grid-template-columns: 30px 170px 1fr 56px; align-items: center; gap: 10px;
  height: 44px; padding: 0 8px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 15px;
}
.row:first-child { border-top: 1px solid var(--line); }
.row:hover { background: var(--hover); }
.row.is-sel { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
.row .save-btn { position: static; opacity: .6; width: 28px; height: 28px; }
.row-src { display: flex; align-items: center; gap: 8px; color: var(--muted); min-width: 0; }
.row-src span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-src .fav { width: 16px; height: 16px; }
.row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.row-title strong { color: var(--text); font-weight: 500; margin-right: 8px; }
.row.is-read .row-title strong { color: var(--muted); font-weight: 400; }
.row time { text-align: right; color: var(--faint); font-size: 13.5px; font-variant-numeric: tabular-nums; }

.list-foot { padding: 26px 0; text-align: center; color: var(--faint); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 500;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .6; cursor: default; }

.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty .big { font-size: 20px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.empty svg.i { width: 40px; height: 40px; color: var(--accent); margin-bottom: 12px; }

/* Welcome */
.welcome { max-width: 680px; padding-top: 40px; }
.welcome .brand-mark { width: 58px; height: 48px; margin-bottom: 18px; }
.welcome h1 { font-size: 44px; letter-spacing: -.03em; margin: 0; }
.welcome .lead { font-size: 20px; color: var(--muted); margin: 6px 0 36px; }
.welcome-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.welcome-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.welcome-card h3 { margin: 0; font-size: 17px; }
.welcome-card p { margin: 0 0 8px; color: var(--muted); font-size: 14px; flex: 1; }

/* ---------- Reader ---------- */
.reader {
  position: fixed; top: 0; right: 0; bottom: 0; left: var(--sidebar-w); z-index: 40;
  background: var(--bg); display: flex; flex-direction: column;
  animation: slideIn .18s ease-out;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.reader-bar {
  display: flex; align-items: center; gap: 4px; height: 58px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: var(--sidebar); flex: none;
}
.reader-bar .spacer { flex: 1; }
.reader-bar .pos { color: var(--faint); font-size: 13px; margin: 0 8px; font-variant-numeric: tabular-nums; }
.reader-scroll { flex: 1; overflow-y: auto; position: relative; }
.reader-article { max-width: 760px; margin: 0 auto; padding: 48px 32px 100px; }
.reader-article h1 { font-size: 36px; line-height: 1.18; letter-spacing: -.025em; margin: 0 0 12px; }
.reader-article h1 a:hover { color: var(--accent); }
.reader-meta { color: var(--muted); font-size: 15px; margin-bottom: 30px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reader-meta .fav { width: 18px; height: 18px; }
.reader-meta a:hover { color: var(--text); }
.hero { width: 100%; border-radius: 10px; margin-bottom: 24px; display: block; }
.reader-content { font-size: 18px; line-height: 1.7; color: var(--text-2); overflow-wrap: break-word; }
.reader-content > :first-child { margin-top: 0; }
.reader-content img, .reader-content video, .reader-content iframe { max-width: 100%; height: auto; border-radius: 8px; }
.reader-content iframe { aspect-ratio: 16 / 9; width: 100%; height: auto; border: 0; }
.reader-content figure { margin: 24px 0; }
.reader-content figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; }
.reader-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.reader-content h1, .reader-content h2, .reader-content h3, .reader-content h4 { color: var(--text); line-height: 1.3; margin: 1.6em 0 .6em; }
.reader-content blockquote { margin: 1.4em 0; padding-left: 18px; border-left: 3px solid var(--accent); color: var(--muted); }
.reader-content pre { background: var(--surface); padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 14px; }
.reader-content code { font-size: .9em; }
.reader-content table { border-collapse: collapse; display: block; overflow-x: auto; }
.reader-content td, .reader-content th { border: 1px solid var(--line); padding: 6px 10px; }
.visit { margin-top: 36px; width: 100%; height: 50px; font-size: 16px; }
.snippet-note { margin-top: 28px; color: var(--faint); font-size: 14px; }
.reader-next {
  position: fixed; right: 18px; top: 50%; width: 44px; height: 44px; transform: translateY(-50%);
}
.reader-prev {
  position: fixed; left: calc(var(--sidebar-w) + 18px); top: 50%; width: 44px; height: 44px; transform: translateY(-50%);
}
.reader-loading { padding: 80px; text-align: center; color: var(--faint); }

/* ---------- Modal & toast ---------- */
.modal {
  width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); padding: 0; box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0, 0, 0, .55); }
.modal form, .modal .modal-inner { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.modal p { margin: 0; color: var(--muted); font-size: 14px; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.modal input[type=text], .modal input[type=url], .modal select {
  height: 42px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg);
  color: var(--text); padding: 0 12px; font: inherit; font-size: 15px; outline: none;
}
.modal input:focus, .modal select:focus { border-color: var(--accent); }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.modal .actions .left { margin-right: auto; }
.modal .error { color: var(--danger); font-size: 14px; }
.modal .info { font-size: 13px; color: var(--faint); word-break: break-all; }
.modal ol { margin: 0; padding-left: 20px; color: var(--text-2); font-size: 14px; line-height: 1.7; }
.modal code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.dropzone {
  border: 1.5px dashed var(--line); border-radius: 10px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer;
}
.dropzone.over, .dropzone:hover { border-color: var(--accent); color: var(--text); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 14px; }
.keys kbd {
  font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 4px 7px; min-width: 26px; text-align: center; display: inline-block; color: var(--text);
}

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 10px; font-size: 14px; font-weight: 500;
  transition: all .2s; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(var(--sidebar-w), 86vw); z-index: 60;
    transform: translateX(-100%); transition: transform .2s;
  }
  body.sidebar-open .sidebar { transform: none; opacity: 1; }
  body.sidebar-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; }
  .topbar {
    display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 10px;
    border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 10;
  }
  .topbar-title { display: flex; align-items: center; gap: 6px; font-weight: 800; letter-spacing: -.03em; }
  .topbar-title .brand-mark { width: 24px; height: 20px; }
  .page { padding: 22px 16px 60px; }
  .page-head { flex-direction: column; gap: 12px; }
  .page-head h1 { font-size: 28px; }
  .card { grid-template-columns: 1fr 96px; gap: 14px; margin: 0 -8px; padding: 14px 8px; }
  .thumb { width: 96px; height: 72px; order: 2; }
  .card-body { padding-right: 0; }
  .card h3 { font-size: 17px; }
  .card p { -webkit-line-clamp: 2; font-size: 14px; }
  .card .meta .author { display: none; }
  .save-btn { display: none; }
  .row { grid-template-columns: 1fr 44px; height: auto; padding: 10px 4px; }
  .row .save-btn, .row-src { display: none; }
  .row-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .reader { left: 0; }
  .reader-article { padding: 26px 18px 80px; }
  .reader-article h1 { font-size: 27px; }
  .reader-content { font-size: 17px; }
  .reader-next, .reader-prev { display: none; }
  .welcome-grid { grid-template-columns: 1fr; }
}

.logout-form { display: contents; }
