/* ==========================================================================
   KrakenTheMeta — dashboard ("the lair")
   Mobile first: a bottom tab bar + bottom sheets on phones, a rail + centred
   dialogs from 1024px. Same tokens, type and accents as the landing page, but
   calmer: this is a tool you work in, not a page you scroll through.
   ========================================================================== */

body.dash-page {
  background:
    radial-gradient(ellipse 80% 50% at 70% -10%, rgba(23, 68, 99, 0.22), transparent 60%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(12, 34, 56, 0.25), transparent 60%),
    var(--abyss-1);
  background-attachment: fixed;
  min-height: 100svh;
  --rail: 256px;
  --top: 64px;
  --tab: 68px;
  --danger: #ff8f84;
  --danger-rgb: 255, 143, 132;
  --win: #6fe3a6;
  --loss: #ff8f8f;
}
/* `hidden` always wins over a component's display (the builder panes opt out: on desktop they all show) */
.dash-page [hidden]:not([data-pane]) { display: none !important; }
:where(.dash-page) button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
:where(.dash-page) button:disabled { cursor: default; }
:where(.dash-page) a { text-decoration: none; }

/* ---------------------------------------------------------------- shell */

.app { min-height: 100svh; }

.rail { display: none; }

.stage { min-width: 0; min-height: 100svh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(var(--top) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) clamp(14px, 3vw, 32px) 0;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 10, 18, 0.8);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
}
.topbar__mark { display: grid; place-items: center; width: 34px; height: 34px; flex: none; }
.topbar__mark svg { width: 28px; height: 28px; filter: drop-shadow(0 0 8px rgba(var(--glow-rgb), 0.4)); }
.topbar__title { min-width: 0; flex: 1; }
.topbar__title h1 {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 22px;
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.topbar__avatar { width: 36px; height: 36px; border-radius: 50%; }
.topbar__avatar .avatar { width: 36px; height: 36px; }

.avatar {
  display: block;
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--abyss-3);
  box-shadow: 0 0 0 1px var(--line-2);
}

.view {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 36px) calc(var(--tab) + 40px + env(safe-area-inset-bottom));
  outline: none;
}
.view.is-entering { animation: view-in 0.35s var(--ease-out) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed;
  inset: auto 0 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  height: calc(var(--tab) + env(safe-area-inset-bottom));
  padding: 0 6px env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: rgba(3, 10, 18, 0.88);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  transition: color 0.2s;
}
.tabbar a .i { width: 22px; height: 22px; }
.tabbar a.is-active { color: var(--glow-hi); }
.tabbar a.is-active .i { filter: drop-shadow(0 0 8px rgba(var(--glow-rgb), 0.7)); }
.tabbar__create {
  justify-self: center;
  display: grid;
  place-items: center;
  width: 54px; height: 54px;
  margin-top: -22px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffc868, #ffab37);
  color: var(--lure-ink);
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, 0.7), 0 10px 26px -8px rgba(var(--lure-rgb), 0.7), 0 0 0 4px var(--abyss-1);
  transition: transform 0.2s var(--ease-out);
}
.tabbar__create .i { width: 26px; height: 26px; stroke-width: 2.2; }
.tabbar__create:active { transform: scale(0.95); }

.boot { display: grid; place-items: center; gap: 16px; min-height: 50vh; text-align: center; color: var(--ink-3); font-size: 12px; }
.boot__orb {
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(var(--glow-rgb), 0.5);
  box-shadow: 0 0 30px -4px rgba(var(--glow-rgb), 0.6);
  animation: orb 1.6s ease-in-out infinite;
}
@keyframes orb { 0%, 100% { transform: scale(0.85); opacity: 0.5; } 50% { transform: scale(1); opacity: 1; } }

