:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --fg: #0f1419;
  --muted: #5b6672;
  --faint: #8b96a1;
  --line: #e4e8ec;
  --accent: #1d9bf0;
  --accent-ink: #ffffff;
  --accent-soft: #e8f5fe;
  --good: #16a34a;
  --good-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 20, 25, 0.04), 0 4px 16px rgba(15, 20, 25, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d10;
    --panel: #14171b;
    --panel-2: #1b1f24;
    --fg: #e7e9ea;
    --muted: #9aa4ae;
    --faint: #6e7781;
    --line: #262b31;
    --accent-soft: #10273a;
    --good-soft: #10261a;
    --warn-soft: #2b2012;
    --bad-soft: #2d1414;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 0 0 4px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--fg); color: var(--bg); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--fg); font-weight: 500; }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 20px; height: 20px; flex: none; }
.nav .count { margin-left: auto; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; border-radius: 99px; padding: 0 7px; min-width: 20px; text-align: center; }
.side .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; }
.side .me .who { min-width: 0; flex: 1; }
.side .me .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { padding: 32px 40px 80px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }

/* mobile */
.topbar, .tabbar { display: none; }
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 76px 16px 96px; }
  .topbar { display: flex; position: fixed; inset: 0 0 auto 0; height: 56px; align-items: center; justify-content: space-between; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 20; }
  .tabbar { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; inset: auto 0 0 0; background: var(--panel); border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; color: var(--muted); position: relative; }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .count { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; border-radius: 99px; padding: 0 5px; }
}

/* building blocks */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card, .stack > .card, .posts > .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.spacer { flex: 1; }

.btn { font: inherit; font-weight: 600; font-size: 14px; border: 1px solid transparent; border-radius: 99px; padding: 8px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; background: var(--panel-2); color: var(--fg); }
.btn:hover { filter: brightness(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--fg); color: var(--bg); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.lg { padding: 12px 22px; font-size: 15px; }
.btn svg { width: 16px; height: 16px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=time], input[type=datetime-local], input[type=number], select, textarea {
  font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; border-radius: 99px; padding: 2px 9px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

.seg { display: inline-flex; background: var(--panel-2); border-radius: 99px; padding: 3px; gap: 2px; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 5px 13px; border-radius: 99px; cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--fg); box-shadow: var(--shadow); }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: 0.15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(18px); }

.choice { border: 1.5px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 3px; }

.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button { font: inherit; font-weight: 600; font-size: 13px; width: 46px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; }
.days button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel-2); border-radius: 99px; padding: 4px 6px 4px 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 99px; }
.chip button:hover { background: var(--line); }

/* home */
.stat { padding: 16px 18px; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -0.01em; }
.stat .s { font-size: 13px; color: var(--muted); }
.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress div { height: 100%; background: var(--good); border-radius: 99px; transition: width 0.3s; }
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.tick { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; color: transparent; font-size: 14px; font-weight: 800; }
.steps li.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.steps li.done .t { color: var(--muted); }
.steps .t { font-weight: 600; }
.steps .body { flex: 1; min-width: 0; }

/* post preview, drawn like X */
.posts { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
@media (max-width: 420px) { .posts { grid-template-columns: 1fr; } }
.tweet { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.tweet .tw-body { padding: 14px 16px 10px; display: grid; grid-template-columns: 40px 1fr; gap: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--panel-2); object-fit: cover; display: block; }
.avatar.sm { width: 32px; height: 32px; }
.tw-head { display: flex; gap: 4px; align-items: baseline; min-width: 0; }
.tw-head b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-head span { color: var(--muted); white-space: nowrap; }
.tw-text { white-space: pre-wrap; word-wrap: break-word; margin-top: 2px; cursor: text; border-radius: 6px; }
.tw-text:hover { background: var(--panel-2); }
.tw-edit { margin-top: 4px; min-height: 110px; }
.tw-img { margin-top: 10px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 16 / 9; background: var(--panel-2); position: relative; }
.tw-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tw-img .tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; opacity: 0.9; }
.tw-img .tools button { border: 0; cursor: pointer; background: rgba(15, 20, 25, 0.75); color: #fff; border-radius: 99px; height: 30px; padding: 0 11px; display: inline-flex; align-items: center; gap: 6px; font: 600 12px/1 inherit; font-family: inherit; backdrop-filter: blur(4px); }
.tw-img .tools button:hover { background: rgba(15, 20, 25, 0.9); }
.tw-img .tools svg { width: 14px; height: 14px; }
.tw-img .over { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); color: #fff; font-weight: 600; }
.tw-noimg { margin-top: 10px; border: 1.5px dashed var(--line); border-radius: 14px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.tw-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 0 16px 10px 66px; }
.tw-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel-2); margin-top: auto; }
.tw-confirm { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--accent-soft); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.count-ok { color: var(--muted); }
.count-bad { color: var(--bad); font-weight: 700; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 600; font-size: 14px; border: 0; background: transparent; color: var(--muted); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--fg); border-bottom-color: var(--accent); }
.tabs .n { font-size: 12px; background: var(--panel-2); border-radius: 99px; padding: 0 7px; margin-left: 6px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 0; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.notice { border-radius: 12px; padding: 12px 14px; background: var(--accent-soft); font-size: 14px; }
.notice.warn { background: var(--warn-soft); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
@media (max-width: 880px) { .toasts { left: 16px; right: 16px; bottom: 80px; } }
.toast { background: var(--fg); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 500; box-shadow: 0 8px 30px rgba(0,0,0,.2); max-width: 440px; animation: up 0.2s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* sign in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin .box { max-width: 460px; width: 100%; text-align: center; }
.signin .brand-mark { width: 52px; height: 52px; font-size: 24px; border-radius: 14px; margin: 0 auto 18px; }
.signin h1 { font-size: 28px; }
.signin .how { text-align: left; margin: 26px 0; display: grid; gap: 12px; }
.signin .how div { display: flex; gap: 12px; align-items: flex-start; }
.signin .how b { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; font-size: 13px; }

.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--line), var(--panel-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
.notes h4 { margin: 14px 0 4px; font-size: 14px; }
.notes ul { margin: 0; padding-left: 18px; }
.notes li { margin: 2px 0; }
kbd { font: 12px ui-monospace, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
