/* Космическая тема: фон — реальные снимки туманностей, интерфейс — тёмное стекло. */
:root {
  --ink: #eef2ff;
  --muted: #9aa4c8;
  --line: rgba(150, 160, 255, .16);
  --glass: rgba(12, 16, 34, .62);
  --glass-strong: rgba(16, 20, 42, .86);
  --accent1: #7a5cff;
  --accent2: #2fd6ff;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 18px 44px rgba(0, 0, 0, .45);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #05060f;
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

.app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── космос под интерфейсом ──────────────────────────────── */
.space {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #05060f url(/static/img/bg-portrait.jpg) center top / cover no-repeat;
}

.space::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 60% at 50% -8%, rgba(140, 90, 255, .18), transparent 62%),
    linear-gradient(180deg, rgba(5, 6, 15, .18) 0%, rgba(5, 6, 15, .52) 34%, rgba(5, 6, 15, .88) 68%, rgba(5, 6, 15, .97) 100%);
}

@media (min-aspect-ratio: 1/1) {
  .space { background-image: url(/static/img/bg.jpg); background-position: center; }
}

.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .55;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 18%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 78% 9%, #dff, transparent),
    radial-gradient(1px 1px at 34% 42%, #fff, transparent),
    radial-gradient(1.6px 1.6px at 61% 63%, #fff, transparent),
    radial-gradient(1px 1px at 88% 36%, #cfe, transparent),
    radial-gradient(1.1px 1.1px at 22% 76%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 47% 88%, #e6f7ff, transparent),
    radial-gradient(1px 1px at 92% 82%, #fff, transparent),
    radial-gradient(1px 1px at 6% 54%, #fff, transparent);
  background-repeat: repeat;
  background-size: 100% 100%;
  animation: twinkle 7s ease-in-out infinite alternate;
}

@keyframes twinkle { from { opacity: .35; } to { opacity: .7; } }



/* ── шапка ───────────────────────────────────────────────── */
.topbar {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(180deg, rgba(5, 6, 15, .85), rgba(5, 6, 15, 0));
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }

.logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #b9a6ff, #6a4bff 55%, #2a1a6b);
  box-shadow: 0 0 18px rgba(122, 92, 255, .65), inset 0 0 8px rgba(255, 255, 255, .35);
}

.brand-title {
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: .1px;
  background: linear-gradient(95deg, #ffffff 10%, #b7c6ff 55%, #7fe6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(12px);
  color: var(--ink);
  width: 38px; height: 38px;
  border-radius: 13px;
  font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(.94); }

/* ── контент ─────────────────────────────────────────────── */
.view {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 4px 16px 102px;
  -webkit-overflow-scrolling: touch;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 20px 2px 10px;
}
.section-title::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  box-shadow: 0 0 10px rgba(122, 92, 255, .9);
}

.cards { display: flex; flex-direction: column; gap: 9px; }

.card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.card:active { transform: scale(.985); border-color: rgba(160, 170, 255, .4); }

.avatar {
  width: 44px; height: 44px;
  flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(122, 92, 255, .55), rgba(47, 214, 255, .18) 70%);
  border: 1px solid rgba(160, 170, 255, .25);
  font-size: 18px;
}

.card .body { flex: 1; min-width: 0; }
.card .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thumb {
  width: 56px; height: 76px;
  object-fit: cover;
  border-radius: 12px;
  background: #0a0c18;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.preview-video {
  margin: 4px 0 10px;
  border-radius: 16px;
  overflow: hidden;
  background: #03040a;
  border: 1px solid var(--line);
}
.preview-video video {
  display: block;
  width: 100%;
  max-height: 44vh;
  background: #03040a;
}

.thumb.solo { width: 56px; height: 76px; }

.thumb.ghost {
  background: url(/static/img/galaxy.jpg) center/cover no-repeat;
  opacity: .45;
}

.chip {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(154, 164, 200, .14);
  border: 1px solid rgba(154, 164, 200, .22);
  color: var(--muted);
  white-space: nowrap;
}
.chip.ready {
  background: rgba(74, 222, 128, .12);
  border-color: rgba(74, 222, 128, .35);
  color: var(--good);
  box-shadow: 0 0 12px rgba(74, 222, 128, .18);
}
.chip.published {
  background: rgba(122, 92, 255, .18);
  border-color: rgba(122, 92, 255, .45);
  color: #c8b8ff;
}
.chip.processing {
  background: rgba(251, 191, 36, .12);
  border-color: rgba(251, 191, 36, .4);
  color: var(--warn);
}
.chip.error {
  background: rgba(248, 113, 113, .12);
  border-color: rgba(248, 113, 113, .4);
  color: var(--bad);
}

.more-btn {
  width: 100%;
  margin-top: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}
.empty .art {
  width: 132px; height: 132px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(160, 170, 255, .3);
  box-shadow: 0 0 40px rgba(122, 92, 255, .35), inset 0 0 24px rgba(5, 6, 15, .6);
}

/* ── нижние вкладки ──────────────────────────────────────── */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  gap: 6px;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  background: rgba(6, 8, 18, .82);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11.5px;
  padding: 8px 4px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  transition: background .15s ease, color .15s ease;
}
.tab span { font-size: 19px; line-height: 1.1; }
.tab.active {
  color: var(--ink);
  background: linear-gradient(180deg, rgba(122, 92, 255, .22), rgba(47, 214, 255, .07));
  box-shadow: inset 0 0 0 1px rgba(160, 170, 255, .25);
}

.badge {
  position: absolute;
  top: 4px; right: calc(50% - 24px);
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #060814;
  font-size: 10px;
  line-height: 16px;
  font-weight: 800;
}

/* ── лист выбора режима ──────────────────────────────────── */
.sheet, .viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3, 4, 10, .62);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
}
.viewer { align-items: center; justify-content: center; }