@media (min-width: 1024px) {
  body.dash-page { --top: 72px; }
  .app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); }
  .tabbar, .topbar__mark, .topbar__avatar { display: none; }
  .view { padding-bottom: 64px; }
  .topbar__title h1 { font-size: 26px; }

  .rail {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 22px;
    height: 100svh;
    padding: 22px 16px 18px;
    border-right: 1px solid var(--line);
    background: rgba(2, 8, 14, 0.6);
    overflow-y: auto;
    scrollbar-width: none;
  }
  .rail__brand { padding: 0 8px; }
  .rail__create { width: 100%; }
  .rail__nav { display: flex; flex-direction: column; gap: 2px; }
  .rail__nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
    padding: 0 12px;
    border-radius: 11px;
    color: var(--ink-2);
    font-weight: 600;
    font-size: 15px;
    transition: background-color 0.2s, color 0.2s;
  }
  .rail__nav a .i { width: 20px; height: 20px; }
  .rail__nav a:hover { background: rgba(150, 205, 240, 0.06); color: var(--ink); }
  .rail__nav a.is-active { background: rgba(var(--glow-rgb), 0.1); color: var(--glow-hi); }
  .rail__nav a.is-active::before {
    content: "";
    position: absolute;
    left: -16px; top: 10px; bottom: 10px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--glow);
    box-shadow: 0 0 12px var(--glow);
  }
  .rail__explore { display: flex; flex-direction: column; gap: 2px; padding-top: 18px; border-top: 1px solid var(--line); }
  .rail__label { padding: 0 12px 8px; font: 500 10px/1 var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-4); }
  .rail__explore a { padding: 7px 12px; border-radius: 9px; font-size: 14px; color: var(--ink-3); transition: color 0.2s, background-color 0.2s; }
  .rail__explore a:hover { color: var(--ink); background: rgba(150, 205, 240, 0.05); }
  .rail__foot { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
  .rail__user {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px 8px 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    text-align: left;
    transition: border-color 0.2s, background-color 0.2s;
  }
  .rail__user:hover { border-color: var(--line-2); background: rgba(150, 205, 240, 0.04); }
  .rail__user-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; font-size: 14.5px; }
  .rail__user .i { width: 18px; height: 18px; color: var(--ink-3); }
}

/* ---------------------------------------------------------------- gens (AI builds left) */

.gens:empty { display: none; }
.gens--chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  font: 500 11.5px/1 var(--font-mono);
  color: var(--ink-2);
  white-space: nowrap;
}
.gens--chip .i { width: 15px; height: 15px; color: var(--glow); }
.gens--chip.is-out { border-color: rgba(var(--lure-rgb), 0.45); color: var(--lure-hi); }
.gens--chip.is-out .i { color: var(--lure); }
@media (min-width: 1024px) { .gens--chip { display: none; } }
@media (max-width: 380px) { .gens--chip span { display: none; } }

.rail .gens {
  padding: 14px 14px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(12, 32, 52, 0.5), rgba(6, 18, 32, 0.6));
}
.gens__label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; white-space: nowrap; font: 500 10px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.gens__num { margin-top: 8px; font: 500 26px/1 var(--font-display); letter-spacing: -0.02em; }
.gens__num small { margin-left: 6px; font: 400 13px var(--font-ui); letter-spacing: 0; color: var(--ink-3); }
.gens__meter { height: 4px; margin: 10px 0 8px; overflow: hidden; border-radius: 4px; background: var(--line); }
.gens__meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--glow), var(--glow-hi)); box-shadow: 0 0 10px var(--glow); }
.gens__note { font-size: 12.5px; color: var(--ink-3); }
.gens__note a, .gens__note button { color: var(--lure-hi); font-weight: 600; }

/* ---------------------------------------------------------------- notifications */

