:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #111114;
  --muted: #6e6e76;
  --line: rgba(0, 0, 0, 0.1);
  --accent: #e8436f;
  --accent2: #833cf2;
  --field: #f4f4f7;
  --danger: #d63131;
  --warn: #b7791f;
  --ok: #1f8a4c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101014;
    --card: #1c1c22;
    --text: #f2f2f5;
    --muted: #9a9aa3;
    --line: rgba(255, 255, 255, 0.1);
    --field: #26262e;
    --danger: #ff6464;
    --warn: #f0b44c;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: calc(env(safe-area-inset-top) + 52px) 0 calc(env(safe-area-inset-bottom) + 150px);
  -webkit-text-size-adjust: 100%;
}
body.locked { overflow: hidden; }
button, select, input, textarea { font: inherit; color: inherit; }

.top {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 6px) 16px 6px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.top h1 {
  margin: 0; font-size: 22px; font-weight: 900; letter-spacing: 0.5px;
  background: linear-gradient(90deg, #f9c940, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.icon-btn { border: 0; background: none; font-size: 22px; width: 40px; height: 40px; border-radius: 20px; }
.icon-btn:active { background: var(--line); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#main { max-width: 720px; margin: 0 auto; padding: 8px 16px; }
.card { background: var(--card); border-radius: 16px; padding: 14px; margin: 12px 0; }
.card h2, .card h3 { margin: 0 0 8px; }
.card h3 { font-size: 17px; }
.card p { margin: 6px 0; }
.empty { color: var(--muted); text-align: center; padding: 28px 16px; }
.muted { color: var(--muted); font-size: 13px; }
.pad { padding: 0 4px; }
.center { text-align: center; }
.warn { color: var(--warn); }
.alert { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }

#banner {
  position: fixed; z-index: 30; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 58px);
  max-width: 560px; margin: 0 auto; padding: 12px 14px; border-radius: 14px;
  background: var(--ok); color: #fff; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
#banner.error { background: var(--danger); }

/* Accounts */
.acc-head { display: flex; align-items: center; gap: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar.ph { display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 800; }
.acc-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acc-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-title small { color: var(--muted); font-size: 12.5px; }
.trial { color: var(--accent2); font-weight: 600; font-size: 12.5px; }
@media (prefers-color-scheme: dark) { .trial { color: #b48cff; } }

.strip { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 6px; scroll-snap-type: x proximity; }
.strip::-webkit-scrollbar { display: none; }
.tile {
  position: relative; flex: none; width: 88px; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden;
  border: 0; padding: 0; background: var(--field); scroll-snap-align: start;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.failed { outline: 2px solid var(--danger); outline-offset: -2px; }
.tile.add { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; border: 1.5px dashed var(--line); }
.tile.add span { font-size: 30px; line-height: 1; color: var(--accent); }
.noimg { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); font-size: 22px; background: var(--field); }
.dur { position: absolute; right: 4px; bottom: 4px; font-size: 11px; color: #fff; background: rgba(0, 0, 0, 0.55); padding: 1px 5px; border-radius: 6px; }
.badge { position: absolute; left: 4px; top: 4px; font-size: 10px; font-weight: 700; color: #fff; background: var(--accent2); padding: 2px 5px; border-radius: 6px; }
.badge.err { background: var(--danger); top: auto; bottom: 4px; }
.badge.warn { background: rgba(0, 0, 0, 0.6); top: auto; bottom: 22px; font-weight: 500; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, 0.35); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.2s; }
.post .bar, .bar.big { position: relative; display: block; border-radius: 3px; overflow: hidden; margin-top: 6px; background: var(--line); }
.bar.big { height: 8px; }

/* Scheduled list and plan rows */
.post { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.post:first-of-type { border-top: 0; }
.post > img, .post > .noimg { width: 48px; height: 85px; border-radius: 8px; object-fit: cover; flex: none; }
.post-body { flex: 1; min-width: 0; }
.post-body p { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.row-status { font-size: 12.5px; color: var(--muted); }

/* Controls */
button { border: 0; border-radius: 12px; padding: 11px 14px; background: var(--field); font-weight: 600; cursor: pointer; }
button:disabled { opacity: 0.45; }
button.primary { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff; }
button.danger { color: var(--danger); }
button.small { padding: 6px 10px; font-size: 13.5px; border-radius: 10px; flex: none; }
button.link { background: none; padding: 6px 0; color: var(--accent2); font-weight: 500; font-size: 14px; text-align: left; }
button.wide { width: 100%; margin-top: 10px; }
button.strong { background: none; color: var(--accent); }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: 0.3px; }
label.check { display: flex; gap: 10px; align-items: center; text-transform: none; font-size: 15px; color: var(--text); letter-spacing: 0; }
label.check input { width: 22px; height: 22px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--field); padding: 11px 12px; font-size: 16px; }
textarea { resize: vertical; min-height: 140px; }
.row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.row > button:not(.small) { flex: 1; }
.row.between { justify-content: space-between; }
.over { color: var(--danger); }
.onboarding button { margin-top: 10px; width: 100%; }
.card > button { margin-top: 8px; }

.cap-row { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.cap-row:first-child { border-top: 0; }
.cap-row > div { flex: 1; min-width: 0; }
.cap-row p { margin: 2px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.caps { background: var(--field); border-radius: 12px; padding: 4px 10px; }

.days { display: flex; gap: 6px; }
.day { flex: 1; padding: 10px 0; }
.day.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.row input[type="time"] { flex: 1; }

/* Floating schedule button and tab bar */
.fab {
  position: fixed; z-index: 15; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 70px);
  padding: 14px 30px; border-radius: 30px; font-size: 17px; font-weight: 800; color: #fff;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); box-shadow: 0 8px 24px rgba(232, 67, 111, 0.4);
}
.tabs {
  position: fixed; z-index: 10; inset: auto 0 0 0; display: flex;
  padding: 4px 8px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line);
}
.tabs button { flex: 1; background: none; color: var(--muted); font-size: 11px; font-weight: 600; padding: 6px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.tabs button span { font-size: 21px; line-height: 1.2; }
.tabs button.active { color: var(--accent); }

/* Bottom sheet */
#sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: calc(100% - env(safe-area-inset-top) - 12px);
  max-width: 720px; margin: 0 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 24px);
  animation: up 0.22s ease-out;
}
.sheet-panel.still { animation: none; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  margin: 0 -16px 8px; padding: 10px 8px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.sheet-head > button { background: none; color: var(--accent); font-weight: 500; justify-self: start; }
.sheet-head > button:last-child { justify-self: end; }
.sheet-head b { text-align: center; font-size: 16px; }
.sheet-panel video { display: block; width: auto; max-width: 100%; max-height: 52vh; aspect-ratio: 9 / 16; margin: 6px auto; border-radius: 14px; background: #000; }
.sheet-panel h3 { margin: 18px 0 4px; font-size: 15px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu > button { text-align: left; }
.menu label { margin-top: 8px; }

/* Automatic posting times */
.auto { background: var(--card); border-radius: 14px; padding: 4px 12px 12px; margin: 8px 0 4px; }
.auto.on { outline: 1.5px solid color-mix(in srgb, var(--accent2) 55%, transparent); }
.auto > button { width: 100%; margin-top: 10px; }
.stepper { gap: 16px; }
.stepper b { font-size: 20px; min-width: 24px; text-align: center; }
.stepper button { width: 44px; font-size: 18px; }
.hours { display: flex; flex-direction: column; gap: 4px; }
.hour { display: grid; grid-template-columns: 48px 1fr 48px 52px; align-items: center; gap: 8px; font-size: 13.5px; font-variant-numeric: tabular-nums; padding: 2px 4px; border-radius: 8px; }
.hour.chosen { background: color-mix(in srgb, var(--accent2) 16%, transparent); font-weight: 700; }
.hour small { color: var(--muted); text-align: right; }
.hbar { height: 8px; border-radius: 4px; background: var(--field); overflow: hidden; }
.hbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.hbar i.neg { background: var(--muted); opacity: 0.5; }
.row input[type="number"] { width: 80px; flex: none; }
