:root {
  --bg: #0d001a;
  --panel: rgba(22, 10, 48, 0.92);
  --line: rgba(255, 255, 255, 0.11);
  --text: #f7f4ff;
  --muted: rgba(215, 205, 245, 0.68);
  --accent: #6e1aff;
  --accent-2: #471aff;
  --cyan: #00bfff;
  --ok: #3ee6a3;
  --bad: #ff6b7a;
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tab-h: 64px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body { overflow-x: hidden; }

.aurora {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(80% 50% at 15% -5%, rgba(149, 0, 255, 0.38), transparent 55%),
    radial-gradient(60% 40% at 95% 5%, rgba(0, 191, 255, 0.16), transparent 50%),
    radial-gradient(50% 40% at 50% 105%, rgba(71, 26, 255, 0.22), transparent 55%);
}

#app {
  position: relative; z-index: 1;
  max-width: 480px; margin: 0 auto;
  min-height: 100dvh;
  padding: calc(10px + var(--safe-t)) 14px calc(var(--tab-h) + 18px + var(--safe-b));
}

.top {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
  min-height: 44px;
}
.brand-wrap { flex: 1; min-width: 0; }
.brand {
  display: flex; align-items: center; gap: 9px;
  font-family: Syne, sans-serif; font-weight: 800; font-size: 1.05rem;
  letter-spacing: -0.03em;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; object-fit: cover;
  box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 8px 22px rgba(110,26,255,.4);
}
.top .sub,
.page-head .sub {
  color: var(--muted); font-size: 12px; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-head .sub { white-space: normal; line-height: 1.35; margin-top: 6px; }

.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 12px; flex-shrink: 0;
  background: rgba(255,255,255,.07); color: var(--text);
  font-size: 17px; cursor: pointer;
  transition: transform .15s var(--ease), background .15s;
}
.icon-btn:active { transform: scale(.94); background: rgba(255,255,255,.12); }

.view { animation: rise .32s var(--ease) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page { padding-bottom: 8px; }

.page-head { margin-bottom: 14px; }
.page-head h1 {
  margin: 0;
  font-family: Syne, sans-serif;
  font-size: clamp(1.35rem, 5vw, 1.6rem);
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.linkish {
  appearance: none; border: 0; background: none; padding: 0;
  color: var(--cyan); font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

/* Cards / list */
.list { display: grid; gap: 10px; }
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(14px);
  padding: 14px;
}
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card-title {
  font-weight: 700; font-size: 15px; letter-spacing: -0.015em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.4; }
.card-text {
  margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}
.card-actions .btn { flex: 1 1 auto; min-width: calc(50% - 4px); }

.pill {
  display: inline-flex; align-items: center;
  padding: 4px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
  background: rgba(110, 26, 255, 0.22); color: #d9ceff;
}
.pill.active { background: rgba(0, 191, 255, 0.16); color: var(--cyan); }
.pill.finished { background: rgba(62, 230, 163, 0.14); color: var(--ok); }
.pill.cancelled { background: rgba(255, 107, 122, 0.14); color: #ffb4bc; }

.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 18px; border-radius: 999px;
  font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent) 55%, #9500ff);
  box-shadow: 0 10px 26px rgba(71, 26, 255, 0.38);
  transition: transform .15s var(--ease), filter .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.ghost {
  background: rgba(255,255,255,.08); box-shadow: none; color: var(--text);
}
.btn.danger { background: rgba(255, 107, 122, 0.18); color: #ffb4bc; box-shadow: none; }
.btn.sm { min-height: 40px; padding: 8px 12px; font-size: 13px; }
.btn.block, .form .btn.primary, .join-card .btn, .empty .btn, .pay-card .btn {
  width: 100%;
}

.sticky-cta {
  position: sticky;
  bottom: calc(var(--tab-h) + 8px + var(--safe-b));
  z-index: 5;
  margin-top: 16px;
  padding-top: 4px;
}
.sticky-cta .btn { width: 100%; box-shadow: 0 12px 32px rgba(71, 26, 255, 0.5); }

/* Form */
.form { display: grid; gap: 4px; }
.field { margin-bottom: 12px; display: block; }
.field > span {
  display: block; font-size: 12px; color: var(--muted);
  margin-bottom: 6px; font-weight: 600;
}
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 14px;
  background: rgba(0,0,0,.28); color: var(--text);
  padding: 12px 14px; font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
.field input:focus, .field textarea:focus {
  border-color: rgba(0, 191, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.12);
}
.field input[type="datetime-local"] { min-height: 48px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--line); background: rgba(255,255,255,.05);
  color: var(--muted); border-radius: 999px; padding: 10px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; min-height: 40px;
  transition: background .15s, border-color .15s, color .15s, transform .12s;
}
.chip.on {
  color: #fff; border-color: rgba(0, 191, 255, 0.5);
  background: rgba(71, 26, 255, 0.38);
}
.chip:active { transform: scale(.97); }

.check {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 16px; font-size: 14px; color: var(--text); cursor: pointer;
}
.check input {
  width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0;
}

/* Channels */
.channel-list { display: grid; gap: 8px; }
.channel-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  border: 1px solid var(--line); border-radius: 16px;
  background: rgba(255,255,255,.04); color: var(--text);
  padding: 12px 14px; cursor: pointer; font: inherit;
  min-height: 56px;
  transition: border-color .15s, background .15s, transform .12s;
}
.channel-row:active { transform: scale(.99); }
.channel-row.selected {
  border-color: rgba(0, 191, 255, 0.5);
  background: rgba(71, 26, 255, 0.28);
}
.channel-avatar {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px;
  background: linear-gradient(145deg, var(--accent-2), #9500ff);
  box-shadow: 0 8px 18px rgba(110, 26, 255, 0.35);
}
.channel-row strong { display: block; font-size: 14px; letter-spacing: -0.01em; }
.channel-row span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.channel-row > div:nth-child(2) { flex: 1; min-width: 0; }
.channel-row .ch-check {
  margin: 0; width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--cyan); color: #041018; font-size: 12px; font-weight: 800;
}

/* Tab bar */
.tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(480px, 100%);
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + var(--safe-b));
  background: rgba(13, 0, 26, 0.9);
  backdrop-filter: blur(18px) saturate(140%);
  border-top: 1px solid var(--line); z-index: 20;
}
.tabbar.with-pay { grid-template-columns: repeat(4, 1fr); }
.tabbar[hidden] { display: none !important; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 700;
  padding: 10px 4px; border-radius: 12px; cursor: pointer;
  min-height: 44px;
  transition: color .15s, background .15s;
}
.tab[hidden] { display: none !important; }
.tab.active {
  color: #fff;
  background: linear-gradient(180deg, rgba(110, 26, 255, 0.38), rgba(71, 26, 255, 0.12));
}