.bell { position: relative; }
.bell__count {
  position: absolute;
  top: 3px; right: 3px;
  min-width: 17px; height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--lure);
  color: var(--lure-ink);
  font: 700 10px/17px var(--font-ui);
  text-align: center;
}
.bell__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: min(360px, calc(100vw - 24px));
  max-height: min(70vh, 480px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: rgba(7, 20, 35, 0.98);
  box-shadow: var(--shadow-deep);
  animation: pop-in 0.18s var(--ease-out);
}
.bell__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.bell__head p { font: 500 10.5px/1 var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.bell__list { margin: 0; padding: 6px; list-style: none; overflow-y: auto; }
.bell__list li { padding: 11px 12px; border-radius: 10px; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.bell__list li + li { border-top: 1px solid var(--line); border-radius: 0; }
.bell__list li.is-new { color: var(--ink); }
.bell__list li time { display: block; margin-top: 4px; font: 400 11px var(--font-mono); color: var(--ink-4); }
.bell__empty { padding: 26px 16px; text-align: center; font-size: 14px; color: var(--ink-3); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- the brewing screen */

.brew {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  background:
    radial-gradient(ellipse 70% 50% at 50% 25%, rgba(23, 68, 99, 0.4), transparent 65%),
    rgba(1, 4, 9, 0.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: fade 0.3s ease;
}
.brew[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.brew__card { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(560px, 100%); text-align: center; }
.brew__sonar { position: relative; width: 96px; height: 96px; }
.brew__sonar i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(var(--glow-rgb), 0.7);
  animation: sonar 2.4s var(--ease-out) infinite;
}
.brew__sonar i:nth-child(2) { animation-delay: 0.8s; }
.brew__sonar i:nth-child(3) { animation-delay: 1.6s; }
.brew__sonar svg { position: absolute; inset: 26px; width: 44px; height: 44px; filter: drop-shadow(0 0 14px rgba(var(--glow-rgb), 0.8)); animation: bob-mark 3s ease-in-out infinite; }
@keyframes sonar { from { transform: scale(0.35); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
@keyframes bob-mark { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.brew h2 { font-size: clamp(28px, 5vw, 38px); letter-spacing: -0.02em; }
.brew__prompt { max-width: 46ch; font: italic 400 17px/1.45 var(--font-display); color: var(--ink-2); }
.brew__stages { display: flex; flex-direction: column; gap: 4px; width: 100%; margin: 4px 0; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: rgba(4, 14, 25, 0.7); text-align: left; }
.brew__stage { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; color: var(--ink-4); transition: color 0.4s, background-color 0.4s; }
.brew__stage .dot { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border: 1px solid var(--line-2); border-radius: 9px; transition: all 0.4s; }
.brew__stage .dot .i { width: 16px; height: 16px; }
.brew__stage b { display: block; font-size: 15px; font-weight: 650; }
.brew__stage small { display: block; font-size: 13px; color: var(--ink-4); }
.brew__stage.is-live { color: var(--ink); background: rgba(var(--glow-rgb), 0.07); }
.brew__stage.is-live .dot { color: var(--glow-hi); border-color: rgba(var(--glow-rgb), 0.55); box-shadow: 0 0 20px -4px rgba(var(--glow-rgb), 0.7); animation: orb 1.4s ease-in-out infinite; }
.brew__stage.is-live small { color: var(--ink-3); }
.brew__stage.is-done { color: var(--ink-2); }
.brew__stage.is-done .dot { color: var(--glow); border-color: rgba(var(--glow-rgb), 0.35); }
.brew__time { font: 500 12px/1 var(--font-mono); letter-spacing: 0.08em; color: var(--ink-3); }
.brew__note { font-size: 13px; color: var(--ink-4); }
.brew__promo {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(var(--glow-rgb), 0.25);
  border-radius: 16px;
  background: rgba(6, 20, 34, 0.8);
  text-align: left;
}
.brew__promo video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; background: #000; }
.brew__promo h4 { font: 500 18px/1.2 var(--font-display); }
.brew__promo p { margin: 6px 0 10px; font-size: 13.5px; color: var(--ink-3); }
@media (max-width: 520px) { .brew__promo { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- home */

.greet { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 20px; }
.greet h2 { font-size: clamp(30px, 5vw, 46px); letter-spacing: -0.028em; line-height: 1.02; }
.greet p { color: var(--ink-3); font-size: 15.5px; }

.composer {
  position: relative;
  padding: clamp(14px, 2vw, 18px);
  border: 1px solid var(--line-2);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(12, 34, 56, 0.66), rgba(5, 18, 32, 0.8));
  box-shadow: var(--shadow-deep), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.composer::before {
  content: "";
  position: absolute;
  inset: -1px;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(var(--glow-rgb), 0.6), transparent 35%, transparent 65%, rgba(var(--lure-rgb), 0.5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.3s;
}
.composer:focus-within::before { opacity: 1; }
.composer__label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.composer__label .depth-tag { font-size: 10.5px; }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 84px;
  padding: 4px 2px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  font: 400 clamp(17px, 2vw, 20px)/1.45 var(--font-ui);
}
.composer textarea::placeholder { color: var(--ink-4); }
.composer__row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.composer__row .seg { flex: 1 1 auto; }
.composer__go { margin-left: auto; }
.composer__meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--ink-3); }
@media (max-width: 640px) {
  .composer__go { width: 100%; }
  .composer__row .seg { width: 100%; }
}

.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.quick button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 24, 40, 0.45);
  text-align: left;
  transition: border-color 0.25s, background-color 0.25s, transform 0.25s var(--ease-out);
}
.quick button:hover { border-color: var(--line-2); background: rgba(10, 30, 50, 0.6); transform: translateY(-1px); }
.quick .i { width: 22px; height: 22px; flex: none; color: var(--glow); }
.quick b { display: block; font-size: 14.5px; font-weight: 650; }
.quick small { display: block; font-size: 12.5px; color: var(--ink-3); }
@media (max-width: 640px) {
  .quick { grid-template-columns: 1fr; }
  .quick button { min-height: 52px; }
}

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; margin-top: 8px; }
@media (min-width: 1100px) { .home-grid { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } .home-side .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.procard { padding: 22px; border: 1px solid rgba(241, 197, 108, 0.3); border-radius: 20px; background: linear-gradient(180deg, rgba(46, 33, 12, 0.45), rgba(10, 20, 30, 0.7)); box-shadow: 0 0 60px -34px rgba(241, 197, 108, 0.5); }
.procard h3 { display: flex; align-items: center; justify-content: space-between; gap: 10px; font: 500 22px/1.1 var(--font-display); color: var(--gold); }
.procard p { margin-top: 8px; font-size: 14px; color: var(--ink-2); }
.procard ul { display: flex; flex-direction: column; gap: 9px; margin: 16px 0 18px; padding: 0; list-style: none; font-size: 14px; color: var(--ink-2); }
.procard li { display: flex; gap: 9px; }
.procard li .i { width: 17px; height: 17px; flex: none; margin-top: 2px; color: var(--gold); stroke-width: 2; }
.procard small { display: block; margin-top: 10px; text-align: center; font-size: 12px; color: var(--ink-4); }
.procard--on { border-color: rgba(var(--glow-rgb), 0.3); background: linear-gradient(180deg, rgba(10, 36, 48, 0.55), rgba(6, 18, 32, 0.7)); box-shadow: none; }
.procard--on h3 { color: var(--glow-hi); }

/* ---------------------------------------------------------------- builder */

.bhero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 14px;
  min-height: 210px;
  padding: 18px clamp(16px, 2.6vw, 26px) clamp(16px, 2.4vw, 22px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: radial-gradient(ellipse at 80% 0%, rgba(23, 68, 99, 0.4), transparent 60%), var(--abyss-2);
  isolation: isolate;
}
.bhero__art { position: absolute; inset: 0; z-index: -2; background-size: cover; background-position: center 28%; opacity: 0.55; transform: scale(1.02); transition: opacity 0.6s; }
.bhero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(3, 10, 18, 0.96) 0%, rgba(3, 10, 18, 0.55) 55%, rgba(3, 10, 18, 0.25) 100%), linear-gradient(90deg, rgba(3, 10, 18, 0.7), transparent 70%); }
.bhero__back { position: absolute; top: 14px; left: 14px; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 8px; border-radius: 10px; background: rgba(2, 8, 14, 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.bhero__back .i { width: 18px; height: 18px; }
.bhero__back:hover { color: var(--ink); }
.bhero__title { min-width: 0; }
.bhero__title h2 { font-size: clamp(26px, 4vw, 40px); letter-spacing: -0.024em; line-height: 1.04; overflow-wrap: anywhere; }
.bhero__title .iconbtn { display: inline-grid; margin-left: 4px; vertical-align: 0.12em; }
.bhero__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 14px; color: var(--ink-2); }
.bhero__count { display: inline-flex; align-items: center; gap: 10px; font: 500 12.5px/1 var(--font-mono); }
.bhero__count b { color: var(--ink); font-weight: 500; }
.bhero__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@media (min-width: 900px) { .bhero__actions { flex: none; flex-wrap: nowrap; } .bhero__main { flex: 1 1 auto; } }
.bhero__actions .iconbtn { background: rgba(2, 8, 14, 0.5); border: 1px solid var(--line-2); }
@media (min-width: 900px) {
  .bhero { flex-direction: row; align-items: flex-end; justify-content: space-between; min-height: 240px; }
  .bhero__main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
}

.bhero__main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bhero.skel { min-height: 220px; }
.dlist__bar .seg { padding: 3px; }
.dlist__bar .seg button { height: 30px; padding: 0 10px; font-size: 13px; }

.btabs { position: sticky; top: calc(var(--top) + env(safe-area-inset-top)); z-index: 20; margin: 14px -4px 0; padding: 10px 4px; background: linear-gradient(180deg, var(--abyss-1) 70%, transparent); }
@media (min-width: 1100px) { .btabs { display: none; } }

.bgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; margin-top: 12px; }
.bgrid > [data-pane][hidden] { display: none; }
@media (min-width: 1100px) {
  .bgrid { grid-template-columns: minmax(0, 1fr) 420px; align-items: start; margin-top: 18px; }
  .bgrid > [data-pane][hidden] { display: block; }
  .bgrid > [data-pane="add"] { position: sticky; top: calc(var(--top) + 18px); max-height: calc(100svh - var(--top) - 36px); display: flex; flex-direction: column; }
  .bgrid > [data-pane="stats"], .bgrid > [data-pane="stats"][hidden] { grid-column: 1; grid-row: 1; display: grid; }
  .bgrid > [data-pane="deck"] { grid-column: 1; grid-row: 2; }
  .bgrid > [data-pane="add"], .bgrid > [data-pane="add"][hidden] { grid-column: 2; grid-row: 1 / span 2; align-self: start; display: flex; }
}

/* add-cards panel */
.addp { display: flex; flex-direction: column; min-height: 0; }
.addp__tabs { padding: 12px 12px 0; }
.addp__body { flex: 1; min-height: 0; padding: 12px; overflow-y: auto; }

/* AI form (shared by the create sheet and the builder) */
.aiform { display: flex; flex-direction: column; gap: 14px; }
.aiform__prompt .textarea { min-height: 110px; font-size: 16px; }
.aiform details { border: 1px solid var(--line); border-radius: 14px; background: rgba(1, 6, 12, 0.35); }
.aiform summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); list-style: none; }
.aiform summary::-webkit-details-marker { display: none; }
.aiform summary .i { width: 18px; height: 18px; color: var(--ink-3); transition: transform 0.3s var(--ease-out); }
.aiform details[open] summary .i { transform: rotate(180deg); }
.aiform__adv { display: flex; flex-direction: column; gap: 14px; padding: 4px 14px 16px; }
.aiform__adv > .field + .field { margin-top: 0; } /* the flex gap spaces them */
.aiform__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 520px) { .aiform__row { grid-template-columns: 1fr; } }
.aiform__sub { margin-left: 28px; }
.nudge { padding: 14px; border: 1px solid rgba(var(--glow-rgb), 0.3); border-radius: 14px; background: rgba(var(--glow-rgb), 0.06); font-size: 14px; color: var(--ink-2); }
.nudge__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.gensline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
.gensline .i { width: 16px; height: 16px; color: var(--glow); }
.gensline.is-out .i { color: var(--lure); }
.upsell { display: flex; flex-direction: column; gap: 12px; padding: 20px; border: 1px solid rgba(241, 197, 108, 0.35); border-radius: 18px; background: linear-gradient(180deg, rgba(46, 33, 12, 0.5), rgba(10, 20, 30, 0.7)); text-align: center; }
.upsell h3 { font: 500 22px/1.2 var(--font-display); color: var(--gold); }
.upsell p { font-size: 14px; color: var(--ink-2); }
.upsell ul { display: flex; flex-direction: column; gap: 8px; margin: 4px auto; padding: 0; list-style: none; font-size: 14px; color: var(--ink-2); text-align: left; }
.upsell li { display: flex; gap: 8px; }
.upsell li .i { width: 16px; height: 16px; flex: none; margin-top: 3px; color: var(--gold); }