.sheet-card {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(20, 24, 48, .98), rgba(9, 11, 24, .99));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  animation: sheet-up .18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }

.sheet-title { font-weight: 700; font-size: 17px; margin-bottom: 4px; }
.sheet-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.btn {
  width: 100%;
  border: 0;
  border-radius: 15px;
  padding: 14px;
  font-size: 15px;
  font-weight: 650;
  color: #fff;
  background: linear-gradient(120deg, var(--accent1), #4b8bff 55%, var(--accent2));
  box-shadow: 0 10px 26px rgba(90, 110, 255, .35);
  cursor: pointer;
  margin-bottom: 9px;
}
.btn.secondary {
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: none;
}
.btn:disabled { opacity: .55; }
.btn:active { transform: scale(.99); }

/* ── просмотр ролика ─────────────────────────────────────── */
#viewer-video {
  max-width: 94%;
  max-height: 72vh;
  border-radius: 20px;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: 0 0 60px rgba(122, 92, 255, .35);
}
.viewer-close {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  z-index: 60;
}
.viewer-bar {
  position: absolute;
  left: 14px; right: 14px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── настройки ───────────────────────────────────────────── */
.field { margin: 16px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.value-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(122, 92, 255, .18);
  border: 1px solid rgba(122, 92, 255, .35);
  color: #cbb9ff;
  font-size: 12.5px;
  margin-left: 8px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent2);
  height: 28px;
}

.segmented {
  display: flex;
  gap: 4px;
  background: var(--glass);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: 16px;
}
.segmented button {
  flex: 1;
  border: 0;
  padding: 11px 6px;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.segmented button.active {
  background: linear-gradient(180deg, rgba(122, 92, 255, .35), rgba(47, 214, 255, .12));
  color: var(--ink);
  font-weight: 650;
  box-shadow: inset 0 0 0 1px rgba(160, 170, 255, .3);
}

textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--glass);
  color: var(--ink);
  font: inherit;
}
textarea:focus { outline: none; border-color: rgba(122, 160, 255, .6); box-shadow: 0 0 0 3px rgba(122, 92, 255, .18); }

.preview {
  margin-top: 8px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
  white-space: pre-wrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.stat {
  padding: 12px 8px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--line);
  text-align: center;
}
.stat .num { font-weight: 750; font-size: 18px; }
.stat .num.up { color: var(--good); }
.stat .num.down { color: var(--bad); }
.stat .cap { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stat .hint { font-size: 10.5px; color: rgba(154, 164, 200, .7); margin-top: 3px; }

.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin: 0 6px;
}
.dot.up { background: var(--good); box-shadow: 0 0 10px rgba(74, 222, 128, .7); }
.dot.down { background: var(--bad); box-shadow: 0 0 10px rgba(248, 113, 113, .7); }

.card.event { padding: 10px 12px; text-decoration: none; color: inherit; }

.account {
  display: flex;
  gap: 10px;
  align-items: stretch;
  padding: 16px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(6, 8, 18, .35), rgba(6, 8, 18, .85)),
    url(/static/img/planet.jpg) center/cover no-repeat;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .35);
  margin-bottom: 10px;
}
.account .num { font-weight: 750; font-size: 17px; text-shadow: 0 2px 10px rgba(0, 0, 0, .6); }
.account .cap { font-size: 11.5px; color: #b6c1e4; }
.account .col { flex: 1; text-align: center; display: flex; flex-direction: column; justify-content: center; gap: 2px; }

/* ── тост ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  padding: 12px 16px;
  border-radius: 15px;
  background: rgba(14, 18, 38, .96);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 80;
  text-align: center;
  white-space: pre-wrap;
  backdrop-filter: blur(12px);
}

.hidden { display: none !important; }

.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