.empty {
  text-align: center; padding: 36px 12px 16px; color: var(--muted);
}
.empty h2 {
  margin: 0 0 8px; color: var(--text);
  font-family: Syne, sans-serif; font-size: 1.25rem; letter-spacing: -0.03em;
}
.empty p { margin: 0 0 18px; font-size: 14px; line-height: 1.45; }
.empty .btn, .empty a.btn { max-width: 280px; margin: 0 auto; }

.muted { color: var(--muted); }
.fine {
  margin: 14px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45;
}
.fine.center { text-align: center; }
.fine a { color: var(--cyan); font-weight: 600; text-decoration: none; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + var(--safe-b));
  transform: translateX(-50%) translateY(16px);
  background: #1a0d36; border: 1px solid rgba(0, 191, 255, 0.35);
  color: #fff; padding: 11px 14px; border-radius: 14px;
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: .3s var(--ease); z-index: 50; max-width: min(400px, 92vw);
  box-shadow: 0 16px 40px rgba(0,0,0,.45);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255, 107, 122, 0.5); }

/* Confirm sheet */
.sheet-root {
  position: fixed; inset: 0; z-index: 60;
  display: grid; align-items: end;
}
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.55);
  animation: fadeIn .2s ease both;
}
.sheet {
  position: relative;
  background: #160a2e; border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(18px + var(--safe-b));
  border: 1px solid var(--line); border-bottom: 0;
  animation: sheetUp .28s var(--ease) both;
  max-width: 480px; width: 100%; margin: 0 auto;
}
.sheet-handle {
  width: 36px; height: 4px; border-radius: 99px;
  background: rgba(255,255,255,.2); margin: 4px auto 14px;
}
.sheet h3 {
  margin: 0 0 6px; font-family: Syne, sans-serif; font-size: 1.2rem; letter-spacing: -0.03em;
}
.sheet p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.sheet-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: none; opacity: 1; }
}

