:root {
  --bg: #000;
  --bg-hover: #080808;
  --bg-raised: #16181c;
  --line: #2f3336;
  --text: #e7e9ea;
  --muted: #71767b;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --green: #00ba7c;
  --red: #f4212e;
  --orange: #ff7a00;
  --substack: #ff6719;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); }

/* ---------- layout ---------- */
.column {
  max-width: 600px;
  min-height: 100vh;
  margin: 0 auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
@media (max-width: 620px) { .column { border: 0; } }

.top {
  position: sticky; top: 0; z-index: 10;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 4px; }
.title { font-size: 20px; font-weight: 800; margin: 0; }
.who {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; font-size: 14px; font-weight: 600;
}
.who:hover { background: var(--bg-raised); }

.tabs { display: flex; }
.tab {
  flex: 1; background: none; border: 0; padding: 14px 0 0; color: var(--muted); font-weight: 500;
  display: flex; flex-direction: column; align-items: center;
}
.tab::after { content: ""; display: block; height: 4px; width: 0; border-radius: 2px; background: var(--accent); margin-top: 12px; }
.tab:hover { background: rgba(231, 233, 234, .06); }
.tab.on { color: var(--text); font-weight: 700; }
.tab.on::after { width: 56px; }

.panel { padding-bottom: 80px; }

/* ---------- controls ---------- */
.btn {
  border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 700;
  background: var(--text); color: #0f1419;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--text); }
.btn.big { padding: 12px 24px; font-size: 17px; width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: none; font-size: 20px; color: var(--accent);
}
.icon-btn:hover { background: rgba(29, 155, 240, .1); }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 14px; border-radius: 999px; color: var(--muted); font-size: 14px; font-weight: 600; }
.seg button.on { background: var(--bg-raised); color: var(--text); }

input[type=text], input:not([type]) {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text);
  padding: 12px; outline: none; width: 100%;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card .logo { font-size: 44px; }
.login-card h1 { font-size: 31px; margin: 8px 0; }
.login-card form { display: grid; gap: 12px; margin: 24px 0 12px; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- feed ---------- */
.feed-tools { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); }

.notice { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.notice.warn { color: var(--orange); }
.notice.bad { color: var(--red); }

.person-head {
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg-raised);
  font-weight: 700; font-size: 14px; display: flex; gap: 8px; align-items: center;
}
.person-head img { width: 20px; height: 20px; border-radius: 50%; }

.card { border-bottom: 1px solid var(--line); transition: background .15s; }
.card:hover { background: var(--bg-hover); }
.post { display: flex; gap: 12px; padding: 12px 16px; }
.card .post + .post { padding-top: 0; }
.avatar-col { flex: 0 0 40px; display: flex; flex-direction: column; align-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-raised); object-fit: cover; }
.avatar.square { border-radius: 8px; }
.thread-line { flex: 1; width: 2px; background: var(--line); margin-top: 4px; min-height: 12px; }
.body { flex: 1; min-width: 0; }
.context { color: var(--muted); font-size: 13px; font-weight: 700; margin: -2px 0 2px; }
.head { display: flex; gap: 4px; align-items: baseline; white-space: nowrap; overflow: hidden; }
.head .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.head .handle, .head .time { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.head .time { flex-shrink: 0; }
.badge { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--substack); color: #fff; align-self: center; }
.text { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; margin-top: 2px; }
.text .mention, .text .tag { color: var(--accent); }
.article-title { font-weight: 800; font-size: 17px; margin: 4px 0; }

.media { margin-top: 12px; display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.media.n2, .media.n4 { grid-template-columns: 1fr 1fr; }
.media.n3 { grid-template-columns: 1fr 1fr; }
.media.n3 > :first-child { grid-row: span 2; }
.media .m { position: relative; display: block; background: var(--bg-raised); }
.media img { display: block; width: 100%; height: 100%; max-height: 510px; object-fit: cover; }
.media.n1 img { max-height: 510px; object-fit: contain; background: #000; }
.media:not(.n1) img { aspect-ratio: 16 / 10; }
.media .play {
  position: absolute; inset: 0; margin: auto; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 22px; border: 4px solid #fff;
}

.quote { margin-top: 12px; border: 1px solid var(--line); border-radius: 16px; padding: 12px; font-size: 14px; }
.quote .head { font-size: 14px; }
.quote .avatar { width: 20px; height: 20px; }
.quote .media { margin-top: 8px; }

.foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; color: var(--muted); font-size: 13px; max-width: 425px; }
.foot span { display: inline-flex; gap: 4px; align-items: center; }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--accent); }

.thread-label { color: var(--muted); font-size: 13px; padding: 0 16px 10px 68px; }

/* ---------- end of batch ---------- */
.end {
  padding: 40px 24px 48px; text-align: center; border-bottom: 1px solid var(--line);
}
.end h2 { font-size: 24px; margin: 8px 0; font-weight: 800; }
.end p { color: var(--muted); margin: 0 0 20px; }
.end .big-icon { font-size: 44px; }
.wait-ring { --p: 0; width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1turn), var(--line) 0);
  display: grid; place-items: center; }
