/* Aurora Glass — the dark violet, semi-transparent look from the
   myaimodelmanager app (public/css/design-system.css). Tokens mirror the
   --ds-* set there so the two products read as one family. */

:root {
  /* Surfaces */
  --bg: #0a0810;              /* violet-black page */
  --bg-elev: #15131c;         /* raised panel */
  --bg-elev-2: #1c1926;       /* hover / nested */

  /* Glass — every panel is a frosted sheet over the aurora backdrop */
  --glass: rgba(255, 255, 255, .045);
  --glass-strong: rgba(255, 255, 255, .08);
  --glass-border: rgba(255, 255, 255, .10);
  --blur: 18px;

  /* Brand */
  --accent: #8240ff;
  --accent-soft: #b58afe;
  --brand-grad: linear-gradient(135deg, #8240ff, #b58afe);
  --brand-grad-hover: linear-gradient(135deg, #9257ff, #c7a4ff);
  --brand-glow: 0 6px 24px rgba(130, 64, 255, .35);

  /* Text */
  --fg: #f4f4f5;
  --muted: #b9b9c0;
  --dim: #7c7c85;

  /* Lines */
  --border: rgba(255, 255, 255, .08);

  /* Status */
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #fb7185;

  /* Radii + motion */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;
  --t-fast: .16s ease;
  --t: .26s cubic-bezier(.22, 1, .36, 1);

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
}

/* Aurora: two fixed violet blooms behind everything, so the frosted panels
   have something to be translucent *over*. Fixed, not scrolling, so the glow
   stays put while content moves. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60vw 60vw at 12% -10%, rgba(130, 64, 255, .22), transparent 60%),
    radial-gradient(50vw 50vw at 95% 8%, rgba(181, 138, 254, .14), transparent 60%),
    radial-gradient(70vw 50vw at 50% 110%, rgba(130, 64, 255, .10), transparent 65%);
}

a { color: var(--accent-soft); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 16px 72px; }
h1 { font-size: 22px; margin: 0 0 16px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }

/* header / nav */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.nav { display: flex; gap: 8px; align-items: center; }
.nav a {
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 8px 15px; border-radius: var(--r-pill);
  background: var(--glass); border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
  transition: background var(--t-fast), color var(--t-fast);
}
.nav a:hover { color: var(--fg); background: var(--glass-strong); }
.nav a.active {
  background: var(--brand-grad); border-color: transparent; color: #fff;
  box-shadow: var(--brand-glow);
}

/* layout */
.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.dim { color: var(--dim); font-size: 12px; }

/* form controls */
input[type=text], input[type=number], input[type=search], input[type=password], select, textarea {
  background: rgba(0, 0, 0, .28);
  border: 1px solid var(--glass-border);
  color: var(--fg);
  border-radius: var(--r-sm);
  padding: 10px 12px; font-size: 14px; outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input[type=text], input[type=search], input[type=password] { flex: 1; min-width: 240px; }
input[type=number] { width: 90px; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(130, 64, 255, .55);
  box-shadow: 0 0 0 3px rgba(130, 64, 255, .16);
}
input::placeholder, textarea::placeholder { color: var(--dim); }
textarea { width: 100%; min-height: 70px; margin-top: 10px; font-family: monospace; }
.field { margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label.field { display: block; }
.field > span { display: block; margin-bottom: 6px; }
.field input, .field textarea, .field select { width: 100%; font-family: inherit; margin-top: 0; }
.field textarea { min-height: 80px; }
[hidden] { display: none !important; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
label.check input { accent-color: var(--accent); width: 16px; height: 16px; }

button {
  background: var(--brand-grad); border: none; color: #fff;
  padding: 10px 18px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform var(--t-fast), background var(--t), box-shadow var(--t);
}
button:hover:not(:disabled) { background: var(--brand-grad-hover); transform: translateY(-1px); }
button:disabled { opacity: .45; cursor: default; box-shadow: none; }
button.secondary {
  background: var(--glass); border: 1px solid var(--glass-border); color: var(--fg);
  box-shadow: none;
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
}
button.secondary:hover:not(:disabled) { background: var(--glass-strong); }
button.danger { background: transparent; border: 1px solid rgba(251, 113, 133, .5); color: var(--err); box-shadow: none; }
button.danger:hover:not(:disabled) { background: rgba(251, 113, 133, .12); }

details { margin-top: 10px; color: var(--muted); font-size: 13px; }
details summary { cursor: pointer; }

/* login cookies — the two values X actually needs, side by side */
.cookie-grid { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0 4px; }
.cookie-grid .field { flex: 1 1 260px; margin-bottom: 0; }
.cookie-grid .field input { min-width: 0; font-family: monospace; font-size: 12px; }
#cookieMsg small { color: var(--dim); word-break: break-word; }
#cookieAdv { margin-top: 14px; }

/* messages */
.msg { margin-top: 12px; font-size: 14px; }
.msg.warn { color: var(--warn); }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--accent-soft); border-top-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
  margin-right: 8px; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* tabs */
.tabs { display: flex; gap: 8px; margin: 16px 0; }
.tab {
  background: var(--glass); border: 1px solid var(--glass-border); color: var(--muted);
  padding: 8px 16px; border-radius: var(--r-pill); font-weight: 600; box-shadow: none;
}
.tab:hover:not(.active) { background: var(--glass-strong); transform: none; }
.tab.active { background: var(--brand-grad); border-color: transparent; color: #fff; box-shadow: var(--brand-glow); }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* media grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.cell {
  position: relative;
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: var(--r-md); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.cell:hover { border-color: rgba(130, 64, 255, .35); }
.cell.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--brand-glow); }
.thumb { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #000; }
.vthumb {
  position: relative; display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 32px; cursor: pointer;
}
.vthumb .poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vthumb .play {
  position: relative; z-index: 1;
  width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; padding-left: 4px;
  background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .35);
  backdrop-filter: blur(4px);
  transition: transform var(--t-fast), background var(--t-fast);
}
.vthumb:hover .play { transform: scale(1.08); background: rgba(0, 0, 0, .75); }
.vthumb .dur {
  position: absolute; right: 8px; bottom: 8px; z-index: 1;
  font-size: 11px; font-weight: 600; color: #fff;
  background: rgba(0, 0, 0, .65); border-radius: var(--r-sm); padding: 2px 6px;
}
video.thumb { object-fit: contain; }

/* inline player — replaces the .vthumb once a preview is clicked */
.vplayer { position: relative; background: #000; }
.vplayer video {
  width: 100%; height: 100%; aspect-ratio: 1;
  object-fit: contain; display: block; background: #000;
}
.vstate {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 12px; text-align: center;
  font-size: 12px; color: #fff; background: rgba(0, 0, 0, .6);
  pointer-events: none;   /* never sits between the user and the controls */
}
.vstate.err { pointer-events: auto; color: var(--warn); }
.vstate-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.vstate-actions button, .vstate-actions a {
  font-size: 11px; padding: 5px 10px; border-radius: var(--r-sm);
  text-decoration: none; color: var(--fg);
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  box-shadow: none;
}
.vstate-actions button:hover, .vstate-actions a:hover { background: var(--accent); transform: none; }
.meta { padding: 8px 10px; font-size: 12px; color: var(--muted); flex: 1; overflow: hidden; }
.meta .text { max-height: 3.6em; overflow: hidden; color: var(--dim); }
.actions { display: flex; gap: 6px; padding: 0 10px 10px; }
.actions a, .actions button {
  flex: 1; text-align: center; font-size: 12px; padding: 6px 8px;
  border-radius: var(--r-sm); text-decoration: none;
  border: 1px solid var(--glass-border); color: var(--fg);
  background: var(--glass); font-weight: 600; cursor: pointer; box-shadow: none;
}
.actions a:hover, .actions button:hover:not(:disabled) { background: var(--glass-strong); transform: none; }
.actions a.dl { background: var(--brand-grad); border-color: transparent; color: #fff; }
.pick { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; z-index: 1; }

/* view toggle — grid vs feed */
.viewtoggle { display: inline-flex; gap: 4px; padding: 3px; border-radius: var(--r-pill);
  background: var(--glass); border: 1px solid var(--glass-border); }
.viewtoggle button {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 30px; padding: 0; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--muted); cursor: pointer; box-shadow: none;
}
.viewtoggle button:hover:not(.active) { background: var(--glass-strong); color: var(--fg); transform: none; }
.viewtoggle button.active { background: var(--brand-grad); color: #fff; box-shadow: var(--brand-glow); }
.viewtoggle svg { width: 17px; height: 17px; display: block; }

/* video feed — a full-screen player over the page, one video per screen
   (two side by side once there is width for it), swiped with scroll snap. */
.feedscreen {
  position: fixed; inset: 0; z-index: 60;
  background: #000; display: flex; flex-direction: column;
}
.feedscreen[hidden] { display: none; }   /* flex would otherwise outrank [hidden] */
body.feed-open { overflow: hidden; }     /* the page behind must not scroll along */
.feedtrack {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr; grid-auto-rows: 100%;
  overflow-y: auto; overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
}
@media (min-width: 860px) { .feedtrack { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.feedtrack .empty { color: var(--muted); align-self: center; text-align: center; padding: 24px; }
.fcell { position: relative; height: 100%; overflow: hidden; background: #000; scroll-snap-align: start; }
.fcell video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }

/* controls float over the video, out of the way of the exit button */
.fexit {
  position: absolute; z-index: 2;
  top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .35);
  backdrop-filter: blur(4px); box-shadow: none;
}
.fexit:hover { background: rgba(0, 0, 0, .8); transform: none; }
.fexit svg { width: 20px; height: 20px; display: block; }
.fsound {
  position: absolute; z-index: 1;
  left: 50%; transform: translateX(-50%);
  top: calc(14px + env(safe-area-inset-top));
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: #fff; padding: 6px 12px;
  border-radius: var(--r-pill); border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px);
  pointer-events: none; white-space: nowrap;
}
.fpick {
  position: absolute; z-index: 2;
  top: calc(16px + env(safe-area-inset-top)); left: calc(14px + env(safe-area-inset-left));
  width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer;
}
.finfo {
  position: absolute; z-index: 1; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; gap: 8px;
  padding: 40px 16px calc(18px + env(safe-area-inset-bottom));
  color: #fff; font-size: 13px;
  background: linear-gradient(to top, rgba(0, 0, 0, .85), rgba(0, 0, 0, 0));
}
.finfo .who { font-weight: 600; }
.finfo .text { color: rgba(255, 255, 255, .78); max-height: 3.6em; overflow: hidden; }
.finfo .actions { padding: 0; }
.finfo .actions a { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); color: #fff; }
.finfo .actions a.dl { background: var(--brand-grad); border-color: transparent; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: var(--r-pill);
  background: rgba(130, 64, 255, .16); border: 1px solid rgba(130, 64, 255, .35);
  color: var(--accent-soft);
}
.badge.ok { background: rgba(52, 211, 153, .14); border-color: rgba(52, 211, 153, .35); color: var(--ok); }
.badge.off { background: var(--glass); border-color: var(--glass-border); color: var(--dim); }

/* modal */
.backdrop {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(10, 8, 16, .72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.backdrop[hidden] { display: none; }
.modal {
  background: var(--bg-elev); border: 1px solid var(--glass-border);
  border-radius: var(--r-lg); padding: 22px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-md);
}
.modal h2 { margin-bottom: 14px; }

/* remote character picker */
.picker-search { margin-bottom: 8px; }
.picker {
  display: grid; gap: 8px;
  max-height: 340px; overflow-y: auto;
  padding: 4px; margin: 0 -4px;
}
.pcard {
  display: flex; gap: 12px; align-items: center; text-align: left;
  width: 100%; padding: 8px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: var(--r-md); box-shadow: none; color: var(--fg);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.pcard:hover:not(:disabled) { background: var(--bg-elev-2); border-color: rgba(130, 64, 255, .35); transform: none; }
.pcard.picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--brand-glow); }
.pthumb {
  flex: none; width: 56px; height: 56px; border-radius: var(--r-sm);
  object-fit: cover; background: var(--bg-elev-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: var(--dim);
}
.pthumb.new { background: rgba(130, 64, 255, .16); color: var(--accent-soft); }
.pbody { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pname { font-size: 14px; font-weight: 600; color: var(--fg); }
.pintro {
  font-size: 12px; color: var(--muted); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pmeta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 2px; }
.ptag {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: var(--r-pill);
  background: rgba(130, 64, 255, .14); color: var(--accent-soft);
}
.pdate { font-size: 10px; color: var(--dim); }
.pempty { padding: 6px 2px; }

/* search history chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 4px 6px 4px 11px; border-radius: var(--r-pill);
  background: var(--glass); border: 1px solid var(--glass-border);
  cursor: pointer; transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.chip:hover { background: var(--glass-strong); color: var(--fg); border-color: rgba(130, 64, 255, .35); }
.chip .n { font-size: 10px; color: var(--dim); }
.chip .x {
  background: none; border: none; box-shadow: none; padding: 0;
  width: 16px; height: 16px; line-height: 1; font-size: 13px;
  color: var(--dim); border-radius: 50%;
}
.chip .x:hover:not(:disabled) { background: rgba(251, 113, 133, .16); color: var(--err); transform: none; }

/* --- site brandmark (landing page header) --- */
.brandmark { display: flex; align-items: center; gap: 12px; flex: 1 1 460px; min-width: 0; }
.brandmark img { border-radius: var(--r-sm); flex: none; }
.brandmark h1 { margin: 0; }
.tagline { margin: 3px 0 0; color: var(--muted); font-size: 13px; max-width: 52ch; }

/* --- MyAIModelManager promo --- */
.promo {
  display: flex; gap: 14px; align-items: flex-start;
  background: linear-gradient(135deg, rgba(130, 64, 255, .14), rgba(181, 138, 254, .06));
  border: 1px solid rgba(130, 64, 255, .30);
  border-radius: var(--r-lg); padding: 16px 18px; margin-bottom: 16px;
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
}
.promo-logo { border-radius: var(--r-sm); flex: none; }
.promo-body { flex: 1; min-width: 0; }
.promo-body h2 { margin: 0 0 6px; font-size: 15px; }
.promo-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.promo-body b { color: var(--fg); font-weight: 600; }
.promo-cta {
  display: inline-block; margin-top: 12px; padding: 9px 16px;
  background: var(--brand-grad); color: #fff; text-decoration: none;
  font-size: 13px; font-weight: 600; border-radius: var(--r-pill);
  box-shadow: var(--brand-glow); transition: background var(--t-fast);
  white-space: nowrap;
}
.promo-cta:hover { background: var(--brand-grad-hover); color: #fff; }

/* slim variant: CTA sits inline on the right */
.promo-slim { align-items: center; }
.promo-slim .promo-cta { margin-top: 0; flex: none; align-self: center; }
@media (max-width: 700px) {
  .promo, .promo-slim { flex-wrap: wrap; }
  .promo-slim .promo-cta { margin-top: 4px; }
}

/* --- narrow screens ---------------------------------------------------
   Flex children default to min-width:auto, so long placeholders (the
   username field, the promo copy) pushed the page wider than the phone
   viewport. Let them shrink, and give the primary inputs a full row. */
img, video { max-width: 100%; }
.row > *, .toolbar > *, .promo > * { min-width: 0; }

@media (max-width: 640px) {
  .wrap { padding-left: 14px; padding-right: 14px; }
  .row > input[type=text],
  .row > input[type=search],
  .row > input[type=number] { flex: 1 1 100%; }
  .row > button, .toolbar > .row > button { flex: 1 1 auto; }
  .promo, .promo-slim { flex-direction: column; align-items: flex-start; }
  .promo-slim .promo-cta { margin-top: 10px; align-self: flex-start; }
  .promo-cta { white-space: normal; }
  .brandmark { flex-basis: 100%; }
  .tagline { max-width: none; }
}

/* --- long-form copy at the foot of the landing page --- */
.seo { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--border); max-width: 74ch; }
.seo h2 { font-size: 20px; margin: 0 0 12px; }
.seo h3 { font-size: 15px; margin: 28px 0 10px; }
.seo p { color: var(--muted); font-size: 14px; line-height: 1.7; margin: 0 0 12px; }
.seo a { color: var(--accent); }
.seo b { color: var(--fg); font-weight: 600; }
.seo code {
  background: rgba(0, 0, 0, .3); border: 1px solid var(--glass-border);
  border-radius: 4px; padding: 1px 5px; font-size: 13px;
}
.seo-list { margin: 0; }
.seo-list dt {
  color: var(--fg); font-size: 14px; font-weight: 600; margin-top: 18px;
  padding-left: 14px; border-left: 2px solid var(--accent);
}
.seo-list dd {
  margin: 6px 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.7;
}

/* --- site footer --- */
.sitefoot {
  margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  flex-wrap: wrap; text-align: center;
}
.sitefoot img { border-radius: 6px; flex: none; }
.sitefoot p { margin: 0; color: var(--muted); font-size: 13px; }
.sitefoot a { color: var(--accent-soft); text-decoration: none; font-weight: 600; }
.sitefoot a:hover { text-decoration: underline; }
