/* FF Weather — design system.
   Dark is the showcase theme; light mirrors it. Theme resolution:
   [data-theme] wins, otherwise system preference. */

:root {
  color-scheme: dark;
  --bg: #0a0e1a;
  --bg-glow-1: rgba(43, 92, 226, 0.16);
  --bg-glow-2: rgba(99, 102, 241, 0.10);
  --surface: rgba(255, 255, 255, 0.055);
  --surface-hover: rgba(255, 255, 255, 0.085);
  --surface-strong: #151b2e;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef2f9;
  --text-2: #a9b2c6;
  --text-3: #78829b;
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --danger: #f87171;
  --up: #fb923c;
  --down: #60a5fa;
  --card-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 30px rgba(2, 6, 18, 0.35);
  --dialog-shadow: 0 24px 60px rgba(2, 6, 18, 0.6);
  --icon-cloud: #c3cede;
  --icon-snow: #cfe4ff;
  --icon-wind: #5eead4;
  --icon-fog: #93a0b8;
  --seg-track: rgba(255, 255, 255, 0.07);
  --seg-thumb: rgba(255, 255, 255, 0.16);
  --input-bg: rgba(255, 255, 255, 0.06);
  --wash-opacity: 1;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f7;
  --bg-glow-1: rgba(56, 189, 248, 0.14);
  --bg-glow-2: rgba(99, 102, 241, 0.08);
  --surface: #ffffff;
  --surface-hover: #ffffff;
  --surface-strong: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #10182b;
  --text-2: #43506b;
  --text-3: #67718c;
  --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px rgba(15, 23, 42, 0.07);
  --dialog-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  --icon-cloud: #aebccf;
  --icon-snow: #8fc3f0;
  --icon-wind: #14b8a6;
  --icon-fog: #9aa6bd;
  --seg-track: rgba(15, 23, 42, 0.06);
  --seg-thumb: #ffffff;
  --input-bg: rgba(15, 23, 42, 0.04);
  --wash-opacity: 0.65;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #eef1f7;
    --bg-glow-1: rgba(56, 189, 248, 0.14);
    --bg-glow-2: rgba(99, 102, 241, 0.08);
    --surface: #ffffff;
    --surface-hover: #ffffff;
    --surface-strong: #ffffff;
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.16);
    --text: #10182b;
    --text-2: #43506b;
    --text-3: #67718c;
    --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px rgba(15, 23, 42, 0.07);
    --dialog-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    --icon-cloud: #aebccf;
    --icon-snow: #8fc3f0;
    --icon-wind: #14b8a6;
    --icon-fog: #9aa6bd;
    --seg-track: rgba(15, 23, 42, 0.06);
    --seg-thumb: #ffffff;
    --input-bg: rgba(15, 23, 42, 0.04);
    --wash-opacity: 0.65;
  }
}

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; }

/* Author display declarations (e.g. .chip { display:inline-flex }) override
   the UA's [hidden] rule, so restate it with priority. */