.wait-ring span { width: 54px; height: 54px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-weight: 800; }
.skeleton { padding: 16px; display: grid; gap: 12px; }
.skeleton div { height: 72px; border-radius: 12px; background: linear-gradient(90deg, var(--bg-raised), #202327, var(--bg-raised)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- accounts ---------- */
.add { padding: 16px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; }
.add-row .btn { flex-shrink: 0; }

.source { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.source .info { flex: 1; min-width: 0; }
.source .info .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source .info .meta { color: var(--muted); font-size: 13px; }
.source .err { color: var(--red); font-size: 12px; }
.remove { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 700; }
.remove:hover { border-color: var(--red); color: var(--red); background: rgba(244, 33, 46, .1); }

.section { font-size: 20px; font-weight: 800; padding: 20px 16px 8px; margin: 0; }
.filters { padding: 0 16px 16px; display: grid; gap: 2px; }
.filter { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; cursor: pointer; }
.filter input { width: 20px; height: 20px; accent-color: var(--accent); margin: 1px 0 0; flex-shrink: 0; }
.filter b { font-weight: 600; }
.filter .small { display: block; }

/* ---------- budget ---------- */
.b-hero { padding: 20px 16px; border-bottom: 1px solid var(--line); }
.b-big { font-size: 36px; font-weight: 800; }
.b-big small { font-size: 16px; color: var(--muted); font-weight: 500; }
.meter { position: relative; height: 12px; border-radius: 6px; background: var(--bg-raised); margin: 16px 0 6px; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--accent); }
.meter .fill.over { background: var(--orange); }
.meter .fill.capped { background: var(--red); }
.meter .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); }
.meter-legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.b-section { padding: 16px; border-bottom: 1px solid var(--line); }
.b-section h3 { margin: 0 0 10px; font-size: 17px; }
.slider-row { display: flex; gap: 12px; align-items: center; }
.slider-row input[type=range] { flex: 1; accent-color: var(--accent); }
.money-field {
  display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 6px;
  padding: 0 10px; font-weight: 800; color: var(--muted);
}
.money-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.money-field input {
  width: 64px; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-weight: 800;
  padding: 8px 0; text-align: right; -moz-appearance: textfield;
}
.money-field input::-webkit-outer-spin-button, .money-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--bg-raised); border-radius: 12px; padding: 12px; }
.stat .v { font-size: 20px; font-weight: 800; }
.stat .l { font-size: 13px; color: var(--muted); }
table.costs { width: 100%; border-collapse: collapse; font-size: 14px; }
table.costs td { padding: 8px 0; border-bottom: 1px solid var(--line); }
table.costs td.num { text-align: right; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--accent); color: #fff;
  padding: 10px 16px; border-radius: 6px; font-weight: 600; z-index: 50; max-width: calc(100vw - 32px);
}
