/* Ebatti — graphite UI. One accent (azure), thin borders, strict 4px grid. Phones first: 320px and up. */
:root {
  --bg: #0c0d0f;
  --rail: #0f1012;
  --panel: #141518;
  --panel-2: #191a1e;
  --inset: #0e0f11;
  --text: #ececef;
  --muted: #8d8f99;
  --faint: #5f616b;
  --line: #222429;
  --line-strong: #2e3036;
  --hover: #1c1e22;
  --accent: #2f6fed;
  --accent-hover: #3a7af5;
  --accent-ink: #ffffff;
  --accent-text: #7ea9ff;
  --accent-soft: rgba(47, 111, 237, .14);
  --green: #3fca86;
  --green-soft: rgba(63, 202, 134, .12);
  --blue: var(--accent-text);
  --blue-soft: var(--accent-soft);
  --amber: #e9b44c;
  --amber-soft: rgba(233, 180, 76, .12);
  --red: #f2555a;
  --red-soft: rgba(242, 85, 90, .12);
  --gray-soft: #1d1f23;
  --shadow: none;
  --pop: 0 16px 48px rgba(0, 0, 0, .5), 0 0 0 1px var(--line-strong);
  --radius: 12px;
  --r-sm: 8px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --tap: 44px;
  --nav-h: 58px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font: 14px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03";
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, video, svg { max-width: 100%; }
code { font: 12.5px ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace; background: var(--gray-soft); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
h1 { font-size: 24px; line-height: 1.2; font-weight: 650; margin: 0; letter-spacing: -.022em; }
h2 { font-size: 13.5px; margin: 0 0 14px; font-weight: 600; letter-spacing: -.005em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h2 .muted { font-weight: 450; }
.mt { margin-top: 22px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; padding: 16px; }
.spacer { flex: 1; }
.num, .tabular { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- Layout */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  padding: 14px 10px 12px; border-right: 1px solid var(--line); background: var(--rail); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; padding: 6px 10px 18px; color: var(--text); }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--text); color: var(--bg); display: grid; place-items: center; flex: none; }
.logo svg { width: 18px; height: 18px; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 16px 10px 6px; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar nav a {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 34px;
  padding: 6px 10px; border-radius: 7px; color: var(--muted); font-weight: 500; transition: background .12s, color .12s;
}
.sidebar nav a svg, .bottom-nav svg, .menu-item svg {
  width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.sidebar nav a .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar nav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.sidebar nav a.active svg { color: var(--accent-text); }
.pill { font-size: 11px; font-weight: 600; background: var(--gray-soft); color: var(--muted); border-radius: 99px; padding: 0 7px; line-height: 18px; font-variant-numeric: tabular-nums; }
.pill:empty { display: none; }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.sidebar-foot { margin-top: auto; padding: 12px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sidebar-foot b { display: block; color: var(--text); font-size: 20px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mini-cd { font-variant-numeric: tabular-nums; }

main {
  padding: 28px 32px 64px; max-width: 1240px; width: 100%; min-width: 0;
  padding-left: max(32px, var(--sal)); padding-right: max(32px, var(--sar));
}
.tab:not([hidden]) { animation: tab-in .22s var(--ease); }
@keyframes tab-in { from { opacity: 0; transform: translateY(4px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; font-size: 13.5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; min-width: 0; }
.panel.help { background: transparent; }
.panel.help p { margin: 0 0 10px; color: var(--muted); }
.panel.help p b, .panel.help li b { color: var(--text); font-weight: 550; }
.panel.help ul { margin: 0 0 10px; padding-left: 20px; color: var(--muted); }
.panel.help li { margin: 4px 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 + * { margin-top: 16px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.home-grid > div { display: grid; gap: 16px; min-width: 0; }
.home-grid .panel { margin: 0; }
.home-grid + .panel, .home-grid + div { margin-top: 16px; }

/* ---------------------------------------------------------------- Buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px;
  font: inherit; font-size: 13.5px; font-weight: 550; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 6px 13px; cursor: pointer;
  white-space: nowrap; text-decoration: none !important; user-select: none; -webkit-user-select: none;
  transition: background .12s, border-color .12s, transform .08s, opacity .12s;
}
.btn:hover { background: var(--hover); border-color: #3a3d44; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.small { min-height: 28px; padding: 3px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.big { min-height: 44px; padding: 10px 18px; font-size: 14.5px; width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger, .btn.danger-ghost { color: var(--red); }
.btn.danger-ghost:hover { border-color: color-mix(in srgb, var(--red) 40%, transparent); background: var(--red-soft); }
.ico, .btn .ico { width: 16px; flex: none; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); border-top-color: transparent; animation: spin .7s linear infinite; }
.btn.primary.busy::after { border-color: #fff; border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
input:where(:not([type=checkbox], [type=radio], [type=range])), select, textarea {
  font: inherit; color: var(--text); background: var(--inset);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 7px 10px; width: 100%; min-width: 0; min-height: 34px;
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238d8f99' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 14px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
input[type=datetime-local] { color-scheme: dark; }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=search] { width: 260px; }
.toolbar select { width: auto; }
.toolbar.tight { margin-bottom: 10px; }
.toolbar.tight input[type=search] { flex: 1; width: auto; }
.inline-form { display: flex; gap: 8px; }
.link-box { display: flex; gap: 8px; margin-bottom: 10px; }
.link-box input { font: 12px ui-monospace, Menlo, monospace !important; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; flex-wrap: wrap; }

.seg { display: inline-flex; background: var(--inset); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; max-width: 100%; }
.seg button { font: inherit; font-size: 13px; font-weight: 550; border: 0; background: transparent; color: var(--muted); padding: 4px 11px; min-height: 28px; border-radius: 7px; cursor: pointer; transition: background .12s, color .12s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }

/* ---------------------------------------------------------------- KPI cards */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.cards.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; transition: border-color .15s; }
a.card { color: inherit; text-decoration: none !important; display: block; }
a.card:hover { border-color: var(--line-strong); }
.card .label { color: var(--muted); font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .value { font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 6px 0 4px; }
.card .sub { color: var(--muted); font-size: 12px; line-height: 1.4; }
.card.bad { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.card.bad .value { color: var(--red); }
.card.good .value { color: var(--green); }
.card.muted-value .value { color: var(--muted); }
.warn-text { color: var(--amber); }

.banner { background: var(--panel); border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); border-radius: var(--r-sm); padding: 12px 16px; margin-bottom: 16px; }
.banner ol { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }
.banner.warn { border-left-color: var(--amber); }
.banner.bad { border-left-color: var(--red); }

/* ---------------------------------------------------------------- Schedule & home */
.next-slot { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.next-slot .big { font-size: 40px; line-height: 1; font-weight: 600; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.next-slot .countdown { color: var(--muted); font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { font-variant-numeric: tabular-nums; font-weight: 550; font-size: 12.5px; padding: 3px 9px; border-radius: 7px; background: var(--inset); border: 1px solid var(--line); color: var(--muted); }
.chip.done { color: var(--green); border-color: color-mix(in srgb, var(--green) 25%, var(--line)); }
.chip.next { background: var(--accent); border-color: var(--accent); color: #fff; }

.runway-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.runway-row:last-child { border-bottom: 0; }
.runway-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { width: 80px; height: 4px; border-radius: 2px; background: var(--gray-soft); overflow: hidden; flex: none; }
.meter > div { height: 100%; background: var(--green); border-radius: 2px; transition: width .4s var(--ease); }
.meter.low > div { background: var(--amber); }
.meter.empty > div { background: var(--red); }

.up-list { display: grid; }
.up-row { display: grid; grid-template-columns: 56px 27px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none !important; }
.up-row:last-child { border-bottom: 0; }
.up-row .at { font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.up-row .at small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; }
.up-row img { width: 27px; height: 48px; object-fit: cover; border-radius: 5px; background: var(--inset); border: 1px solid var(--line); }
.up-row img.noimg { visibility: hidden; }
.up-row .what { min-width: 0; }
.up-row .what b { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-row .what span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; overflow: hidden; white-space: nowrap; }
.up-row .what span em { font-style: normal; overflow: hidden; text-overflow: ellipsis; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; }
.status-line { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 550; }

/* ---------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); -webkit-overflow-scrolling: touch; }
.panel .table-wrap { border: 0; border-radius: 0; background: transparent; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover td { background: rgba(255, 255, 255, .015); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.empty { text-align: center; color: var(--muted); padding: 44px 12px; }
.table select { width: auto; min-height: 30px; padding-top: 4px; padding-bottom: 4px; }
.inline-input { border-color: transparent !important; background-color: transparent !important; padding: 4px 6px !important; min-height: 30px !important; }
.inline-input:hover { border-color: var(--line-strong) !important; }
.inline-input:focus { background-color: var(--inset) !important; border-color: var(--accent) !important; }
.log-table td { padding: 8px 10px; font-size: 13px; }
.log-table td:first-child { width: 1%; font-variant-numeric: tabular-nums; }
.log-table td:nth-child(2) { width: 1%; }
.log-table td:last-child { overflow-wrap: anywhere; }
.panel .log-table td:first-child { padding-left: 0; }
.panel .log-table td:last-child { padding-right: 0; }

.acc { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.acc > div { min-width: 0; }
.acc b { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; background: var(--gray-soft); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 600; color: var(--muted); font-size: 12.5px; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.acc-mini { display: flex; align-items: center; gap: 7px; white-space: nowrap; min-width: 0; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 550; padding: 1px 8px; line-height: 20px; border-radius: 99px; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--accent-soft); color: var(--accent-text); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--gray-soft); color: var(--muted); }
.badge.spin::before { animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .2; } }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.info { background: var(--green); }
.dot.warn { background: var(--amber); }
.dot.error { background: var(--red); }
.err { color: var(--red); max-width: 340px; margin-top: 4px; font-size: 12.5px; overflow-wrap: anywhere; }

.vid a { font-weight: 550; color: var(--text); display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caption { max-width: 320px; white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--muted); }
.caption-edit { min-width: 240px; max-width: 360px; font-size: 13px !important; }
.qpos { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ---------------------------------------------------------------- Switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 99px; transition: background .18s var(--ease); }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .18s var(--ease); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- Upload */
.step { width: 20px; height: 20px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text); font-size: 11.5px; display: inline-grid; place-items: center; }
.dropzone { display: grid; place-items: center; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 32px 16px; cursor: pointer; transition: border-color .15s, background .15s; background: var(--inset); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { display: none; }
.file-list { margin-top: 10px; max-height: 260px; overflow: auto; }
.file-row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 6px 8px; }
.file-total { padding: 8px 2px 0; font-size: 12.5px; color: var(--muted); }
.picker { max-height: 290px; overflow: auto; border: 1px solid var(--line); background: var(--inset); border-radius: 10px; padding: 4px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px; }
.pick { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; cursor: pointer; min-width: 0; min-height: 36px; }
.pick:hover { background: var(--hover); }
.pick:has(input:checked) { background: var(--accent-soft); }
.pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.pick em { font-style: normal; color: var(--muted); font-size: 11.5px; }
.radio-group { display: grid; gap: 8px; margin: 14px 0; }
.radio { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); background: var(--inset); border-radius: 10px; padding: 11px 12px; cursor: pointer; transition: border-color .12s, background .12s; }
.radio input { margin-top: 2px; }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio b { display: block; font-weight: 550; }
.radio span { color: var(--muted); font-size: 12.5px; }
.summary { margin: 0 0 12px; font-weight: 500; min-height: 20px; }
.progress { position: relative; height: 26px; border-radius: 8px; background: var(--inset); border: 1px solid var(--line); overflow: hidden; margin-top: 10px; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12.5px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; }

/* ---------------------------------------------------------------- Settings */
.fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 18px; }
.fields label:not(.check) { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; min-width: 0; }
.fields .full { grid-column: 1 / -1; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.save-bar { position: sticky; bottom: 0; padding: 14px 0 12px; background: linear-gradient(transparent, var(--bg) 35%); z-index: 2; }
.save-bar .btn { width: auto; }

/* ---------------------------------------------------------------- Platforms & AI */
.plat { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 650; letter-spacing: .02em; padding: 0 6px; line-height: 17px; border-radius: 5px; vertical-align: 1px; white-space: nowrap; border: 1px solid var(--line-strong); color: var(--text); background: var(--panel-2); }
.plat.tiktok { color: var(--text); }
.plat.youtube { color: #ff6b6b; border-color: rgba(255, 107, 107, .3); background: rgba(255, 107, 107, .08); }
.plat-btn.tiktok, .plat-btn.youtube { background: var(--panel-2); }
.plat-btn.tiktok::before, .plat-btn.youtube::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--text); }
.plat-btn.youtube::before { background: #ff4e45; }
.acc .plat { margin-right: 4px; }
.pick .plat, .runway-row .plat { flex: none; }
.ai-tag { font-size: 10.5px; font-weight: 650; color: var(--accent-text); background: var(--accent-soft); padding: 0 5px; border-radius: 4px; }
.ai-line { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.yt-title { font-weight: 600; font-size: 13px; margin: 0 0 4px 6px; max-width: 340px; }
ol.steps { margin: 0 0 10px; padding-left: 20px; color: var(--muted); }
ol.steps li { margin: 6px 0; }
details summary { cursor: pointer; margin-top: 4px; }
details div { max-width: 460px; margin-top: 4px; color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace !important; font-size: 12.5px !important; }
#gen-account { width: auto; max-width: 320px; }

/* ---------------------------------------------------------------- Users & login */
.user-box { display: flex; align-items: center; gap: 8px; padding: 10px 6px 0; border-top: 1px solid var(--line); margin-top: 10px; }
.user-box .me { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.user-box .me b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; font-size: 13px; }
.secret-box { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--green-soft); border: 1px solid color-mix(in srgb, var(--green) 25%, transparent); }
.secret-box p { margin: 0 0 8px; }
.mt-panel { margin-top: 16px; }
.role-tag { font-size: 12px; font-weight: 550; padding: 1px 8px; border-radius: 99px; background: var(--gray-soft); color: var(--muted); }
.role-tag.admin { background: var(--accent-soft); color: var(--accent-text); }
.login-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: max(16px, var(--sat)) 16px max(16px, var(--sab)); }
.login-box { width: 100%; max-width: 384px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login-box .brand, .login-box .brand:is(*) { padding: 0 0 20px; font-size: 17px; gap: 10px; }
.login-box h1 { font-size: 20px; margin-bottom: 14px; }
.login-box form { display: grid; gap: 14px; }
.login-box label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; }
.login-box .error { color: var(--red); margin: 0; }
.login-box p { margin: 0 0 4px; }
.login-box pre { white-space: pre-wrap; background: var(--inset); border: 1px solid var(--line); padding: 10px; border-radius: 8px; font-size: 12.5px; }
.login-about { margin: 18px 0 6px; line-height: 1.55; }
.fb-box { display: grid; gap: 14px; margin-bottom: 14px; }
.fb-google { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--panel-2); border: 1px solid var(--line-strong); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.fb-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 0; }
.note-ok { color: var(--green); margin: 0; }
.team-box { border-top: 1px solid var(--line); padding-top: 10px; }
.team-box summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.fb-box[hidden] + .team-box { border-top: 0; padding-top: 0; }
.fb-box[hidden] + .team-box summary { display: none; }
.login-links { margin: 0; }

/* ---------------------------------------------------------------- Terms / Privacy */
.legal-page { padding: 24px 16px 60px; }
.legal { max-width: 720px; margin: 0 auto; line-height: 1.7; font-size: 15px; color: #d4d5da; }
.legal .brand { display: inline-flex; color: var(--text); padding: 0 0 20px; text-decoration: none; }
.legal h1 { font-size: 30px; margin: 6px 0 4px; color: var(--text); }
.legal h2 { font-size: 18px; margin: 30px 0 8px; display: block; color: var(--text); }
.legal ul { padding-left: 22px; }
.legal li { margin: 6px 0; }
.legal footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- Library */
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; min-width: 0 !important; min-height: 0 !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap; border: 0 !important; opacity: 0; }
.lib-intro { margin: -10px 0 16px; }
.lib-filter { margin-bottom: 14px; display: flex; width: max-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.lib-filter::-webkit-scrollbar { display: none; }
.lib-filter button { white-space: nowrap; }
.lib-filter em { font-style: normal; font-size: 11.5px; opacity: .7; margin-left: 3px; font-variant-numeric: tabular-nums; }
.lib-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 12px; }
.lib-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-width: 0; transition: border-color .15s; }
.lib-card:hover { border-color: var(--line-strong); }
.lib-thumb { position: relative; width: 112px; aspect-ratio: 9 / 16; border-radius: 9px; overflow: hidden; background: var(--inset); border: 1px solid var(--line); align-self: start; }
.lib-thumb[data-play] { cursor: pointer; }
.lib-thumb img, .lib-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-thumb img.noimg { display: none; }
.lib-thumb .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px; text-shadow: 0 1px 10px rgba(0, 0, 0, .8); pointer-events: none; opacity: .9; }
.lib-thumb.posted { background: var(--green-soft); }
.lib-thumb .posted-badge { position: absolute; left: 6px; bottom: 6px; background: rgba(12, 13, 15, .85); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 6px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
/* Library card fields read like text and only look like fields on hover / focus */
.lib-card .lib-title, .lib-card .lib-caption, .lib-card .lib-topic-input {
  background-color: transparent; border-color: transparent; padding: 3px 6px; margin-left: -6px; width: calc(100% + 6px); min-height: 0;
}
.lib-card .lib-title { font-weight: 600; font-size: 14.5px; letter-spacing: -.005em; }
.lib-card .lib-caption { color: var(--muted); font-size: 13px; line-height: 1.5; resize: none; }
.lib-card .lib-topic-input { width: 150px; font-size: 12.5px; color: var(--muted); }
.lib-card .lib-title:hover, .lib-card .lib-caption:hover, .lib-card .lib-topic-input:hover { border-color: var(--line); }
.lib-card .lib-title:focus, .lib-card .lib-caption:focus, .lib-card .lib-topic-input:focus { background-color: var(--inset); color: var(--text); }
.lib-auto { font-size: 12.5px; color: var(--muted); min-height: 0; }
.lib-name { font-size: 12px !important; }
.auto-tag { font-size: 10.5px; font-weight: 600; letter-spacing: .02em; color: var(--accent-text); background: var(--accent-soft); border-radius: 4px; padding: 0 5px; line-height: 17px; flex: none; }
.plan-bar { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.plan-bar:empty { display: none; }
.plan-bar.off { background: transparent; border-style: dashed; }
.plan-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.plan-head b { font-weight: 600; flex: none; }
.plan-head .plan-sub { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-head .plan-sub b { font-weight: 550; color: var(--text); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 1px; margin: 12px 0 0; background: var(--line); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.metric { background: var(--inset); padding: 8px 12px; min-width: 0; }
.metric dt { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.metric dd { margin: 2px 0 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric.warn dd { color: var(--amber); }
.plan-switch { margin: 6px 0 4px; }
.lib-view { margin: -4px 0 14px; }
.lib-topicbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 14px; }
.lib-topicbar select { width: auto; max-width: 100%; }
.lib-opts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lib-topic-input { width: 170px; font-size: 13px; padding: 5px 8px; }
.plan-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.topic-chip { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid var(--line); border-radius: 7px; padding: 2px 9px; font-size: 12px; color: var(--muted); }
.topic-chip b { color: var(--text); font-weight: 550; }
.topic-chip.warn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.profile-panel { max-width: 720px; }
.profile-form { display: grid; gap: 12px; }
.profile-top { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; min-width: 0; }
.profile-top > div { min-width: 0; }
.profile-top b { display: block; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.avatar.xl { width: 64px; height: 64px; font-size: 26px; border-radius: 50%; overflow: hidden; display: inline-grid; place-items: center; background: var(--gray-soft); border: 1px solid var(--line-strong); font-weight: 650; flex: none; }
.avatar.xl img { width: 100%; height: 100%; object-fit: cover; }
.ins-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.ins-key { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-bar { height: 6px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; }
.ins-bar div { height: 100%; background: var(--accent); border-radius: 99px; }
.music-list { display: grid; gap: 6px; margin: 10px 0 14px; }
.music-row { display: flex; align-items: center; gap: 10px; background: var(--inset); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; font-size: 13.5px; }
.music-row span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-list.agenda { display: block; }
.agenda-day { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 2px 8px; }
.agenda-day:first-child { margin-top: 0; }
.agenda-day em { font-style: normal; font-weight: 500; text-transform: none; letter-spacing: 0; }
.agenda-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; margin-bottom: 6px; cursor: pointer; min-width: 0; min-height: var(--tap); transition: border-color .12s; }
.agenda-row:hover { border-color: var(--line-strong); }
.agenda-row.open { border-color: var(--accent); }
.agenda-row .at { font-weight: 650; font-variant-numeric: tabular-nums; flex: none; width: 46px; }
.agenda-row img { width: 27px; height: 48px; object-fit: cover; border-radius: 5px; background: var(--inset); flex: none; }
.agenda-row img.noimg { visibility: hidden; }
.agenda-row .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-row .who { flex: none; max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 5px; }
.agenda-open { margin: -2px 0 10px; }
.results-total { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 14px; }
.results-total div { font-size: 12.5px; color: var(--muted); }
.results-total b { display: block; font-size: 26px; font-weight: 600; letter-spacing: -.03em; color: var(--text); font-variant-numeric: tabular-nums; }
.results-cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; }
.results-cols h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.sched-chip .views { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lib-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.lib-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lib-posts { display: flex; flex-direction: column; gap: 6px; }
.lib-posts:empty { display: none; }
.sched-chip { display: flex; align-items: center; gap: 7px; font-size: 13px; background: var(--inset); border: 1px solid var(--line); border-radius: 9px; padding: 5px 8px; min-width: 0; }
.sched-chip .who { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 36px; flex: 1 1 auto; }
.sched-chip .when { color: var(--muted); white-space: nowrap; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.sched-chip > * { flex-shrink: 0; }
.sched-chip > .who { flex-shrink: 1; }
.sched-chip a { font-weight: 650; }
.chip-x { border: 0; background: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 4px 6px; line-height: 1; border-radius: 6px; }
.chip-x:hover { color: var(--text); background: var(--hover); }
.lib-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.lib-actions .btn.primary { flex: 1; }
.empty-state { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 16px; background: transparent; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty-state b { color: var(--text); }

/* ---------------------------------------------------------------- Notifications (Telegram) */
.tg-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tg-logo { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line-strong); flex: none; }
.tg-logo svg { width: 20px; height: 20px; fill: var(--accent-text); }
.tg-head > div { min-width: 0; }
.tg-head b { display: block; font-size: 15px; font-weight: 600; }
.tg-chats { display: grid; gap: 8px; margin-top: 14px; }
.tg-chat { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 14px; align-items: center; background: var(--inset); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.tg-chat .who { min-width: 0; }
.tg-chat .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.tg-toggles { display: flex; gap: 16px; flex-wrap: wrap; grid-column: 1 / -1; }
.tg-toggles .check { font-size: 13px; }
.tg-connect { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tg-wait { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.tg-wait::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-text); border-top-color: transparent; animation: spin .8s linear infinite; flex: none; }
.token-form { display: flex; gap: 8px; margin-top: 12px; }
.token-form input { flex: 1; }

/* ---------------------------------------------------------------- Sheets: bottom panel on phones, dialog on desktop */
.sheet { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet-panel { position: relative; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow: auto; overscroll-behavior: contain; background: var(--panel); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--pop); animation: pop-in .2s var(--ease); }
@keyframes pop-in { from { transform: translateY(6px) scale(.985); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h2 { margin: 0; font-size: 16px; }
.sheet-sub { margin: -6px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-label { font-weight: 550; font-size: 13px; margin-top: 4px; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.link-btn { border: 0; background: none; color: var(--accent-text); font: inherit; font-size: 13px; cursor: pointer; padding: 4px 2px; }
.chips.quick { margin: 0; }
.chips.quick .chip { cursor: pointer; font: inherit; font-weight: 550; font-size: 12.5px; min-height: 32px; }
.chips.quick .chip:hover { color: var(--text); border-color: var(--line-strong); }
.sheet-picker { max-height: 240px; grid-template-columns: 1fr; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; min-height: 52px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--inset); color: var(--text); font: inherit; font-weight: 550; font-size: 14.5px; cursor: pointer; text-decoration: none !important; transition: border-color .12s, background .12s; }
.menu-item svg { width: 20px; height: 20px; color: var(--muted); }
.menu-item:hover { border-color: var(--line-strong); background: var(--hover); }
.menu-item.active { border-color: var(--accent); }
.menu-item.active svg { color: var(--accent-text); }
.menu-item.danger { color: var(--red); justify-content: center; }
.menu-me { display: flex; align-items: center; gap: 10px; padding: 2px 2px 6px; min-width: 0; }
.menu-me > div { min-width: 0; }
.menu-me b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.sheet-open { overflow: hidden; }

/* ---------------------------------------------------------------- Background jobs */
.lib-jobs { display: grid; gap: 8px; margin-bottom: 14px; }
.lib-jobs:empty { display: none; }
.job-card { display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.job-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); flex: none; }
.job-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.job-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.job-body .badge { white-space: normal; align-self: flex-start; }
#jobs-clear { justify-self: end; }

/* ---------------------------------------------------------------- Link import & editor sheets */
.sheet-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radio-group.tight { margin: 4px 0; }
.mini-num { width: 56px !important; display: inline-block !important; padding: 2px 6px !important; margin: 0 2px; min-height: 0 !important; }
.check.rights { align-items: flex-start; font-weight: 500; }
.check.rights input { margin-top: 3px; }
.sheet-panel.wide { width: min(860px, calc(100vw - 32px)); }
.editor { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; }
.edit-preview { position: relative; width: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: 12px; overflow: hidden; align-self: start; border: 1px solid var(--line); }
.edit-preview video { width: 100%; height: 100%; object-fit: contain; display: block; }
.edit-preview[data-style="crop"] video { object-fit: cover; }
.edit-preview[data-style="blur"] { background: radial-gradient(circle at 50% 30%, #2b2d33, #0b0b0d 75%); }
.edit-text { position: absolute; left: 5%; right: 5%; text-align: center; font-weight: 800; line-height: 1.2; color: #fff; pointer-events: none;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 3px #000; white-space: pre-wrap; word-break: break-word; }
.edit-text.pos-top { top: 8%; }
.edit-text.pos-middle { top: 50%; transform: translateY(-50%); }
.edit-text.pos-bottom { bottom: 15%; }
.edit-text.color-yellow { color: #ffe14d; }
.edit-text.boxed { background: rgba(0, 0, 0, .55); border-radius: 6px; padding: .2em .35em; text-shadow: none; }
.edit-controls { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.seg-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.trim-row { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 8px; align-items: end; }
.trim-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 550; }

/* Phone bottom navigation (hidden on bigger screens) */
.bottom-nav { display: none; }

/* ---------------------------------------------------------------- Toasts */
#toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--panel-2); color: var(--text); border: 1px solid var(--line-strong); border-left: 3px solid var(--green); padding: 11px 15px; border-radius: 10px; box-shadow: var(--pop); font-weight: 500; animation: slide .22s var(--ease); overflow-wrap: anywhere; }
.toast.error { border-left-color: var(--red); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1180px) {
  .cards.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}
/* Tablets and small laptops: icon rail */
@media (max-width: 1080px) and (min-width: 721px) {
  .app { grid-template-columns: 64px minmax(0, 1fr); }
  .sidebar { padding: 14px 8px 12px; align-items: center; }
  .brand { padding: 6px 0 14px; font-size: 0; gap: 0; }
  .nav-group { font-size: 0; padding: 10px 0 4px; width: 24px; border-top: 1px solid var(--line); margin-top: 6px; }
  .sidebar nav { width: 100%; }
  .sidebar nav a { justify-content: center; padding: 0; width: 44px; height: 40px; margin: 0 auto; }
  .sidebar nav a .nav-label { display: none; }
  .sidebar nav a .pill { position: absolute; top: 2px; right: 0; font-size: 9.5px; line-height: 14px; padding: 0 4px; }
  .sidebar-foot { display: none; }
  .user-box { flex-direction: column; padding: 10px 0 0; }
  .user-box .me { display: none; }
  .user-box .btn { font-size: 11px; padding: 2px 6px; }
  main { padding: 24px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-2 > .panel + .panel { margin-top: 0; }
}
@media (max-width: 900px) {
  .lib-list { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------- Phones (320px and up) */
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  main {
    padding: calc(16px + var(--sat)) max(14px, var(--sar)) calc(var(--nav-h) + 28px + var(--sab)) max(14px, var(--sal));
  }
  h1 { font-size: 26px; }
  .page-head { margin-bottom: 14px; align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn, .page-head .actions select { flex: 1 1 auto; }
  .panel { padding: 14px; border-radius: 12px; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .home-grid, .home-grid > div { gap: 12px; }
  .toolbar input[type=search] { width: 100%; }
  .seg { overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  .seg::-webkit-scrollbar { display: none; }
  .toolbar .seg { flex: 1 1 100%; }
  .toolbar .seg button { flex: 1 0 auto; }
  .toolbar select { flex: 1 1 auto; }
  .inline-form { flex-direction: column; }
  .token-form { flex-direction: column; }
  .cards, .cards.six { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 12px 13px; }
  .card .value { font-size: 24px; }
  .next-slot .big { font-size: 34px; }
  /* 16px stops iPhone Safari from zooming into inputs; 44px touch targets */
  input:where(:not([type=checkbox], [type=radio], [type=range])), select, textarea { font-size: 16px; padding: 10px 12px; min-height: var(--tap); }
  select { padding-right: 32px; }
  .btn { min-height: var(--tap); padding: 9px 14px; font-size: 14px; }
  .btn.small { min-height: 36px; padding: 6px 11px; font-size: 13px; }
  .seg button { min-height: 36px; padding: 6px 10px; }
  .check { min-height: var(--tap); }
  .switch { width: 44px; height: 26px; }
  .switch span::after { width: 22px; height: 22px; }
  .switch input:checked + span::after { transform: translateX(18px); }
  .pick { min-height: var(--tap); }
  .link-box { flex-direction: column; }
  .up-row { grid-template-columns: 50px 27px minmax(0, 1fr); }
  .up-row > :last-child:not(.what) { display: none; }
  .results-cols { grid-template-columns: minmax(0, 1fr); }
  .results-total { gap: 20px; }

  /* Tables become cards */
  .table-wrap.stack { background: transparent; border: 0; border-radius: 0; overflow: visible; }
  .stack .table, .stack .table tbody { display: block; }
  .stack .table thead { display: none; }
  .stack .table tbody { display: grid; gap: 10px; }
  .stack .table tr { display: grid; grid-template-columns: minmax(0, 1fr); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px; }
  .stack .table tbody tr:hover td { background: transparent; }
  .stack .table td { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; min-width: 0; overflow-wrap: anywhere; }
  .stack .table td:last-child { border-bottom: 0; }
  .stack .table td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 500; }
  .stack .table td:first-child, .stack .table td[data-label=""] { grid-template-columns: minmax(0, 1fr); }
  .stack .table td:first-child::before, .stack .table td[data-label=""]::before { display: none; }
  .stack .table td:first-child { padding-top: 10px; }
  .stack .table td.num { text-align: left; }
  .stack .table td.empty { display: block; padding: 36px 12px; text-align: center; }
  .stack .table td.empty::before { display: none; }
  .stack .table td:empty { display: none; }
  .stack .table select, .stack .table .inline-input { width: 100% !important; max-width: none !important; min-width: 0 !important; }
  .stack .table .inline-input { border-color: var(--line-strong) !important; background-color: var(--inset) !important; }
  .stack .table .caption, .stack .table .caption-edit, .stack .table .vid a, .stack .table .acc b, .stack .table .err { max-width: none; min-width: 0; }
  .stack .acc { min-width: 0; }
  .stack .acc-mini { white-space: normal; min-width: 0; }
  .stack .acc-mini > span:not(.plat):not(.avatar) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .stack .cell { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
  .stack .cell > div, .stack .cell > textarea { flex-basis: 100%; margin: 0; }
  .stack .table td.nowrap, .stack .table td .nowrap { white-space: normal; }
  .sched-chip { flex-wrap: wrap; row-gap: 4px; }
  .sched-chip .when { margin-right: auto; }
  .stack .table td[data-label=""]:not(:first-child) { display: flex; flex-wrap: wrap; gap: 8px; }
  .stack .table td[data-label=""] .btn { flex: 1 1 auto; }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--rail) 88%, transparent);
    backdrop-filter: saturate(140%) blur(16px); -webkit-backdrop-filter: saturate(140%) blur(16px);
    border-top: 1px solid var(--line);
    padding: 0 max(4px, var(--sar)) var(--sab) max(4px, var(--sal));
  }
  .bottom-nav a, .bottom-nav button {
    position: relative; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0;
    font: inherit; font-size: 11px; font-weight: 550; letter-spacing: .01em; color: var(--muted); background: none; border: 0;
    text-decoration: none !important; cursor: pointer; transition: color .15s; touch-action: manipulation; min-width: 0;
  }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .active { color: var(--text); }
  .bottom-nav .active svg { color: var(--accent-text); }
  .bottom-nav .active::before { content: ""; position: absolute; top: 0; left: 50%; width: 24px; height: 2px; margin-left: -12px; border-radius: 0 0 2px 2px; background: var(--accent); }
  .bottom-nav .pill { position: absolute; top: 6px; left: 50%; margin-left: 6px; font-size: 9.5px; line-height: 15px; padding: 0 5px; background: var(--accent); color: #fff; }
  .bottom-nav .pill.warn { background: var(--amber); color: #111; }

  .sheet { place-items: end stretch; }
  .sheet-panel { width: 100%; max-height: 90vh; max-height: 90dvh; border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + var(--sab)); animation: sheet-up .26s var(--ease); box-shadow: 0 -1px 0 var(--line-strong), 0 -20px 50px rgba(0, 0, 0, .5); }
  .sheet-panel::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 2px auto 6px; flex: none; }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  .sheet-panel.wide { width: 100%; }
  .sheet-buttons { grid-template-columns: minmax(0, 1fr); }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .edit-preview { width: min(58vw, 240px); justify-self: center; }
  .trim-row { grid-template-columns: minmax(0, 1fr) auto; }
  .lib-card { grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 10px; }
  .lib-thumb { width: 92px; }
  .lib-list { grid-template-columns: minmax(0, 1fr); }
  .plan-bar { font-size: 13.5px; }
  .lib-view { display: flex; width: 100%; }
  .lib-view button { flex: 1; }
  .lib-filter { width: 100%; }
  .lib-filter button { flex: 1 0 auto; padding: 6px 10px; }
  .lib-topic-input { width: 100%; }
  #gen-account { max-width: none; }
  .tg-chat { grid-template-columns: minmax(0, 1fr); }
  .tg-connect .btn { flex: 1 1 100%; }
  #toasts { bottom: calc(var(--nav-h) + 12px + var(--sab)); right: 12px; left: 12px; max-width: none; }
}
@media (max-width: 360px) {
  main { padding-left: max(12px, var(--sal)); padding-right: max(12px, var(--sar)); }
  .cards, .cards.six { gap: 8px; }
  .card { padding: 11px; }
  .card .value { font-size: 22px; }
  .stack .table td { grid-template-columns: 88px minmax(0, 1fr); }
  .menu-grid { grid-template-columns: minmax(0, 1fr); }
  .lib-card { grid-template-columns: 76px minmax(0, 1fr); }
  .lib-thumb { width: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------- Projects */
.project-switch {
  display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 6px; padding: 7px 8px; min-height: 44px;
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px; transition: border-color .12s, background .12s;
}
.project-switch:hover { border-color: var(--line-strong); background: var(--panel-2); }
.project-switch .nav-label { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.project-switch small { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.project-switch b { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-switch .ico { color: var(--muted); }
.project-mark { width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 650; color: var(--accent-text); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.project-list { display: grid; gap: 8px; }
.project-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--inset); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.project-row.current { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.project-row .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.project-row .who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#more-project { margin-bottom: 8px; }
#more-project .nav-label { line-height: 1.25; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1080px) and (min-width: 721px) {
  .project-switch { width: 44px; padding: 8px; justify-content: center; margin: 0 auto 6px; }
  .project-switch .nav-label, .project-switch .ico { display: none; }
}
@media (max-width: 720px) {
  .project-row { flex-wrap: wrap; }
  .project-row .who { flex-basis: calc(100% - 40px); }
}

/* ---------------------------------------------------------------- Story series */
.series-list { display: grid; gap: 14px; }
.series-card { margin: 0; }
.series-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.series-title { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.series-title b { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.series-card .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.episode-list { display: grid; margin-top: 12px; border-top: 1px solid var(--line); }
.episode-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.episode-row .ep-num { font-weight: 600; font-variant-numeric: tabular-nums; flex: none; width: 54px; color: var(--muted); font-size: 12.5px; }
.episode-row .ep-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.episode-row .ep-title .err { display: block; white-space: normal; }
@media (max-width: 720px) {
  .episode-row { flex-wrap: wrap; row-gap: 4px; }
  .episode-row .ep-title { flex-basis: calc(100% - 64px); }
  .episode-row .ep-num { width: 54px; }
  .series-card .metrics dd { font-size: 13.5px; }
}

/* Facebook */
.plat.facebook { color: #6ea8ff; border-color: rgba(110, 168, 255, .35); background: rgba(24, 119, 242, .12); }
.plat-btn.facebook { background: var(--panel-2); }
.plat-btn.facebook::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: #1877f2; }

.report-preview { display: block; width: 100%; max-width: 360px; margin-top: 16px; border-radius: 12px; border: 1px solid var(--line); }
#report-panel .actions { display: flex; gap: 8px; }
#report-panel textarea { font-family: inherit; }

/* billing */
.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.plan-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.plan-card.current { border-color: var(--accent); }
.plan-card h3 { margin: 0; font-size: 15px; }
.plan-card .price { font-size: 30px; font-weight: 650; letter-spacing: -.03em; }
.plan-card .price small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.plan-card ul { margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 13px; display: grid; gap: 4px; }
.plan-card ul b { color: var(--text); }
.plan-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.invoice { display: grid; gap: 12px; margin: 4px 0 12px; }
.invoice label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.invoice b { color: var(--text); font-size: 15px; }
.copy-row { display: flex; align-items: center; gap: 8px; }
.copy-row code { font-size: 15px; color: var(--text); background: var(--inset); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; flex: 1; min-width: 0; }
code.break { word-break: break-all; }
.plan-edit { display: grid; grid-template-columns: 70px repeat(3, minmax(0, 1fr)); gap: 8px 10px; align-items: center; margin-top: 14px; font-size: 13px; }
.plan-edit b { font-weight: 500; color: var(--muted); font-size: 12px; }
/* support */
.support-grid { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.support-grid > .panel { margin-bottom: 0; }
.ticket-list { display: grid; gap: 6px; padding: 8px; }
.ticket { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; }
.ticket:hover { background: var(--inset); }
.ticket.active { background: var(--inset); border-color: var(--line-strong); }
.ticket b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.thread { display: grid; gap: 10px; margin: 6px 0 14px; max-height: 60vh; overflow-y: auto; }
.msg { background: var(--inset); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; max-width: 88%; }
.msg.staff { justify-self: end; background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.reply { display: flex; gap: 8px; align-items: flex-end; }
.reply textarea { flex: 1; }
/* admin */
.bars { display: block; width: 100%; height: 120px; margin: 4px 0 6px; }
.bars rect { fill: var(--accent); opacity: .85; }
.bars rect:hover { opacity: 1; }
@media (max-width: 900px) {
  .plan-grid, .support-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .plan-edit { grid-template-columns: 56px repeat(3, minmax(0, 1fr)); gap: 6px; }
  .reply { flex-direction: column; align-items: stretch; }
}

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