[hidden] { display: none !important; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background:
    radial-gradient(55rem 30rem at 12% -8%, var(--bg-glow-1), transparent 60%),
    radial-gradient(45rem 28rem at 95% 12%, var(--bg-glow-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
}

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px clamp(14px, 3vw, 28px);
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark { width: 32px; height: 32px; border-radius: 8px; flex: none; }

.brand-name { line-height: 1; }

.brand-top {
  display: block;
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}

.brand-main {
  display: block;
  margin-top: 2px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.005em;
  background: linear-gradient(100deg, var(--text) 30%, var(--accent) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border: 1px solid color-mix(in srgb, #fbbf24 35%, transparent);
  background: color-mix(in srgb, #fbbf24 10%, transparent);
  color: color-mix(in srgb, #fbbf24 75%, var(--text));
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: help;
}

.chip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #fbbf24;
}

/* hamburger menu */

.menu-anchor { position: relative; }

.menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  min-width: 230px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--dialog-shadow);
}

.menu-label {
  margin: 4px 8px 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-2);
  cursor: pointer;
}

.menu-item:hover { background: var(--surface-hover); color: var(--text); }

.menu-styles input {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.menu-styles .menu-item span { flex: 1; }

/* checkmark slot keeps rows aligned; filled when selected */
.menu-styles .menu-item::before {
  content: "";
  width: 15px;
  flex: none;
  font-size: 13px;
  color: var(--accent);
}

.menu-styles .menu-item:has(input:checked) {
  color: var(--text);
  font-weight: 650;
}

.menu-styles .menu-item:has(input:checked)::before { content: "✓"; }

.menu-styles .menu-item:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.menu-sep {
  margin: 8px 4px;
  border: 0;
  border-top: 1px solid var(--border);
}

.menu-link { text-decoration: none; }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.updated {
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 620px) {
  .updated { display: none; }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

.icon-btn svg { width: 17px; height: 17px; }

.icon-btn.spinning svg { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, border-color 0.15s, transform 0.06s;
}

.btn:active { transform: translateY(1px); }

.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent-2) 35%, transparent);
}

.btn-primary:hover { filter: brightness(1.09); }

.btn-primary:disabled { opacity: 0.6; cursor: default; filter: none; }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-2);
}

.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-danger:hover { filter: brightness(1.08); }

.btn-danger-ghost {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* ---------------------------------------------------------------- grid */

.wrap {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 18px;
}

/* ---------------------------------------------------------------- card
   Each tile is a 3D flip card: weather on the front, a generated 4-panel
   forecast comic on the back. .card-wrap provides perspective; both faces
   share the same grid cell so the front's content sets the height. */

.card-wrap {
  perspective: 1600px;
}

.card-inner {
  display: grid;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.35, 0.1, 0.2, 1);
  height: 100%;
}

.card-wrap.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  grid-area: 1 / 1;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-front { cursor: pointer; }

.card-back {
  transform: rotateY(180deg);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.flip-btn {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}

.flip-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.comic-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 13px;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg) 40%, transparent);
}

.comic-img {
  grid-area: 1 / 1;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comic-img.loaded { display: block; }

/* expand-to-lightbox button; only shown once the comic has loaded */
.comic-expand {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: rgba(10, 14, 26, 0.55);
  color: #fff;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s;
}

.comic-img.loaded + .comic-expand { display: grid; }

.comic-expand:hover { opacity: 1; }

.comic-expand svg { width: 15px; height: 15px; }

.comic-loading,
.comic-error {
  grid-area: 1 / 1;
  z-index: 1;
  text-align: center;
  color: var(--text-2);
  font-size: 13.5px;
  padding: 16px;
}

.comic-loading p { margin: 10px 0 0; }

.comic-loading svg {
  width: 30px;
  height: 30px;
  color: var(--accent);
  animation: twinkle 1.6s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(0.82) rotate(12deg); opacity: 0.65; }
}

.comic-loading-sub {
  font-size: 11.5px;
  color: var(--text-3);
}

.comic-error p { margin: 0 0 10px; }

.comic-caption {
  margin: 9px 2px 2px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}

.card {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 18px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  /* no backdrop-filter here: it breaks backface-visibility in Chromium,
     which would make the comic back face ghost through the front. */
}

/* Condition-tinted wash */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--wash-opacity);
  background: radial-gradient(130% 95% at 86% -6%, var(--wash, transparent), transparent 58%);
}

.card > * { position: relative; }

.card[data-cond="sun"]   { --wash: rgba(251, 191, 36, 0.17); }
.card[data-cond="night"] { --wash: rgba(129, 140, 248, 0.16); }
.card[data-cond="cloud"] { --wash: rgba(148, 163, 184, 0.13); }
.card[data-cond="fog"]   { --wash: rgba(148, 163, 184, 0.15); }
.card[data-cond="rain"]  { --wash: rgba(59, 130, 246, 0.16); }
.card[data-cond="storm"] { --wash: rgba(139, 92, 246, 0.18); }
.card[data-cond="snow"]  { --wash: rgba(186, 230, 253, 0.15); }
.card[data-cond="wind"]  { --wash: rgba(45, 212, 191, 0.14); }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.who { min-width: 0; }

