:root {
  --bg: #0D1117;
  --surface: #161B22;
  --surface2: #1F2630;
  --border: #2A323D;
  --text: #E6EDF3;
  --muted: #8B949E;
  --accent: #3DDC97;
  --ink: #052E1C;
  --danger: #F87171;
  --warn: #FBBF24;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
h1 { font-size: 1.6rem; margin: 0 0 12px; }
h3 { font-size: 1.15rem; margin: 0 0 4px; word-break: break-word; }
h4 { font-size: 1rem; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
p { margin: 0 0 10px; }
code { background: var(--surface2); padding: 2px 6px; border-radius: 6px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.warn { color: var(--warn); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(13, 17, 23, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; }

.center { text-align: center; padding-top: 18vh; }
.narrow { max-width: 440px; margin: 0 auto; }
.center-row { justify-content: center; }

/* Tabs */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; margin: 12px -16px 16px; padding: 0 16px;
  scrollbar-width: none; position: sticky; top: 53px; z-index: 9; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; min-height: 48px; padding: 0 14px; border: 0; background: none; color: var(--muted);
  font: inherit; font-weight: 600; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.count {
  display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 4px; border-radius: 999px;
  background: var(--accent); color: var(--ink); font-size: .8rem; text-align: center;
}

.intro { color: var(--muted); margin-bottom: 14px; }
.intro b { color: var(--text); }
.list { display: grid; gap: 12px; }
.empty { color: var(--muted); text-align: center; padding: 40px 12px; background: var(--surface); border-radius: var(--radius); }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: grid; gap: 8px;
}
.card.mine { border-color: var(--accent); }
.card.dim { opacity: .55; }
.link { word-break: break-all; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: .82rem; padding: 3px 10px; border-radius: 999px; background: var(--surface2); color: var(--text);
}
.chip.muted { color: var(--muted); }
.chip.warn { color: var(--warn); background: rgba(251, 191, 36, .12); }
.plan { margin: 0; font-weight: 600; }
.hints { margin: 0; color: var(--muted); font-size: .92rem; }
.note { margin: 0; font-size: .92rem; }
.help { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }

.pill { font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.pill.active { background: rgba(61, 220, 151, .15); color: var(--accent); }
.pill.limited { background: rgba(251, 191, 36, .15); color: var(--warn); }
.pill.disconnected { background: rgba(248, 113, 113, .15); color: var(--danger); }
.warnpill { background: rgba(251, 191, 36, .18); color: var(--warn); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.12); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tabs button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.primary { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(248, 113, 113, .5); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn.big { min-height: 52px; width: 100%; }
.btn.huge { min-height: 60px; width: 100%; font-size: 1.1rem; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 10px; }
.row.between { justify-content: space-between; align-items: center; margin-top: 0; }

/* Forms */
input[type="text"], input[type="url"], input[type="number"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
textarea { resize: vertical; }
.field { display: grid; gap: 6px; margin-top: 10px; }
.field > span { font-size: .9rem; color: var(--muted); font-weight: 600; }
.field.inline { margin-top: 0; }
input.cap { width: 120px; }
input.keyword { font-size: 1.25rem; font-weight: 700; letter-spacing: .02em; }
.toggle {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 12px; margin-top: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 600;
}
.toggle.small { font-weight: 400; font-size: .92rem; color: var(--muted); }
.toggle input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }

.error {
  color: var(--danger); background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .3);
  border-radius: 10px; padding: 10px 12px; margin: 8px 0 0; font-size: .92rem;
}

/* Task card */
.taskcard { display: grid; gap: 14px; }
.back { justify-self: start; padding-left: 0; border: 0; }
.step {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
.num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--ink); font-size: .9rem;
}
.account-handle {
  font-size: clamp(1.6rem, 7vw, 2.2rem); font-weight: 800; color: var(--accent);
  background: var(--bg); border: 2px solid var(--accent); border-radius: 12px; padding: 12px 14px;
  text-align: center; word-break: break-all;
}
.url { margin: 8px 0 0; word-break: break-all; }
.warnbox { border-color: rgba(251, 191, 36, .5); }
.warnbox h4 { color: var(--warn); }
.warnbox .btn { margin-top: 10px; }
.dangerbox { margin-top: 14px; border-color: rgba(248, 113, 113, .5); background: var(--surface2); }
.step > .btn:not(.huge) { margin-top: 10px; }
.step .huge { margin-top: 4px; }

/* Waiting / DMs */
.addres { background: var(--surface2); border-radius: 10px; padding: 0 12px; }
.addres summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.addres[open] { padding-bottom: 12px; }
.addres textarea, .addres .btn { margin-top: 8px; }
.dmtext { white-space: pre-wrap; word-break: break-word; background: var(--bg); border-radius: 10px; padding: 10px 12px; margin: 0; }
.atts { margin: 0; padding-left: 20px; }

/* Accounts */
.bar { height: 10px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.bar .fill.high { background: var(--warn); }
.bar .fill.full { background: var(--danger); }

.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 32px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600;
  opacity: 0; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 720px) {
  main { padding: 0 24px 64px; }
  .tabs { margin: 16px 0 20px; padding: 0; }
  .btn.big { width: auto; }
}