/* Skeleton */
.skel-list { display: grid; gap: 10px; }
.skel-card {
  border-radius: 16px; padding: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}
.skel-line {
  height: 12px; border-radius: 8px; margin-bottom: 10px;
  background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.1), rgba(255,255,255,.04));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.skel-line:last-child { margin-bottom: 0; }
.skel-line.w40 { width: 40%; }
.skel-line.w60 { width: 60%; }
.skel-line.w80 { width: 80%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Join */
.join-card {
  text-align: center;
  padding: 28px 18px 20px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
}
.join-card h2 {
  margin: 0 0 8px;
  font-family: Syne, sans-serif;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}
.join-card .muted { margin: 0 0 18px; font-size: 14px; line-height: 1.45; }
.join-badge {
  display: inline-flex; margin-bottom: 12px;
  padding: 5px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  background: rgba(0, 191, 255, 0.14); color: var(--cyan);
}
.join-meta {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; text-align: left;
  margin: 0 0 18px; padding: 12px 14px;
  border-radius: 14px; background: rgba(255,255,255,.05); border: 1px solid var(--line);
}
.join-meta span { font-size: 12px; color: var(--muted); }
.join-meta strong {
  font-family: "IBM Plex Mono", monospace; font-size: 13px; font-weight: 600;
  word-break: break-all; text-align: right;
}
.join-hint { margin: 14px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.join-card.success { border-color: rgba(62, 230, 163, 0.35); }
.success-burst {
  width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(62, 230, 163, 0.35), transparent 70%),
    rgba(62, 230, 163, 0.12);
  border: 1px solid rgba(62, 230, 163, 0.4);
  animation: rise .4s var(--ease) both;
}
.success-burst::after {
  content: "✓";
  display: grid; place-items: center; height: 100%;
  font-size: 28px; font-weight: 800; color: var(--ok);
}
.need-list {
  text-align: left; margin: 0 0 16px; display: grid; gap: 8px;
}
.need-list div {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  font-size: 13px;
}
.need-list a { color: var(--cyan); font-weight: 700; text-decoration: none; }

/* Pay */
.pay-card {
  padding: 18px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(0, 191, 255, 0.28);
  background: var(--panel);
}
.pay-card h2 {
  margin: 0 0 8px;
  font-family: Syne, sans-serif; font-size: 1.3rem; letter-spacing: -0.03em;
}
.pay-card > p { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.pay-list {
  margin: 0 0 18px; padding-left: 18px;
  color: var(--muted); font-size: 14px; line-height: 1.55;
}
.pay-list li::marker { color: var(--cyan); }

/* Login (browser → MAX deep link) */
.login-card {
  text-align: center;
  padding: 28px 18px 22px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
}
.login-card h2 {
  margin: 0 0 8px;
  font-family: Syne, sans-serif;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
}
.login-card .muted {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.45;
}
.login-card .btn {
  width: 100%;
}
.login-status {
  margin: 16px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--cyan);
  line-height: 1.4;
}

/* Bind + media */
.bind-card {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}
.bind-card h2 {
  margin: 0 0 8px;
  font-family: Syne, sans-serif;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}
.bind-card > .muted { margin: 0 0 14px; font-size: 14px; line-height: 1.45; }
.bind-card > .btn { width: 100%; margin-bottom: 10px; }
.bind-card .field { margin-top: 4px; }

.media-field .media-pick {
  width: 100%;
  cursor: pointer;
  margin-top: 2px;
}
.media-field.locked {
  opacity: 0.85;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: rgba(255,255,255,.03);
}
.media-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 4px; padding: 12px 14px;
  border-radius: 14px; border: 1px solid rgba(0, 191, 255, 0.35);
  background: rgba(0, 191, 255, 0.08);
  font-size: 13px;
}
.media-chip strong {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn.block { width: 100%; }

/* Help */
.help-list { display: grid; gap: 8px; }
.help-list details {
  border: 1px solid var(--line); border-radius: 14px;
  background: rgba(255,255,255,.04); padding: 4px 12px;
}
.help-list summary {
  cursor: pointer; font-weight: 700; font-size: 14px;
  padding: 12px 0; list-style: none;
}
.help-list summary::-webkit-details-marker { display: none; }
.help-list summary::after {
  content: "+"; float: right; color: var(--cyan); font-weight: 800;
}
.help-list details[open] summary::after { content: "−"; }
.help-list p {
  margin: 0 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.45;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