/* create sheet: three ways in */
.ways { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.ways button { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; text-align: left; transition: border-color 0.2s, background-color 0.2s; }
.ways button:hover, .ways button.is-on { border-color: rgba(var(--glow-rgb), 0.4); background: rgba(var(--glow-rgb), 0.06); }
.ways .ico { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px; border: 1px solid var(--line-2); color: var(--glow); }
.ways .ico .i { width: 20px; height: 20px; }
.ways b { display: block; font-size: 15.5px; font-weight: 650; }
.ways small { display: block; margin-top: 2px; font-size: 13px; color: var(--ink-3); }
.ways .is-primary .ico { color: var(--lure-ink); background: linear-gradient(180deg, #ffc868, #ffab37); border-color: transparent; }

/* ---------------------------------------------------------------- collection */

.clist { display: flex; flex-direction: column; padding: 6px; }
.clist .drow { grid-template-columns: 34px minmax(0, 1fr) auto auto; }
.clist .drow__name .i { color: var(--glow); }
@media (max-width: 480px) { .clist .drow { grid-template-columns: 30px minmax(0, 1fr) auto; } }
.coll-more { display: flex; justify-content: center; padding: 18px 0 4px; }
.coll-more:empty { display: none; }
.chip .i { width: 15px; height: 15px; }
.input--sm { min-height: 38px; font-size: 14px; }
.row > .input { flex: 1; min-width: 0; }
.actionlist small { font-weight: 400; }
.brow { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto auto auto; align-items: center; gap: 8px; }
.brow > .i { width: 18px; height: 18px; color: var(--glow); }
.brow__n { font: 400 11.5px/1 var(--font-mono); color: var(--ink-3); white-space: nowrap; }
@media (max-width: 420px) { .brow__n { display: none; } .brow { grid-template-columns: 20px minmax(0, 1fr) auto auto; } }
.codebox { margin: 0; padding: 10px 12px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: rgba(1, 6, 12, 0.6); font: 400 12.5px/1.6 var(--font-mono); color: var(--ink-2); white-space: pre; }

/* ---------------------------------------------------------------- arena */

.arows { display: flex; flex-direction: column; }
.arow {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  transition: background-color 0.15s;
}
.arow + .arow { border-top: 1px solid var(--line); border-radius: 0; }
.arow:hover { background: rgba(150, 205, 240, 0.05); }
.result {
  display: grid;
  place-items: center;
  height: 26px;
  border-radius: 7px;
  font: 500 10.5px/1 var(--font-mono);
  letter-spacing: 0.12em;
  border: 1px solid var(--line-2);
  color: var(--ink-3);
}
.result.win { color: var(--win); border-color: rgba(111, 227, 166, 0.4); background: rgba(111, 227, 166, 0.08); }
.result.loss { color: var(--loss); border-color: rgba(255, 143, 143, 0.4); background: rgba(255, 143, 143, 0.07); }
.arow__main { min-width: 0; }
.arow__line { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14.5px; color: var(--ink); }
.arow__sub { margin-top: 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12.5px; color: var(--ink-3); }
.arow__when { font: 400 11.5px/1 var(--font-mono); color: var(--ink-4); }
.adeck { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px; }
.adeck + .adeck { border-top: 1px solid var(--line); }
.adeck__name { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.adeck__meta { margin-top: 4px; font-size: 13px; color: var(--ink-3); }
.adeck__meta .w { color: var(--win); font-weight: 600; }
.adeck__meta .l { color: var(--loss); font-weight: 600; }
.adeck__acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.adeck__cards { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.adeck__cards span { padding: 4px 8px; border-radius: 7px; background: rgba(150, 205, 240, 0.06); font-size: 12.5px; color: var(--ink-2); }
@media (max-width: 560px) { .adeck { grid-template-columns: 1fr; } .adeck__acts { justify-content: flex-start; } }

/* ---------------------------------------------------------------- profile */

.pgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1000px) { .pgrid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: start; } }
.pgrid > .panel h3 { margin-bottom: 16px; font: 500 21px/1.2 var(--font-display); letter-spacing: -0.01em; }
.plan-rows { display: flex; flex-direction: column; }
.plan-rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.plan-rows > div span:first-child { color: var(--ink-3); }
.plan-rows > div span:last-child { text-align: right; }
.avatars { display: flex; flex-wrap: wrap; gap: 10px; }
.avatars label { position: relative; cursor: pointer; }
.avatars input { position: absolute; opacity: 0; }
.avatars img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px transparent; transition: box-shadow 0.2s, transform 0.2s; }
.avatars input:checked + img { box-shadow: 0 0 0 3px var(--glow), 0 0 18px -2px rgba(var(--glow-rgb), 0.8); }
.avatars input:focus-visible + img { outline: 2px solid var(--glow); outline-offset: 3px; }
.purchases { display: flex; flex-direction: column; }
.purchases div { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.purchases span:last-child { font: 400 12px var(--font-mono); color: var(--ink-3); }
.savebar {
  position: sticky;
  bottom: calc(var(--tab) + 12px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px 12px 18px;
  border: 1px solid rgba(var(--lure-rgb), 0.35);
  border-radius: 16px;
  background: rgba(7, 20, 35, 0.96);
  box-shadow: var(--shadow-deep);
  font-size: 14px;
  color: var(--ink-2);
  animation: toast-in 0.3s var(--ease-out);
}
@media (min-width: 1024px) { .savebar { bottom: 16px; } }
.danger-zone { border-color: rgba(var(--danger-rgb), 0.3); }
.danger-zone h3 { color: var(--danger); }
