/* X-style layout: one feed column on phones, side nav + rail on wider screens. */
:root {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-hover: rgba(15, 20, 25, 0.03);
  --bg-soft: #f7f9f9;
  --text: #0f1419;
  --text-2: #536471;
  --border: #eff3f4;
  --accent: #1d9bf0;
  --accent-soft: rgba(29, 155, 240, 0.1);
  --danger: #f4212e;
  --warn: #ffad1f;
  --ok: #00ba7c;
  --explore: #7856ff;
  --overlay: rgba(0, 0, 0, 0.4);
  --header-bg: rgba(255, 255, 255, 0.85);
  --shadow: 0 0 15px rgba(101, 119, 134, 0.2), 0 0 3px 1px rgba(101, 119, 134, 0.15);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --bg-elev: #000000; --bg-hover: rgba(231, 233, 234, 0.03); --bg-soft: #16181c;
    --text: #e7e9ea; --text-2: #71767b; --border: #2f3336; --overlay: rgba(91, 112, 131, 0.4);
    --header-bg: rgba(0, 0, 0, 0.65); --shadow: 0 0 15px rgba(255, 255, 255, 0.2), 0 0 3px 1px rgba(255, 255, 255, 0.15);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --bg-elev: #000000; --bg-hover: rgba(231, 233, 234, 0.03); --bg-soft: #16181c;
  --text: #e7e9ea; --text-2: #71767b; --border: #2f3336; --overlay: rgba(91, 112, 131, 0.4);
  --header-bg: rgba(0, 0, 0, 0.65); --shadow: 0 0 15px rgba(255, 255, 255, 0.2), 0 0 3px 1px rgba(255, 255, 255, 0.15);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow-x: hidden; overscroll-behavior-y: contain;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: var(--text); }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: flex; justify-content: center; min-height: 100vh; }
