@font-face { font-family: Inter; src: url("../fonts/InterVariable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
  --page: #1f2a3a; --page2: #18212e; --card: #3b4f6b; --card-hover: #43597a;
  --accent: #93c5fd; --list: #dbe4f0; --navy: #1f2a3a; --selected: #b8c9e0; --hover: #c9d6e8;
  --counts: #2f4a70; --toolbar: #263347; --text: #f4f7fb; --muted: #aab8cb; --danger: #e53935;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--page); color: var(--text); font: 15px/1.4 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
#app { display: flex; flex-direction: column; height: 100%; }
#top { display: flex; align-items: center; gap: 12px; padding: calc(8px + var(--safe-top)) 14px 8px; background: var(--toolbar); border-bottom: 1px solid var(--page); }
#top h1 { font-size: 16px; font-weight: 700; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status { color: var(--muted); font-size: 12px; }
.tog { font-size: 13px; color: #e8eef6; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ibtn { background: #33445e; color: #e8eef6; border: 1px solid #4a6185; border-radius: 8px; width: 36px; height: 34px; font-size: 18px; cursor: pointer; }
.ibtn:hover { background: #3d5170; }
#menuBtn { display: none; }
#body { flex: 1; display: flex; min-height: 0; position: relative; }
#side { width: 240px; flex: none; background: var(--list); color: var(--navy); overflow-y: auto; padding: 8px 6px; }
.cat { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 500; user-select: none; }
.cat:hover { background: var(--hover); }
.cat.sel { background: var(--selected); }
.cat .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--navy); }
.cat .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat .n { color: var(--counts); font-weight: 700; font-size: 13px; }
.cat.zero .name { font-weight: 400; opacity: .7; }
.cat.zero .n { visibility: hidden; }
#scrim { display: none; }
#list { flex: 1; overflow-y: auto; padding: 14px; background: linear-gradient(180deg, var(--page) 0%, var(--page2) 100%); outline: none; }
.card { --cc: #4a6185; position: relative; display: flex; gap: 14px; background: var(--card); border: 3px solid var(--cc); border-radius: 12px; padding: 12px 14px; margin: 0 auto 10px; max-width: 900px; cursor: pointer; scroll-margin: 10px; }
.card:hover { background: var(--card-hover); }
.card.active { border-color: #fff; }
.card.read { opacity: .55; }
.thumb { width: 150px; height: 100px; flex: none; border-radius: 8px; object-fit: cover; background: #2c3c54; }
.cbody { flex: 1; min-width: 0; }
.ctitle { display: block; color: #fff; font-weight: 700; font-size: 16px; line-height: 1.3; text-decoration: none; margin-bottom: 4px; }
.card.read .ctitle { font-weight: 500; }
.ctitle:hover { text-decoration: underline; }
.meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.meta .src { color: var(--cc); font-weight: 600; filter: brightness(1.15); }
.sum { color: #dbe4ee; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.acts { display: flex; flex-direction: column; gap: 6px; }
.acts button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid #4a6185; background: #33445e; color: #e8eef6; cursor: pointer; font-size: 15px; }
.acts button:hover { background: #4a6185; }
.empty, .more { text-align: center; color: var(--muted); padding: 30px; }
.more button { background: #33445e; color: #fff; border: 1px solid #4a6185; padding: 8px 18px; border-radius: 8px; cursor: pointer; font: inherit; }
#hint { padding: 5px 14px calc(5px + var(--safe-bottom)); background: var(--toolbar); color: var(--muted); font-size: 12px; text-align: center; }
#toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: #0f1722; color: #fff; padding: 8px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
#toast.on { opacity: 1; }
#toast.bad { background: var(--danger); }
#login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--page); padding: 20px; }
#loginForm { width: min(420px, 100%); background: var(--card); padding: 24px; border-radius: 14px; display: flex; flex-direction: column; gap: 12px; }
#loginForm h2 { margin: 0; }
#loginForm p { margin: 0; color: var(--muted); font-size: 14px; }
#loginForm label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#loginForm input { padding: 10px; border-radius: 8px; border: 1px solid #4a6185; background: #fff; color: var(--navy); font: 16px Inter, sans-serif; }
#loginForm button { padding: 11px; border-radius: 8px; border: 0; background: var(--accent); color: var(--navy); font: 600 15px Inter, sans-serif; cursor: pointer; }
#loginForm button.ghost { background: transparent; color: var(--muted); border: 1px solid #4a6185; }
.err { color: #ffb4b0 !important; min-height: 1em; }

@media (max-width: 760px) {
  #menuBtn { display: inline-block; }
  #status, #hint { display: none; }
  #top { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .tog { font-size: 12px; }
  #side { position: absolute; z-index: 20; top: 0; bottom: 0; left: 0; width: min(80%, 300px); transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.4); }
  #body.menu #side { transform: none; }
  #body.menu #scrim { display: block; position: absolute; inset: 0; z-index: 10; background: rgba(0,0,0,.45); }
  #list { padding: 10px; }
  .card { flex-wrap: wrap; padding: 10px 12px; gap: 10px; }
  .thumb { width: 100%; height: 170px; order: -1; }
  .cbody { flex-basis: calc(100% - 50px); }
  .acts { flex-direction: row; flex: none; }
  .acts button { width: 44px; height: 38px; }
  .card { margin-bottom: 12px; }
  .acts { width: 100%; justify-content: flex-end; }
  .cbody { flex-basis: 100%; }
}

/* ---- step 3: views, category bars, deleted view ---- */
#side { padding: 0; display: flex; flex-direction: column; }
#views { padding: 10px 8px 6px; border-bottom: 1px solid #b8c9e0; display: flex; flex-direction: column; gap: 6px; flex: none; }
#catrows { padding: 8px 6px; overflow-y: auto; flex: 1; }
.seg { display: flex; border: 1px solid #8fa5c2; border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; padding: 7px 4px; border: 0; background: #eef3f9; color: var(--navy); font: 600 13px Inter, sans-serif; cursor: pointer; }
.seg button.on { background: #2f4a70; color: #fff; }
#views .wide { padding: 7px; border-radius: 8px; border: 1px solid #8fa5c2; background: #eef3f9; color: var(--navy); font: 600 13px Inter, sans-serif; cursor: pointer; }
#views .wide.on { background: #2f4a70; color: #fff; }
.sec { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; max-width: 900px; margin: 14px auto 10px; padding: 8px 12px; border-radius: 10px; background: var(--cc); color: #0f1a2b; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.sec:first-child { margin-top: 0; }
.sec .sname { flex: 1; font-size: 15px; }
.sec .scount { font-weight: 600; font-size: 13px; opacity: .8; }
.sec .sdel { border: 1px solid rgba(15,26,43,.45); background: rgba(255,255,255,.35); color: #0f1a2b; border-radius: 8px; padding: 5px 10px; font: 600 12px Inter, sans-serif; cursor: pointer; }
.sec .sdel:hover { background: rgba(255,255,255,.6); }
.sec .sdel.armed { background: var(--danger); color: #fff; border-color: #fff; }
.also { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.card .acts .brestore { width: auto; padding: 0 12px; }
#busy { display: none; }
@media (max-width: 760px) {
  .sec { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .sec .sdel { padding: 8px 12px; }
}
