:root {
  --bg: #f6f6f9;
  --surface: #ffffff;
  --surface-2: #f0f0f5;
  --line: #e4e4ec;
  --text: #15161c;
  --muted: #6b6d7a;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #ecebfd;
  --danger: #d23a3a;
  --ok: #138a52;
  --ok-soft: #e3f5ec;
  --warn: #9a6200;
  --warn-soft: #fdf2dc;
  --shadow: 0 1px 2px rgba(20, 20, 40, .05), 0 4px 16px rgba(20, 20, 40, .06);
  --radius: 16px;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1015;
    --surface: #181a21;
    --surface-2: #20222b;
    --line: #2a2d38;
    --text: #f1f1f5;
    --muted: #9a9cab;
    --accent: #8b8cff;
    --accent-text: #0f1015;
    --accent-soft: #23244a;
    --danger: #ff6b6b;
    --ok: #4fd18e;
    --ok-soft: #173426;
    --warn: #f0b44c;
    --warn-soft: #3a2c12;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  overflow-x: hidden;
}
h1, h2, h3 { text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
i[data-lucide], svg.lucide { width: 20px; height: 20px; stroke-width: 2; flex: none; }

/* Screen frame */
.screen {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  max-width: 600px; margin: 0 auto;
}
.screen.has-tabs { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
.screen.has-tabs .body { padding-bottom: 16px; }
.fab-spacer { height: 64px; flex: none; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 6px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.topbar .title { font-weight: 650; font-size: 17px; flex: 1; text-align: center; margin-right: 44px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.body { flex: 1; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.foot {
  position: sticky; bottom: 0; z-index: 4;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(to bottom, transparent, var(--bg) 22px);
}
.lede { color: var(--muted); font-size: 16px; }
.small { font-size: 14px; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: 14px; border: 0;
  background: var(--accent); color: var(--accent-text);
  font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: none;
  width: 100%;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.ghost { background: transparent; color: var(--text); }
.btn.soft { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.small { min-height: 44px; width: auto; padding: 0 16px; font-size: 15px; border-radius: 12px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.icon-btn:active { background: var(--surface-2); }

/* Forms */
label.field { display: flex; flex-direction: column; gap: 6px; }
label.field > span { font-size: 14px; font-weight: 600; }
.input, textarea.input, select.input {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-size: 16px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: none; overflow: hidden; line-height: 1.45; min-height: 96px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }
.count { font-size: 13px; color: var(--muted); text-align: right; }
.count.over { color: var(--danger); font-weight: 600; }

/* Welcome */
.welcome { justify-content: space-between; }
.hero { padding: 48px 20px 0; display: flex; flex-direction: column; gap: 20px; }
.mark {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(140deg, #6d63ff, #4f46e5 55%, #2c8cff);
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 8px 24px rgba(79, 70, 229, .35);
}
.mark svg { width: 28px; height: 28px; }
.hero h1 { font-size: 32px; }
.rooms-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 20px; }
.rooms-preview div {
  background: var(--surface); border-radius: 14px; padding: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; font-weight: 600; font-size: 15px;
}
.rooms-preview svg { color: var(--accent); }
.rooms-preview small { font-weight: 400; color: var(--muted); font-size: 13px; }

/* Steps */
.steps { display: flex; gap: 6px; flex: 1; justify-content: center; margin-right: 44px; }
.steps span { width: 28px; height: 4px; border-radius: 2px; background: var(--line); }
.steps span.on { background: var(--accent); }

/* Logo picker */
.logo-pick { display: flex; align-items: center; gap: 14px; }
.logo-box {
  width: 72px; height: 72px; border-radius: 18px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none;
  border: 1px dashed var(--line); color: var(--muted);
}
.logo-box img { width: 100%; height: 100%; object-fit: cover; }

/* Cards and lists */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.tap { cursor: pointer; text-align: left; width: 100%; border: 0; display: block; }
.tap:active { transform: scale(.99); }
.idea .hook { font-weight: 600; font-size: 16px; }
.idea .notes { color: var(--muted); font-size: 14px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { text-align: center; padding: 36px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); }
.empty .big { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.empty h2 { color: var(--text); }
.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-head h2 { font-size: 15px; color: var(--muted); font-weight: 600; text-transform: none; }

/* Channels */
.ch { display: flex; align-items: center; gap: 12px; }
.ch-icon {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.ch-icon img { width: 22px; height: 22px; filter: invert(1); }
.ch-icon.sm { width: 28px; height: 28px; border-radius: 8px; }
.ch-icon.sm img { width: 15px; height: 15px; }
.ch-youtube { background: #ff0000; }
.ch-facebook { background: #0866ff; }
.ch-instagram { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fd5949 45%, #d6249f 60%, #285aeb 90%); }
.ch-tiktok { background: #000000; }
.ch-linkedin { background: #0a66c2; }
.ch-x { background: #000000; }
@media (prefers-color-scheme: dark) {
  .ch-tiktok, .ch-x { background: #2e2f38; }
}
.ch .grow { flex: 1; min-width: 0; }
.ch .name { font-weight: 600; }
.ch .status { font-size: 13px; color: var(--muted); line-height: 1.35; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }

/* Brand switcher */
.brand-btn {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 10px 4px 4px;
  border: 0; background: transparent; border-radius: 12px; cursor: pointer; min-width: 0; max-width: 100%;
}
.brand-btn:active { background: var(--surface-2); }
.brand-btn .nm { font-weight: 650; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: none; overflow: hidden;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 44px; height: 44px; border-radius: 12px; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tabbar nav { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 600px; margin: 0 auto; height: var(--tabbar); }
.tabbar button {
  border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabbar button.on { color: var(--accent); }
.tabbar svg { width: 23px; height: 23px; }

/* Floating add */
.fab-row { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); margin-top: auto; display: flex; justify-content: flex-end; pointer-events: none; }
.fab {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 20px;
  border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: 16px;
  box-shadow: 0 8px 24px rgba(79, 70, 229, .35); cursor: pointer;
}

/* Video */
video.player { width: 100%; border-radius: 12px; background: #000; display: block; max-height: 60dvh; margin-top: 12px; }
.status-select {
  appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; padding: 0 30px 0 12px; min-height: 36px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--surface-2) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6d7a' stroke-width='3'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 10px center;
}
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.file-pick { position: relative; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

/* Toggle chips for channels in a post */
.pick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; min-height: 84px;
  border-radius: 14px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600;
}
.pick.on { border-color: var(--accent); background: var(--accent-soft); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; cursor: pointer; }
.switch { width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }

/* Calendar list */
.day { font-size: 13px; font-weight: 700; color: var(--muted); padding: 6px 2px 0; }
.post .time { font-weight: 700; font-size: 15px; }
.post .cap { font-size: 14px; color: var(--muted); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post .wait { font-size: 13px; color: var(--warn); margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.post .wait svg { width: 15px; height: 15px; }

/* Bottom sheet */
.scrim { position: fixed; inset: 0; background: rgba(10, 10, 20, .45); z-index: 40; animation: fade .18s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 600px; margin: 0 auto;
  background: var(--surface); border-radius: 22px 22px 0 0; max-height: 88dvh; overflow-y: auto;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { margin-bottom: 6px; }
.sheet .opt { display: flex; align-items: center; gap: 12px; min-height: 56px; width: 100%; border: 0; background: transparent; padding: 6px 4px; border-radius: 12px; cursor: pointer; text-align: left; font-size: 16px; }
.sheet .opt:active { background: var(--surface-2); }
.sheet .opt .grow { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .opt .check { color: var(--accent); }
.sheet hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 10px); transform: translateX(-50%) translateY(-20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }

.done-mark { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: flex; align-items: center; justify-content: center; }
.done-mark svg { width: 36px; height: 36px; }
.center { align-items: center; text-align: center; justify-content: center; }
