/* ============================================================
   app.css — v2

   The look from screen 01: a deep navy that is nearly black, heavy
   condensed capitals, and colour used only to tell one thing from
   another. Everything is a variable, because a palette typed in
   forty places is a palette nobody can change.
   ============================================================ */

:root {
  /* ---- the ladder ---- */
  --bg:        #050a1a;
  --bg-deep:   #03060f;
  --surface:   #0c1428;
  --surface-2: #121c35;
  --surface-3: #1a2544;
  --border:    rgba(255, 255, 255, .08);
  --border-2:  rgba(255, 255, 255, .16);

  --text:      #f4f6fb;
  --text-2:    #a6b0c6;
  --muted:     #67738f;

  --accent:      #1d7aef;
  --accent-lift: #4b9bff;
  --accent-dim:  rgba(29, 122, 239, .14);
  --accent-edge: rgba(29, 122, 239, .42);

  --danger:      #e01e2d;
  --danger-dim:  rgba(224, 30, 45, .13);
  --danger-edge: rgba(224, 30, 45, .40);
  --danger-text: #ff7a84;

  --good:        #1fae5a;
  --good-dim:    rgba(31, 174, 90, .14);
  --good-edge:   rgba(31, 174, 90, .38);
  --good-text:   #58d98c;

  --on-accent: #ffffff;

  --r-sm:   8px;
  --r:      14px;
  --r-lg:   20px;
  --r-pill: 999px;

  --shadow: 0 24px 60px -28px rgba(0, 0, 0, .95);

  /* Self-hosting a face is still to do — see CLAUDE.md. Until then
     the stack leans on what each platform ships that is closest to
     the heavy grotesque in the mockup. */
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system,
          "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(90% 60% at 50% -10%, #0b1735 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

body.is-modal { overflow: hidden; }

a { color: var(--accent-lift); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- the moment before the first paint ---- */
.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg);
}
.boot-dot {
  width: 34px; height: 34px; border-radius: var(--r-pill);
  border: 3px solid var(--surface-3); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .boot-dot { animation-duration: 2.4s; }
}

.shell { min-height: 100%; display: flex; flex-direction: column; }
.view {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px calc(40px + env(safe-area-inset-bottom));
}

/* ============================================================
   Controls
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--r-pill);
  border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--text); font: inherit; font-weight: 650; font-size: 14px;
  cursor: pointer; transition: .14s;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-lift); border-color: var(--accent-lift); }
.btn-danger {
  background: var(--danger); border-color: var(--danger); color: var(--on-accent);
}
.btn-big { width: 100%; padding: 14px 18px; font-size: 15px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer; transition: .14s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg, .btn svg { width: 17px; height: 17px; flex: none; }

/* ---- fields ---- */
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-size: 11px; font-weight: 750; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-2); margin-bottom: 7px;
}
.field > em {
  display: block; font-style: normal; font-size: 12px; color: var(--muted);
  margin-top: 6px; line-height: 1.45;
}
.field code {
  background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 11.5px;
}
.input {
  width: 100%; padding: 12px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border-2); background: var(--bg-deep);
  color: var(--text); font: inherit; font-size: 15px;
}
.input::placeholder { color: var(--muted); }
.input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* a field with a button sitting inside it */
.inwrap { position: relative; display: block; }
.inwrap .input { padding-right: 46px; }
.inwrap-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; border-radius: var(--r-sm);
}
.inwrap-btn:hover { color: var(--text); background: var(--surface-2); }
.inwrap-btn svg { width: 17px; height: 17px; }

/* ============================================================
   The gate — setup, register, sign in
   ============================================================ */
.gate { width: 100%; max-width: 420px; }
.gate-head { text-align: center; margin-bottom: 26px; }
.gate-title {
  font-size: 27px; font-weight: 800; letter-spacing: -.03em; margin: 0 0 8px;
}
.gate-sub { color: var(--text-2); font-size: 14px; margin: 0; line-height: 1.5; }

.gate-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow);
}
.gate-err, .gate-ok, .modal-err {
  font-size: 13.5px; line-height: 1.5; padding: 11px 13px;
  border-radius: var(--r-sm); margin-bottom: 16px;
}
.gate-err, .modal-err {
  background: var(--danger-dim); border: 1px solid var(--danger-edge);
  color: var(--danger-text);
}
.gate-ok {
  background: var(--good-dim); border: 1px solid var(--good-edge); color: var(--good-text);
}
.gate-alt {
  text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--text-2);
}
.gate-dot { margin: 0 8px; color: var(--muted); }
.gate-foot {
  text-align: center; margin-top: 20px; font-size: 12.5px; color: var(--muted);
  line-height: 1.6;
}
.gate-foot code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.gate-tiny {
  display: block; margin: 22px auto 0; padding: 4px 8px;
  background: none; border: 0; color: var(--muted);
  font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline;
}
.gate-tiny:hover { color: var(--text-2); }

/* ============================================================
   Screen 01 — choosing a universe

   The cards are the page. Everything else on it is quieter than
   they are on purpose.
   ============================================================ */
.picker { width: 100%; max-width: 920px; }
.picker-head { text-align: center; margin-bottom: 40px; }
.picker-title {
  font-size: 30px; font-weight: 400; letter-spacing: -.02em; margin: 0 0 4px;
  color: var(--text);
}
.picker-title b { font-weight: 800; }
.picker-sub { font-size: 23px; color: var(--text); margin: 0; font-weight: 400; }

.picker-list { display: flex; flex-direction: column; gap: 18px; }
.picker-loading, .picker-empty, .picker-cap {
  text-align: center; color: var(--muted); font-size: 13.5px; padding: 10px 0; margin: 0;
}

/* ---- one save ---- */
.save {
  --c: var(--accent);
  position: relative; display: flex; align-items: stretch;
  border-radius: var(--r-lg);
  border: 2px solid var(--c);
  background:
    linear-gradient(100deg, var(--bg-deep) 18%, color-mix(in srgb, var(--c) 42%, var(--bg-deep)) 100%);
  box-shadow: 0 0 34px -18px var(--c);
  overflow: hidden;
  transition: transform .14s, box-shadow .14s;
}
.save:hover { transform: translateY(-2px); box-shadow: 0 0 44px -14px var(--c); }

.save-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 26px 18px;
  background: none; border: 0; color: inherit; font: inherit; cursor: pointer;
  text-align: center;
}
.save-name {
  font-size: 30px; font-weight: 800; letter-spacing: .01em; text-transform: uppercase;
  line-height: 1.1; overflow-wrap: anywhere;
}
.save-meta { font-size: 14px; color: var(--text-2); }
.save-meta i { font-style: normal; color: var(--muted); margin: 0 4px; }

/* Out of the way until the card is under the pointer, because the
   card is for choosing and these are for housekeeping. */
.save-tools {
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  padding-right: 12px; opacity: 0; transition: opacity .14s;
}
.save:hover .save-tools, .save:focus-within .save-tools { opacity: 1; }
.save-tool {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: var(--r-sm); border: 1px solid var(--border-2);
  background: rgba(0, 0, 0, .35); color: var(--text-2);
  cursor: pointer; transition: .14s;
}
.save-tool:hover { color: var(--text); border-color: var(--text-2); }
.save-tool svg { width: 15px; height: 15px; }

.save-new {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 22px 18px; border-radius: var(--r-lg);
  border: 1px dashed var(--border-2); background: var(--surface);
  color: var(--text); font: inherit; font-size: 19px; font-weight: 750;
  text-transform: uppercase; letter-spacing: .02em; cursor: pointer; transition: .14s;
}
.save-new:hover { background: var(--surface-2); border-color: var(--text-2); }
.save-new-plus { display: grid; place-items: center; color: var(--text-2); }
.save-new-plus svg { width: 20px; height: 20px; }

.picker-err { text-align: center; padding: 30px 20px; color: var(--text-2); }
.picker-err-icon { color: var(--danger-text); margin-bottom: 10px; }
.picker-err-icon svg { width: 26px; height: 26px; }
.picker-err p { margin: 0 0 16px; font-size: 14px; }

.picker-foot { display: flex; justify-content: center; margin-top: 34px; }
.btn-signout {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--r-pill);
  border: 1px solid transparent; background: none;
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; transition: .14s;
}
.btn-signout:hover { color: var(--text); border-color: var(--border-2); }
.btn-signout svg { width: 15px; height: 15px; }

/* ============================================================
   Dialogs
   ============================================================ */
.scrim {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 20px;
  background: rgba(2, 4, 10, .72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.modal {
  width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  max-height: calc(100vh - 40px); display: flex; flex-direction: column;
}
.modal.is-danger { border-color: var(--danger-edge); }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px 14px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 750; letter-spacing: -.01em; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-err { margin: 0 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px 18px; border-top: 1px solid var(--border);
}

.warnline {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 18px; font-size: 13.5px; line-height: 1.55; color: var(--text-2);
}
.warnline svg { width: 18px; height: 18px; flex: none; color: var(--danger-text); margin-top: 1px; }
.warnline b { color: var(--text); }

/* ============================================================
   Toasts
   ============================================================ */
.toast-root {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 120;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
  width: min(440px, calc(100vw - 32px));
}
.toast {
  padding: 12px 16px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--border-2);
  color: var(--text); font-size: 13.5px; line-height: 1.5;
  box-shadow: var(--shadow);
  animation: toastIn .22s ease-out both;
}
.toast.is-bad { border-color: var(--danger-edge); background: var(--danger-dim); }
.toast.is-good { border-color: var(--good-edge); background: var(--good-dim); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .save:hover { transform: none; }
}

/* ============================================================
   Phones
   ============================================================ */
@media (max-width: 620px) {
  .view { padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); align-items: flex-start; }
  .gate-title { font-size: 23px; }
  .gate-form { padding: 18px; }
  .picker-head { margin-bottom: 26px; }
  .picker-title { font-size: 22px; }
  .picker-sub { font-size: 16px; }
  .save-name { font-size: 20px; }
  .save-meta { font-size: 12.5px; }
  .save-main { padding: 20px 14px; }
  .save-new { font-size: 15px; padding: 18px 14px; }
  /* no hover on a touch screen, so housekeeping is simply there */
  .save-tools { opacity: 1; }
}