.name {
  margin: 0;
  font-size: 17px;
  font-weight: 680;
  letter-spacing: 0.005em;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.edit-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.card:hover .edit-btn,
.card:focus-within .edit-btn { opacity: 1; }

@media (hover: none) { .edit-btn { opacity: 0.65; } }

.edit-btn:hover { background: var(--surface-hover); color: var(--text); }

.edit-btn svg { width: 13px; height: 13px; }

.where {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.where .dot { margin: 0 4px; }

.clock { font-variant-numeric: tabular-nums; }

.cond-icon { flex: none; width: 54px; height: 54px; margin: -4px -2px 0 0; }

.cond-icon svg { width: 100%; height: 100%; }

/* ---------------------------------------------------------------- hero */

.hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
}

.temp-now {
  margin: 0;
  font-size: 56px;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: flex-start;
}

.temp-now .deg { color: var(--text-3); font-weight: 300; }

.trend {
  font-size: 15px;
  line-height: 1;
  margin: 8px 0 0 2px;
}

.trend.up { color: var(--up); }
.trend.down { color: var(--down); }

.hero-side { min-width: 0; }

.feels {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
}

.hilo {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hilo .lo { color: var(--text-3); font-weight: 500; margin-left: 2px; }

/* ------------------------------------------------------------ 5-day strip */

.strip {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin: 14px 0;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.strip li {
  display: grid;
  justify-items: center;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.strip .dow {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}

.strip .emoji { font-size: 17px; line-height: 1.2; }

.strip .hi { font-size: 12.5px; font-weight: 650; }

.strip .lo { font-size: 12.5px; color: var(--text-3); }

/* ---------------------------------------------------------------- stats */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 6px;
  align-items: center;
}

.stat-ic {
  grid-row: 1;
  width: 14px; height: 14px;
  color: var(--text-3);
}

.stat .val {
  font-size: 13.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat .val small {
  font-size: 10.5px;
  font-weight: 550;
  color: var(--text-3);
}

.stat .ptrend { font-size: 10px; }
.stat .ptrend.rising { color: var(--up); }
.stat .ptrend.falling { color: var(--down); }
.stat .ptrend.steady { color: var(--text-3); }

.stat .sub {
  grid-column: 2;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* --------------------------------------------------------- weather icons */

.ic-sun { fill: #fbbf24; }
.ic-ray { stroke: #fbbf24; }
.ic-moon { fill: #a5b4fc; }
.ic-cloud { fill: var(--icon-cloud); }
.ic-rain { stroke: #60a5fa; }
.ic-snow { fill: var(--icon-snow); }
.ic-snow-stroke { stroke: var(--icon-snow); }
.ic-bolt { fill: #fbbf24; }
.ic-fog { stroke: var(--icon-fog); }
.ic-wind { stroke: var(--icon-wind); }

/* ------------------------------------------------------- error & empty */

.card-error .error-body { padding: 18px 0 10px; }

.error-title { margin: 0 0 4px; font-weight: 650; }

.error-msg { margin: 0 0 12px; font-size: 13px; color: var(--text-3); }

.page-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 20px;
}

.page-error .error-msg { margin-bottom: 16px; }

.empty {
  text-align: center;
  padding: 72px 20px;
}

.empty-art { width: 76px; height: 76px; margin-bottom: 6px; }

.empty h2 { margin: 0 0 6px; font-size: 20px; }

.empty p { margin: 0 0 18px; color: var(--text-2); }

/* ------------------------------------------------------------ skeletons */

.sk {
  border-radius: 8px;
  background: linear-gradient(100deg,
    var(--surface) 40%,
    var(--surface-hover) 50%,
    var(--surface) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -80% 0; }
}

.sk-name  { width: 45%; height: 18px; }
.sk-place { width: 65%; height: 12px; margin-top: 8px; }
.sk-temp  { width: 55%; height: 52px; margin-top: 16px; }
.sk-strip { width: 100%; height: 62px; margin-top: 16px; }
.sk-stats { width: 100%; height: 30px; margin-top: 14px; }

/* --------------------------------------------------------------- dialogs */

.dialog {
  width: min(92vw, 430px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--dialog-shadow);
}

.dialog::backdrop {
  background: rgba(4, 8, 18, 0.55);
  backdrop-filter: blur(3px);
}

.dialog h2 { margin: 0 0 16px; font-size: 18px; }

.field { display: block; margin: 0 0 14px; }

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input::placeholder { color: var(--text-3); }

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  resize: vertical;
  min-height: 74px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field textarea::placeholder { color: var(--text-3); }

.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.dialog-sub {
  margin: -8px 0 16px;
  font-size: 13px;
  color: var(--text-2);
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  margin-left: 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: none;
  cursor: pointer;
}

.link-btn:hover { text-decoration: underline; }

.character-stage {
  position: relative;
  height: 216px;
  display: grid;
  place-items: center;
  margin: 2px 0 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  overflow: hidden;
}

#character-img {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.character-empty {
  grid-area: 1 / 1;
  margin: 0;
  padding: 0 28px;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

.character-stage .comic-loading {
  grid-area: 1 / 1;
  z-index: 1;
  background: color-mix(in srgb, var(--surface-strong) 55%, transparent);
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
}

.character-actions { flex-wrap: wrap; }

.flex-spacer { flex: 1; }

.form-error {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--danger);
}

.remove-zone {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.remove-confirm {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text-2);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* segmented controls */

.seg-field {
  border: 0;
  margin: 0 0 15px;
  padding: 0;
}

.seg-field legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.seg {
  display: flex;
  background: var(--seg-track);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg label { flex: 1; }

.seg input {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.seg span {
  display: block;
  text-align: center;
  padding: 7px 6px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.seg span:hover { color: var(--text); }

.seg input:checked + span {
  background: var(--seg-thumb);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(2, 6, 18, 0.25);
}

.seg input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* -------------------------------------------------------------- lightbox */

.lightbox {
  width: min(94vw, 860px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--dialog-shadow);
  cursor: zoom-out;
  overflow: hidden;
}

.lightbox::backdrop {
  background: rgba(4, 8, 18, 0.72);
  backdrop-filter: blur(4px);
}

.lightbox img {
  display: block;
  width: 100%;
  height: auto;
}

.lightbox-caption {
  margin: 0;
  padding: 12px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

/* ------------------------------------------------------------- doc pages */

.doc {
  max-width: 680px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 24px) 60px;
}

.doc h1 { font-size: 28px; margin: 18px 0 6px; letter-spacing: -0.01em; }

.doc h2 { font-size: 17px; margin: 28px 0 8px; }

.doc p, .doc li { color: var(--text-2); line-height: 1.65; font-size: 14.5px; }

.doc a { color: var(--accent); text-underline-offset: 2px; }

.doc .doc-meta { font-size: 12.5px; color: var(--text-3); }

.doc-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
}

.doc-back:hover { color: var(--text); }

/* If Turnstile decides it needs a visible interaction, the widget appears
   as a floating card bottom-right; otherwise this element stays empty. */
.turnstile-slot {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 40;
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  box-shadow: var(--dialog-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 30;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- footer */

.site-footer {
  padding: 26px 16px 30px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
}

.site-footer p { margin: 0; }

.site-footer a {
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer a:hover { color: var(--text); }

/* -------------------------------------------------------- small screens */

@media (max-width: 480px) {
  .temp-now { font-size: 48px; }
  .cond-icon { width: 48px; height: 48px; }
  .btn { padding: 8px 12px; }
}

/* ------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
