:root {
  --ink: #0F172A;
  --ink-2: #1E293B;
  --ink-3: #334155;
  --accent: #0284C7;
  --accent-ink: #075985;
  --danger: #B91C1C;
  --ok: #15803D;
  --glass: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.35);
  --blur: blur(16px) saturate(180%);
  --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
  --radius: 20px;
  font-family: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  color: var(--ink-2);
  font-size: 1.0625rem;
  line-height: 1.5;
  background:
    radial-gradient(60vmax 60vmax at 100% 0%, rgba(56, 189, 248, 0.3), transparent 60%),
    radial-gradient(50vmax 50vmax at 0% 100%, rgba(134, 221, 185, 0.3), transparent 60%),
    #EEF6FC;
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
h1, h2 { color: var(--ink); margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: 1.4rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 800; }
.muted { color: var(--ink-3); margin: 0 0 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
}

.screen {
  max-width: 760px; margin: 0 auto;
  padding: 12px 16px calc(32px + env(safe-area-inset-bottom));
  display: grid; gap: 16px;
}
.screen--center { min-height: 100dvh; place-content: center; }
.card { padding: 18px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 0;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform 0.12s ease, background-color 0.2s ease, opacity 0.2s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--accent-ink); color: #fff; }
.btn--ghost { background: rgba(15, 23, 42, 0.06); color: var(--ink); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger-ghost { background: #FEE2E2; color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 6px 14px; font-size: 0.95rem; }
.btn--big { min-height: 60px; font-size: 1.1rem; border-radius: 18px; margin-top: 6px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* login */
.login { width: min(360px, calc(100vw - 32px)); padding: 28px 24px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.login img { border-radius: 18px; margin-bottom: 4px; }
.login label { font-weight: 700; color: var(--ink); justify-self: start; }
.login input {
  width: 100%; height: 54px; padding: 0 14px; font: inherit; font-size: 1.05rem;
  border: 2px solid rgba(15, 23, 42, 0.15); border-radius: 14px; background: #fff; color: var(--ink);
  margin-bottom: 6px;
}
.login input:focus { border-color: var(--accent); outline: none; }
.error { color: var(--danger); font-weight: 700; min-height: 1.5em; margin: 4px 0 0; }

/* top bar + tabs */
.sticky { position: sticky; top: 0; z-index: 10; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  margin: 0; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-radius: 0 0 var(--radius) var(--radius);
}
.topbar h1 { margin: 0; flex: 1; }
.who { display: block; font-size: 0.78rem; font-weight: 400; color: var(--ink-3); direction: ltr; text-align: right; }
.net { font-size: 0.85rem; font-weight: 700; color: #78350F; background: #FEF3C7; padding: 4px 10px; border-radius: 999px; }
.tabs {
  max-width: 760px; margin: 0 auto; padding: 10px 16px 4px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.tab {
  min-height: 52px; border-radius: 16px; border: 2px solid rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.75); color: var(--ink); font: inherit; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.tab.is-active { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.count { display: inline-block; min-width: 1.8em; text-align: center; font-size: 0.85rem; background: #fff; color: var(--accent-ink); border-radius: 999px; padding: 1px 8px; }
.tab:not(.is-active) .count { background: var(--accent-ink); color: #fff; }

/* type picker */
fieldset { border: 0; margin: 0 0 16px; padding: 0; }
legend { font-weight: 800; color: var(--ink); margin-bottom: 8px; padding: 0; }
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.types legend { grid-column: 1 / -1; }
.type { position: relative; }
.type input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.type span {
  display: grid; justify-items: center; gap: 4px; padding: 12px 6px; min-height: 84px; align-content: center;
  border-radius: 16px; background: #fff; border: 2px solid rgba(15, 23, 42, 0.12);
  font-weight: 800; color: var(--ink); text-align: center; font-size: 0.98rem;
}
.type svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.type input:checked + span { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.type input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* media slots */
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.slots--single { grid-template-columns: 1fr; }
.slot {
  position: relative; overflow: hidden; cursor: pointer;
  display: grid; justify-items: center; align-content: center; gap: 4px; text-align: center;
  min-height: 170px; padding: 14px 10px;
  border-radius: 18px; border: 2px dashed rgba(7, 89, 133, 0.35); background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
}
.slots--single .slot { min-height: 200px; }
.slot__step {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-ink); color: #fff; font-weight: 800;
}
.slot__title { font-weight: 700; font-size: 1.05rem; }
.slot__title b { color: var(--accent-ink); font-weight: 800; }
.slot__hint { font-size: 0.85rem; color: var(--ink-3); }
.slot__preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot.has-file { border-style: solid; border-color: var(--ok); }
.slot.has-file .slot__step, .slot.has-file .slot__title {
  position: relative; z-index: 1; background: rgba(255, 255, 255, 0.92); border-radius: 999px; padding: 2px 10px;
}
.slot.has-file .slot__step { background: var(--ok); color: #fff; padding: 0; }
.slot.has-file .slot__hint { display: none; }

/* category chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { width: 100%; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chips label span {
  display: inline-flex; align-items: center; min-height: 46px; padding: 8px 16px;
  border-radius: 999px; font-weight: 700; color: var(--ink);
  background: #fff; border: 2px solid rgba(15, 23, 42, 0.12);
}
.chips input:checked + span { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.chips input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* text fields */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field__label { display: flex; align-items: baseline; gap: 6px; font-weight: 800; color: var(--ink); }
.field__label em { font-style: normal; font-weight: 400; color: var(--ink-3); font-size: 0.9rem; }
.counter { margin-inline-start: auto; font-size: 0.85rem; font-weight: 700; color: var(--ink-3); direction: ltr; font-variant-numeric: tabular-nums; }
.counter.is-near { color: #B45309; }
.field input, .field textarea {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--ink);
  border: 2px solid rgba(15, 23, 42, 0.12); border-radius: 14px; background: #fff; resize: none;
}
.field input { height: 52px; }
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; }

/* progress */
.progress { margin-top: 12px; }
.bar { height: 8px; border-radius: 4px; background: #E2E8F0; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s ease; }
.progress__text { margin: 8px 0 0; font-weight: 700; color: var(--ink-2); text-align: center; }

/* media editor */
.media-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px; }
.chips--filter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.filter {
  flex: none; min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.12); background: #fff; color: var(--ink);
  font: inherit; font-weight: 700; font-size: 0.92rem; cursor: pointer;
}
.filter.is-active { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile { border-radius: 16px; overflow: hidden; background: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.tile__media { position: relative; aspect-ratio: 1; background: #DBEAFE; }
.tile__media img, .tile__media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile__media--split { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #fff; }
.tile__half { position: relative; overflow: hidden; }
.tile__half-label {
  position: absolute; bottom: 6px; inset-inline-start: 6px;
  font-size: 0.7rem; font-weight: 800; background: rgba(255, 255, 255, 0.92); color: var(--ink);
  padding: 1px 7px; border-radius: 999px;
}
.tile__badges { position: absolute; top: 6px; inset-inline-start: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 0.72rem; font-weight: 800; color: #fff; background: rgba(7, 89, 133, 0.92); border-radius: 999px; padding: 2px 8px; }
.badge--demo { background: rgba(120, 53, 15, 0.9); }
.tile .play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.tile .play::before { content: "▶"; color: #fff; font-size: 1.6rem; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
.tile .del {
  position: absolute; top: 6px; inset-inline-end: 6px;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.95); color: var(--danger);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2); cursor: pointer;
}
.tile .del svg { width: 22px; height: 22px; fill: currentColor; }
.tile__meta { padding: 8px 10px 10px; display: grid; gap: 2px; min-width: 0; }
.tile__meta strong { font-size: 0.92rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__meta span { font-size: 0.8rem; color: var(--ink-3); }
.empty { text-align: center; margin: 0; }

/* confirm dialog */
.dialog { border: 0; padding: 24px; width: min(360px, calc(100vw - 32px)); text-align: center; color: var(--ink-2); }
.dialog::backdrop { background: rgba(15, 23, 42, 0.45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog img { width: 96px; height: 96px; object-fit: cover; border-radius: 14px; margin: 0 auto 12px; display: block; background: #E0F2FE; }
.dialog__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 160%); transition: transform 0.25s ease;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: #fff; font-weight: 700; box-shadow: var(--shadow);
  pointer-events: none; /* never swallow taps on the buttons underneath */
}
.toast.is-visible { transform: translate(-50%, 0); }