.main { width: 100%; max-width: 600px; min-width: 0; min-height: 100vh; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.side, .rail { display: none; }
@media (min-width: 700px) {
  .main { border-left: 1px solid var(--border); border-right: 1px solid var(--border); padding-bottom: 40px; }
  .side { display: flex; flex-direction: column; gap: 4px; width: 88px; padding: 8px 12px; position: sticky; top: 0; height: 100vh; align-items: flex-end; }
  .tabbar { display: none !important; }
}
@media (min-width: 1100px) {
  .side { width: 260px; align-items: stretch; }
  .rail { display: block; width: 350px; padding: 12px 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.side .brand { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; }
.side .brand svg { width: 30px; height: 30px; }
.side a { display: flex; align-items: center; gap: 18px; padding: 12px; border-radius: 999px; color: var(--text); font-size: 20px; width: max-content; }
.side a:hover { background: var(--bg-hover); }
.side a.on { font-weight: 700; }
.side a svg.i { width: 26px; height: 26px; }
.side a span { display: none; }
@media (min-width: 1100px) { .side a span { display: inline; } .side a { padding: 12px 24px 12px 12px; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 7px; color: var(--text-2); font-size: 10px; }
.tabbar a.on { color: var(--text); }
.tabbar a.on svg.i { stroke-width: 2.4; }
.tabbar svg.i { width: 26px; height: 26px; }

/* ---------- header ---------- */
.head {
  position: sticky; top: 0; z-index: 20; background: var(--header-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.head .title { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 53px; }
.head .title h1 { font-size: 20px; margin: 0; font-weight: 800; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .title .back { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; margin-left: -8px; }
.head .title .back:hover { background: var(--bg-hover); }
.iconbtn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--text); }
.iconbtn:hover { background: var(--bg-hover); }
.tabs { display: flex; }
.tabs button { flex: 1; height: 53px; position: relative; color: var(--text-2); font-weight: 500; }
.tabs button:hover { background: var(--bg-hover); }
.tabs button.on { color: var(--text); font-weight: 700; }
.tabs button.on::after { content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 56px; height: 4px; border-radius: 4px; background: var(--accent); }
.infobar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.infobar button { color: var(--accent); }
.infobar .sp { flex: 1; }

/* ---------- pull to refresh & new pill ---------- */
.ptr { height: 0; overflow: hidden; display: grid; place-items: center; color: var(--text-2); transition: height .2s; }
.ptr svg { width: 22px; height: 22px; transition: transform .2s; }
.ptr.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.newpill {
  position: fixed; top: calc(118px + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -12px); z-index: 25;
  background: var(--accent); color: #fff; font-weight: 700; padding: 8px 18px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(29, 155, 240, 0.4); opacity: 0; pointer-events: none; transition: .2s; display: flex; gap: 6px; align-items: center;
}
.newpill.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
@media (min-width: 700px) { .newpill { left: calc(50% + (88px - 350px) / 2 * 0); } }

/* ---------- card ---------- */
.card { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.card:hover { background: var(--bg-hover); }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px; user-select: none; }
.body { flex: 1; min-width: 0; }
.meta { display: flex; align-items: center; gap: 4px; color: var(--text-2); white-space: nowrap; min-width: 0; }
.meta .name { color: var(--text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.meta .handle { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.meta .sp { flex: 1; }
.badge { font-size: 12px; padding: 1px 7px; border-radius: 999px; font-weight: 600; flex: none; }
.badge.explore { color: var(--explore); background: rgba(120, 86, 255, 0.12); }
.badge.score { color: var(--text-2); background: var(--bg-soft); font-variant-numeric: tabular-nums; }
.ctitle { margin: 2px 0 2px; font-size: 15px; font-weight: 600; line-height: 1.35; word-break: break-word; }
.csum { margin: 0; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.cimg { margin-top: 10px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--bg-soft); aspect-ratio: 16 / 9; }
.cimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.extra { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; color: var(--text-2); font-size: 13px; }
.dups { color: var(--accent); }
.duplist { margin-top: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; font-size: 13px; }
.duplist a { display: block; padding: 3px 0; }
.actions { display: flex; justify-content: space-between; max-width: 425px; margin: 8px 0 -6px -8px; }
.act { display: flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 13px; padding: 6px 8px; border-radius: 999px; transition: .15s; }
.act:hover { color: var(--accent); background: var(--accent-soft); }
.act.hide:hover { color: var(--danger); background: rgba(244, 33, 46, 0.1); }
.act.on { color: var(--accent); }
.act.on svg.i { fill: currentColor; }
.hidden-note { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.hidden-note .sp { flex: 1; }
.hidden-note button { color: var(--accent); font-weight: 600; }

.empty { padding: 48px 32px; text-align: center; color: var(--text-2); }
.empty h2 { color: var(--text); font-size: 26px; margin: 0 0 8px; font-weight: 800; }
.loadmore { padding: 24px; display: grid; place-items: center; color: var(--text-2); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

/* ---------- skeleton ---------- */
.sk { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sk i { display: block; background: var(--bg-soft); border-radius: 8px; }
.sk .a { width: 40px; height: 40px; border-radius: 50%; }

/* ---------- sheet (bottom on phone, centered dialog on desktop) ---------- */
.scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-height: 85vh; overflow-y: auto; background: var(--bg-elev); border-radius: 16px 16px 0 0;
  padding: 8px 0 calc(16px + env(safe-area-inset-bottom)); animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { max-width: 520px; border-radius: 16px; box-shadow: var(--shadow); } }
.sheet .grab { width: 36px; height: 4px; border-radius: 4px; background: var(--border); margin: 4px auto 8px; }
.sheet h3 { margin: 4px 20px 12px; font-size: 20px; font-weight: 800; }
.sheet .item { display: flex; gap: 14px; align-items: center; width: 100%; padding: 14px 20px; text-align: left; font-weight: 600; }
.sheet .item:hover { background: var(--bg-hover); }
.sheet .item small { display: block; color: var(--text-2); font-weight: 400; }
.sheet .cancel { display: block; margin: 12px 20px 0; width: calc(100% - 40px); padding: 12px; border: 1px solid var(--border); border-radius: 999px; font-weight: 700; }
.why { padding: 0 20px; }
.why .row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.why .row .l { flex: 1; min-width: 0; }
.why .row .l small { display: block; color: var(--text-2); }
.why .pts { font-weight: 700; font-variant-numeric: tabular-nums; }
.why .pos { color: var(--ok); }
.why .neg { color: var(--danger); }
.why .total { font-size: 17px; border-bottom: 0; }
.why .foot { color: var(--text-2); font-size: 13px; padding-top: 4px; }

/* ---------- forms (rules / settings) ---------- */
.sec { padding: 16px; border-bottom: 1px solid var(--border); }
.sec h2 { font-size: 20px; font-weight: 800; margin: 0 0 4px; }
.sec .hint { color: var(--text-2); font-size: 13px; margin: 0 0 12px; }
.box { border: 1px solid var(--border); border-radius: 16px; padding: 12px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label, .lbl { font-size: 13px; color: var(--text-2); }
.input { width: 100%; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); outline: none; font-size: 16px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
textarea.input { min-height: 320px; font: 13px/1.5 ui-monospace, "SF Mono", Menlo, monospace; resize: vertical; }
.rowf { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rowf > * { min-width: 0; }
.grow { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.chip button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; }
.chip button:hover { background: var(--accent-soft); }
.chip.mute { background: rgba(244, 33, 46, 0.1); color: var(--danger); }
.chipin { border: 0; background: transparent; outline: none; min-width: 90px; flex: 1; padding: 6px 2px; font-size: 16px; }
.slider { display: flex; align-items: center; gap: 10px; }
.slider input[type=range] { flex: 1; accent-color: var(--accent); min-width: 0; }
.slider output { min-width: 44px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 999px; font-weight: 700; border: 1px solid var(--border); min-height: 36px; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { opacity: .9; }
.btn.blue { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: rgba(244, 33, 46, 0.4); }
.btn.small { padding: 5px 12px; min-height: 30px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.savebar {
  position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 15; display: flex; gap: 10px; align-items: center;
  padding: 12px 16px; background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border);
}
@media (min-width: 700px) { .savebar { bottom: 0; } }
.savebar .sp { flex: 1; color: var(--text-2); font-size: 13px; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

.src { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.src:last-child { border-bottom: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 6px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.red { background: var(--danger); } .dot.pending { background: var(--text-2); }
.src .info { flex: 1; min-width: 0; }
.src .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src .info small { display: block; color: var(--text-2); font-size: 13px; word-break: break-all; }
.src .info .err { color: var(--danger); }
.src .tools { display: flex; gap: 2px; align-items: flex-start; }
.star.on { color: var(--warn); }
.star.on svg.i { fill: currentColor; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; word-break: break-all; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.seg button { padding: 7px 14px; font-size: 14px; }
.seg button.on { background: var(--accent); color: #fff; }
.ver { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.ver .grow small { color: var(--text-2); display: block; }

/* ---------- login ---------- */
.login { max-width: 400px; margin: 0 auto; padding: 18vh 24px 24px; }
.login h1 { font-size: 31px; font-weight: 800; margin: 24px 0 8px; }
.login p { color: var(--text-2); }

/* ---------- rail ---------- */
.rail .box h3 { margin: 0 0 8px; font-size: 20px; font-weight: 800; }
.rail .src { padding: 8px 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 60;
  background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none;
  max-width: calc(100vw - 32px); text-align: center; font-size: 14px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }
