/* ---------------------------------------------------------------------------
   Tokens
--------------------------------------------------------------------------- */
:root {
  --bg: #0a0c10;
  --surface: #12151b;
  --surface-raised: #181c23;
  --surface-hover: #1e232b;
  --border: #262b34;
  --border-strong: #343a45;
  --text: #e7e9ee;
  --text-muted: #8b919c;
  --text-faint: #5f6672;
  --accent: #4f8cff;
  --accent-hover: #6a9dff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --danger: #f0616d;
  --danger-soft: rgba(240, 97, 109, 0.12);
  --online: #3ecf8e;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: 12px;
  --nav-w: 64px;
  --panel-w: 380px;

  --topbar-bg: linear-gradient(to bottom, rgba(10, 12, 16, 0.75), transparent);
  --stage-bg: radial-gradient(120% 90% at 50% 20%, #232a36 0%, #151a22 70%);
  color-scheme: dark;
}

/* Daytime: pale sky blue. Applied by theme.js from the sun's position at the
   user's city, or forced from 设置 › 通用. */
:root[data-theme="light"] {
  --bg: #edf3fa;
  --surface: #f7fafe;
  --surface-raised: #ffffff;
  --surface-hover: #e6eef8;
  --border: #d9e3ef;
  --border-strong: #c4d3e5;
  --text: #182435;
  --text-muted: #5a6a80;
  --text-faint: #8796ab;
  --accent: #2f7be6;
  --accent-hover: #1f6bd6;
  --accent-soft: rgba(47, 123, 230, 0.12);
  --danger: #d6404d;
  --danger-soft: rgba(214, 64, 77, 0.1);
  --online: #22b573;
  --shadow: 0 8px 28px rgba(36, 66, 110, 0.16), 0 0 0 1px rgba(36, 66, 110, 0.05);

  --topbar-bg: rgba(239, 245, 252, 0.94);
  --stage-bg: radial-gradient(120% 90% at 50% 20%, #ffffff 0%, #dfeaf7 75%);
  color-scheme: light;
}

/* ---------------------------------------------------------------------------
   Base
--------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
p { margin: 0; }
.icon { flex: none; display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------------------------------------------------------------------------
   Globe
--------------------------------------------------------------------------- */
.globe { position: fixed; inset: 0; }
.cesium-viewer-bottom, .cesium-widget-credits { display: none !important; }
.credits {
  position: fixed; right: var(--gutter); bottom: 4px; z-index: 5;
  max-width: 50vw; text-align: right;
  font-size: 10px; color: rgba(255, 255, 255, 0.35);
}
.credits * { font-size: inherit !important; color: inherit !important; }
.credits .cesium-credit-logoContainer { display: none !important; }

/* ---------------------------------------------------------------------------
   Top bar
--------------------------------------------------------------------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 var(--gutter) 0 16px;
  background: var(--topbar-bg);
  pointer-events: none;
}
[data-theme="light"] .topbar { box-shadow: 0 1px 0 var(--border); }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: 0.02em; }
.clock {
  display: flex; align-items: baseline; gap: 8px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.clock__icon { align-self: center; color: var(--text-muted); }
.clock__time { font-weight: 600; }
.clock__place { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.clock__offset {
  align-self: center; display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 6px 0 8px; border-radius: 11px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px;
}
.account {
  margin-left: auto; width: 36px; height: 36px; padding: 1px;
  border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 1px var(--border-strong);
}
.account .avatar { width: 100%; height: 100%; }

/* ---------------------------------------------------------------------------
   Navigation rail
--------------------------------------------------------------------------- */
.nav {
  position: fixed; z-index: 10; left: var(--gutter); top: 50%; transform: translateY(-50%);
  display: none; flex-direction: column; gap: 2px; padding: 6px;
  min-width: var(--nav-w); /* grows to fit longer labels (German, Russian) */
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.is-signed-in .nav { display: flex; }
.nav__item {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 6px 6px; border-radius: var(--radius); min-width: 0;
  color: var(--text-muted); transition: background-color .12s, color .12s;
}
.nav__item:hover { background: var(--surface-hover); color: var(--text); }
.nav__item.is-active { background: var(--accent-soft); color: var(--accent); }
.nav__label { font-size: 11px; line-height: 1; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.nav__badge {
  position: absolute; top: 4px; right: 8px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 600; line-height: 16px; text-align: center;
}

/* ---------------------------------------------------------------------------
   Side panel
--------------------------------------------------------------------------- */
.panel {
  position: fixed; z-index: 12;
  top: 64px; right: var(--gutter); bottom: 64px; width: var(--panel-w);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden;
  animation: panel-in .16s ease-out;
}
@keyframes panel-in { from { opacity: 0; transform: translateX(8px); } }
.panel__head {
  display: flex; align-items: center; gap: 4px;
  height: 48px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--border); flex: none;
}
.panel__head .icon-btn:first-child { margin-left: -8px; }
.panel__title { flex: 1; margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel__body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; overscroll-behavior: contain; }
.panel__body--flush { padding: 0; display: flex; flex-direction: column; }
.panel__body::-webkit-scrollbar, .chat__log::-webkit-scrollbar { width: 6px; }
.panel__body::-webkit-scrollbar-thumb, .chat__log::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ---------------------------------------------------------------------------
   Map controls
--------------------------------------------------------------------------- */
.map-controls {
  position: fixed; z-index: 9; right: var(--gutter); bottom: 72px;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel:not([hidden]) ~ .map-controls { right: calc(var(--panel-w) + var(--gutter) * 2); }
.map-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  color: var(--text-muted);
}
.map-btn + .map-btn { border-top: 1px solid var(--border); }
.map-btn:hover { background: var(--surface-hover); color: var(--text); }
.map-btn.is-on { color: var(--accent); }

.altitude {
  position: fixed; z-index: 5; left: 16px; bottom: 16px;
  font-size: 11px; color: rgba(255, 255, 255, 0.45); font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
   Controls
--------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius);
  background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--border-strong);
  font-weight: 500; white-space: nowrap;
  transition: background-color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-hover); }
.btn:disabled { opacity: .5; }
.btn--primary { background: var(--accent); color: #fff; box-shadow: none; }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--danger { color: var(--danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn--quiet { background: transparent; box-shadow: none; color: var(--text-muted); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn--block { width: 100%; }
.btn-group { display: flex; gap: 6px; flex: none; }
.button-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; }

.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: var(--radius);
  color: var(--text-muted);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn--primary { background: var(--accent); color: #fff; }
.icon-btn--primary:hover { background: var(--accent-hover); color: #fff; }

.link { color: var(--text-muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-strong); }
.link:hover { color: var(--text); }
.link--danger { color: var(--danger); }

.input {
  display: block; width: 100%; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius);
  outline: none; resize: vertical; transition: border-color .12s;
}
.input:focus { border-color: var(--accent); }
.input--sm { padding: 5px 8px; font-size: 13px; }
select.input { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(-45deg, transparent 50%, var(--text-muted) 50%); background-size: 5px 5px; background-position: right 14px center, right 9px center; background-repeat: no-repeat; }
select.input option, select.input optgroup { background: var(--surface); }

.field { display: block; margin-bottom: 14px; }
.field__label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }
.field__hint, .hint { display: block; margin-top: 6px; font-size: 12px; color: var(--text-faint); }

.segmented {
  display: flex; padding: 2px; margin: 16px 0 4px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
}
.segmented button {
  flex: 1; height: 28px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.segmented button.is-active { background: var(--surface-raised); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.3); }

.chip {
  height: 26px; padding: 0 10px; border-radius: 13px;
  background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--border);
  font-size: 12px; color: var(--text-muted);
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); color: var(--text); }

.switch {
  appearance: none; flex: none; position: relative; width: 34px; height: 20px; margin: 0;
  border-radius: 10px; background: var(--border-strong); cursor: pointer; transition: background-color .15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }

.radio-list { display: grid; gap: 2px; margin-bottom: 12px; }
.radio, .checkbox { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; }
.radio input, .checkbox input { accent-color: var(--accent); margin: 0; }
.checkbox { margin-top: 8px; }

.avatar { display: block; flex: none; border-radius: 50%; overflow: hidden; background: var(--surface-raised); object-fit: cover; user-select: none; }
.presence {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
}
.presence.is-online { background: var(--online); }
.inline-icon { display: inline-flex; vertical-align: -2px; margin-left: 6px; color: var(--text-muted); }

.empty { padding: 32px 8px; text-align: center; color: var(--text-muted); font-size: 13px; }
.section-title { margin: 20px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: .02em; }
.section-title:first-child { margin-top: 0; }
.count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.tag { padding: 2px 8px; border-radius: var(--radius-sm); background: var(--surface-raised); font-size: 12px; color: var(--text-muted); }

/* Row item (people lists) */
.row-item {
  display: flex; align-items: center; gap: 12px;
  margin: 0 -8px; padding: 8px; border-radius: var(--radius);
}
.row-item[role="button"] { cursor: pointer; }
.row-item[role="button"]:hover { background: var(--surface-hover); }
.row-item__avatar { position: relative; flex: none; }
.row-item__avatar .presence { position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; box-shadow: 0 0 0 2px var(--surface); }
.row-item__main { flex: 1; min-width: 0; }
.row-item__title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item__sub { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item__trail { flex: none; }
.stack-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.mini-row { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mini-row__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row__meta { font-size: 12px; color: var(--text-faint); }

/* ---------------------------------------------------------------------------
   Feed
--------------------------------------------------------------------------- */
.composer { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); }
.composer:focus-within { border-color: var(--accent); }
.composer__input { display: block; width: 100%; padding: 10px 12px 0; border: 0; background: none; outline: none; resize: none; }
.composer__bar { display: flex; align-items: center; padding: 6px 8px 8px 12px; }
.composer__count { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.post { padding: 14px 0; border-bottom: 1px solid var(--border); }
.post:last-child { border-bottom: 0; }
.post__head { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.post__who { min-width: 0; }
.post__name { font-weight: 500; }
.post__meta { font-size: 12px; color: var(--text-muted); }
.post__body { margin: 8px 0 6px 46px; white-space: pre-wrap; overflow-wrap: anywhere; }
.post__actions { display: flex; align-items: center; gap: 2px; margin-left: 40px; }
.action {
  display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 6px; border-radius: var(--radius-sm);
  color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums;
}
.action:hover { background: var(--surface-hover); color: var(--text-muted); }
.action.is-on { color: var(--danger); }
.action.is-on svg { fill: currentColor; }
.action--text { font-size: 12px; }

.thread { margin: 8px 0 0 46px; padding: 8px 10px; background: var(--bg); border-radius: var(--radius); }
.comment { padding: 3px 0; font-size: 13px; overflow-wrap: anywhere; }
.comment__author { color: var(--accent); margin-right: 6px; }
.inline-form { display: flex; gap: 6px; margin-top: 8px; }

/* ---------------------------------------------------------------------------
   Bottles
--------------------------------------------------------------------------- */
.bottle-stage:not(:empty) { margin-top: 8px; }
.letter {
  margin-bottom: 10px; padding: 14px 16px;
  background: #ece6d8; color: #2c2620; border-radius: var(--radius);
}
.letter__from { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; color: #77695a; }
.letter__body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

/* ---------------------------------------------------------------------------
   Chat
--------------------------------------------------------------------------- */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat__peer {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 10px 16px; border-bottom: 1px solid var(--border); text-align: left;
}
.chat__peer:hover { background: var(--surface-hover); }
.chat__peer-meta { font-size: 12px; color: var(--text-muted); }
.chat__log { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.chat__intro { display: flex; align-items: center; gap: 6px; justify-content: center; margin: 8px 0 12px; font-size: 12px; color: var(--text-faint); }
.msg-time { align-self: center; margin: 10px 0 4px; font-size: 11px; color: var(--text-faint); }
.msg {
  align-self: flex-start; max-width: 80%; padding: 7px 11px;
  background: var(--surface-raised); border-radius: 14px 14px 14px 4px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg--mine { align-self: flex-end; background: var(--accent); color: #fff; border-radius: 14px 14px 4px 14px; }
.chat__typing { padding: 0 16px 6px; font-size: 12px; color: var(--text-faint); }
.chat__compose { display: flex; align-items: flex-end; gap: 8px; flex: none; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat__input { resize: none; min-height: 36px; max-height: 120px; overflow-y: hidden; }

/* ---------------------------------------------------------------------------
   Settings
--------------------------------------------------------------------------- */
.panel__body--list { background: var(--bg); padding: 12px; }
.list-group { margin-bottom: 12px; }
.list-group__title { margin: 4px 4px 6px; font-size: 12px; font-weight: 500; color: var(--text-muted); }
.list-group__rows { background: var(--surface-raised); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 0 0 1px var(--border); }
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px;
  padding: 10px 14px; text-align: left;
}
.list-row + .list-row { box-shadow: inset 0 1px 0 var(--border); }
.list-row--link:hover, label.list-row:hover { background: var(--surface-hover); }
label.list-row { cursor: pointer; }
.list-row__icon { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.list-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list-row__hint { font-size: 12px; color: var(--text-muted); }
.list-row__value { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-muted); }
.list-row__chevron { color: var(--text-faint); margin-right: -4px; }
.list-row__check { color: var(--accent); }
.list-row--danger { color: var(--danger); }
.list-row--center { justify-content: center; }
.list-row--center .list-row__main { flex: none; }
.list-row--stack { flex-direction: column; align-items: stretch; gap: 10px; }
.list-row--person { padding: 6px 14px; }
.list-row--person .row-item { flex: 1; margin: 0; padding: 0; }
.list-note { margin: -4px 6px 14px; font-size: 12px; color: var(--text-faint); line-height: 1.6; }

.time-offset__head { display: flex; align-items: center; gap: 12px; }
.time-offset__value { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--accent); }
.time-offset__control { display: flex; align-items: center; gap: 10px; }
.range { flex: 1; accent-color: var(--accent); }

.about { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px 0 24px; }
.about__name { margin-top: 8px; font-size: 17px; font-weight: 600; }
.about__version { font-size: 12px; color: var(--text-muted); }

/* ---------------------------------------------------------------------------
   Me
--------------------------------------------------------------------------- */
.me { flex: 1; min-height: 0; overflow-y: auto; }
.me__hero { position: relative; }
.me__hero .stage { height: 300px; border-radius: 0; }
.me__identity { position: absolute; left: 16px; bottom: 12px; pointer-events: none; }
.me__name { font-size: 17px; font-weight: 600; }
.me__place { font-size: 12px; color: var(--text-muted); }
.me__controls { padding: 0 16px 16px; }
.me__controls .segmented { margin-top: 12px; }
.me__profile { padding-top: 12px; }
.me__bar {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 10px 12px 10px 16px; border-top: 1px solid var(--border); background: var(--surface);
}

/* 3D stage and wardrobe */
.stage {
  position: relative; overflow: hidden; border-radius: var(--radius-lg);
  background: var(--stage-bg); cursor: grab; user-select: none;
}
.stage:active { cursor: grabbing; }
.stage__hint { position: absolute; right: 12px; bottom: 10px; font-size: 11px; color: var(--text-faint); pointer-events: none; }
.stage__loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; color: var(--text-faint); pointer-events: none;
}
.stage__loading[hidden] { display: none; }
.stage--profile { width: 100%; height: 220px; cursor: grab; }

.wardrobe__content { padding-top: 12px; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.preset {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 10px; border-radius: var(--radius);
  background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--border);
}
.preset:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.preset[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
.preset img { width: 64px; height: 64px; border-radius: 50%; margin-bottom: 4px; }
.preset__name { font-size: 13px; font-weight: 500; }
.preset__note { font-size: 11px; color: var(--text-muted); }
.wardrobe__heading { margin: 16px 0 8px; font-size: 12px; color: var(--text-muted); }
.wardrobe__cats { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.wardrobe__options { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.option {
  height: 34px; padding: 0 8px; border-radius: var(--radius);
  background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--border); font-size: 13px;
}
.option:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.option[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.wardrobe__swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch--lg { width: 32px; height: 32px; }
/* "Keep the model's own colour": a white disc with a diagonal stroke. */
.swatch.swatch--original { background: linear-gradient(135deg, transparent 46%, var(--text-faint) 46% 54%, transparent 54%), var(--surface); box-shadow: inset 0 0 0 1px var(--border-strong); }
.wardrobe__foot { display: flex; justify-content: flex-end; margin-top: 14px; }
.sliders { display: grid; gap: 14px; }
.slider { display: grid; grid-template-columns: 56px auto 1fr auto; align-items: center; gap: 8px; font-size: 13px; }
.slider__label { color: var(--text-muted); }
.slider__end { font-size: 11px; color: var(--text-faint); }
.slider input { width: 100%; accent-color: var(--accent); }

/* ---------------------------------------------------------------------------
   Dialogs
--------------------------------------------------------------------------- */
.backdrop {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 16px;
  background: rgba(5, 6, 9, 0.6);
  animation: fade-in .12s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
.dialog {
  display: flex; flex-direction: column; width: 100%; max-height: calc(100vh - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.dialog--sm { max-width: 400px; }
.dialog--md { max-width: 480px; }
.dialog--lg { max-width: 720px; }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 12px 0 20px; }
.dialog__head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.dialog__body { padding: 16px 20px; overflow-y: auto; }
.dialog__body > .text-muted:first-child { margin-bottom: 16px; }
.dialog__foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }

/* Profile */
.profile { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 4px; }
.profile__name { margin: 12px 0 2px; font-size: 18px; font-weight: 600; }
.profile__status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.facts {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; width: 100%;
  margin: 16px 0 0; padding: 12px 14px; background: var(--bg); border-radius: var(--radius);
  font-size: 13px; text-align: left;
}
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.profile__bio { margin-top: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-top: 18px; }
.profile__secondary { display: flex; gap: 18px; margin-top: 16px; }

.swatch {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

.recovery-row { display: flex; align-items: center; gap: 8px; }
.recovery {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--border-strong);
  font: 13px/1.4 var(--mono); overflow-wrap: anywhere; user-select: all;
}

/* ---------------------------------------------------------------------------
   Toast
--------------------------------------------------------------------------- */
.toast {
  position: fixed; z-index: 60; left: 50%; top: 64px; transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px)); padding: 9px 14px;
  background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 13px;
  animation: fade-in .15s ease-out;
}
.toast.is-error { border-color: rgba(240, 97, 109, 0.5); }

/* ---------------------------------------------------------------------------
   Small screens
--------------------------------------------------------------------------- */
@media (max-width: 720px) {
  :root { --gutter: 8px; }
  .brand span, .clock__place { display: none; }
  .nav {
    top: auto; bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); left: var(--gutter); right: var(--gutter);
    transform: none; width: auto; min-width: 0; flex-direction: row; justify-content: space-around;
  }
  .nav__item { flex: 1; padding-left: 2px; padding-right: 2px; }
  .panel { top: 56px; left: var(--gutter); right: var(--gutter); bottom: 80px; width: auto; }
  .panel:not([hidden]) ~ .map-controls { right: var(--gutter); }
  .map-controls { bottom: 132px; }
  .altitude, .credits { display: none; }
  .nav__label { font-size: 10px; }
  .me__hero .stage { height: 240px; }
  .profile__actions { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------------------
   Opening title: deep space, the name appears, then it rushes past as the
   view opens onto the planet (main.js lifts it once the globe is ready)
--------------------------------------------------------------------------- */
.intro {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 55%, #0c1328 0%, #04060c 55%, #010205 100%);
  color: #f2f5fb;
  transition: opacity 1.3s ease .15s;
}
.intro.is-leaving { opacity: 0; pointer-events: none; }
.intro__brand {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  animation: intro-brand 1.6s cubic-bezier(.2, .7, .2, 1) backwards;
  transition: transform 1.4s cubic-bezier(.6, 0, .9, .4), opacity 1s ease, filter 1.4s ease;
}
.intro__brand img { filter: drop-shadow(0 0 18px rgba(143, 179, 255, .55)); }
.intro__brand span {
  font-size: clamp(24px, 7vw, 30px); font-weight: 200; letter-spacing: 0.24em; padding-left: 0.24em; white-space: nowrap;
  animation: intro-track 1.9s cubic-bezier(.2, .7, .2, 1) backwards;
}
.intro.is-leaving .intro__brand { transform: scale(1.6); opacity: 0; filter: blur(6px); }
@keyframes intro-brand { from { opacity: 0; transform: scale(.92); filter: blur(10px); } }
@keyframes intro-track { from { letter-spacing: .5em; padding-left: .5em; } }
@media (prefers-reduced-motion: reduce) {
  .intro__brand { animation-duration: .01s; }
  .intro.is-leaving .intro__brand { transform: none; }
}

/* ---------------------------------------------------------------------------
   Sign in / sign up — always dark, whatever the interface theme
--------------------------------------------------------------------------- */
.auth {
  position: fixed; inset: 0; z-index: 50; overflow-y: auto;
  background: #04060c; color: #e8ecf4; color-scheme: dark;
  transition: opacity .45s ease;
}
.auth.is-leaving { opacity: 0; pointer-events: none; }
.auth__sky { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.auth__inner {
  position: relative; min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; padding: 48px 16px 32px;
}
.auth__brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.auth__name {
  margin: 0; font-size: clamp(26px, 8vw, 34px); font-weight: 300; letter-spacing: 0.22em; padding-left: 0.22em; white-space: nowrap;
  color: #f2f5fb;
}
.auth__tagline { font-size: 13px; letter-spacing: 0.12em; color: rgba(220, 228, 245, 0.55); }
.auth__foot { font-size: 11px; letter-spacing: 0.06em; color: rgba(220, 228, 245, 0.35); text-align: center; }
.auth__lang { position: absolute; top: 14px; right: 16px; z-index: 1; }
.auth-lang {
  height: 30px; padding: 0 26px 0 10px; appearance: none; cursor: pointer;
  background: rgba(255, 255, 255, 0.05) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23c8d2e6' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 15px;
  color: rgba(232, 236, 244, 0.8); font-size: 12px; outline: none;
}
.auth-lang:hover, .auth-lang:focus { border-color: rgba(143, 179, 255, 0.6); color: #f2f5fb; }
.auth-lang option { background: #0d1220; }

.auth-card {
  width: 100%; max-width: 360px; padding: 22px 24px 24px;
  background: rgba(12, 16, 28, 0.72); border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}
.auth-tabs { display: flex; gap: 22px; margin-bottom: 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.auth-tabs__tab {
  position: relative; padding: 0 0 10px; font-size: 15px; color: rgba(220, 228, 245, 0.5);
}
.auth-tabs__tab[aria-selected="true"] { color: #f2f5fb; }
.auth-tabs__tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 1px; background: #8fb3ff;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field__label { font-size: 12px; color: rgba(220, 228, 245, 0.6); }
.auth-field__hint { font-size: 11px; color: rgba(220, 228, 245, 0.38); }
.auth-input {
  width: 100%; height: 40px; padding: 0 12px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px;
  color: #f2f5fb; outline: none; transition: border-color .15s, background-color .15s;
}
.auth-input::placeholder { color: rgba(220, 228, 245, 0.3); }
.auth-input:focus { border-color: rgba(143, 179, 255, 0.7); background: rgba(255, 255, 255, 0.06); }
select.auth-input { appearance: none; }
select.auth-input option, select.auth-input optgroup { background: #0d1220; }
.auth-submit {
  height: 42px; margin-top: 4px; border-radius: 8px;
  background: #e9eef8; color: #0b1020; font-weight: 600; letter-spacing: 0.08em;
  transition: background-color .15s, opacity .15s;
}
.auth-submit:hover:not(:disabled) { background: #ffffff; }
.auth-submit:disabled { opacity: 0.35; cursor: default; }
.auth-error { font-size: 12px; color: #ff8a94; }
.auth-note { font-size: 11px; line-height: 1.6; color: rgba(220, 228, 245, 0.4); }
.auth-switch { font-size: 12px; text-align: center; color: rgba(220, 228, 245, 0.45); }
.auth-link { color: #8fb3ff; font-size: 12px; margin-left: 4px; }
.auth-link:hover { color: #b4ccff; }

.auth-welcome { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 18px; text-align: center; }
.auth-welcome__title { font-size: 16px; margin-bottom: 10px; }
.auth-welcome__label { font-size: 12px; color: rgba(220, 228, 245, 0.5); }
.auth-uid { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.auth-uid__value { font: 300 34px/1.2 var(--mono); letter-spacing: 0.12em; color: #f2f5fb; }
.auth-card > .auth-submit { width: 100%; }

/* Slider puzzle */
.captcha { width: 300px; max-width: 100%; user-select: none; }
.captcha__stage { position: relative; width: 300px; height: 160px; border-radius: 8px; overflow: hidden; background: #0b1120; }
.captcha__image { display: block; width: 300px; height: 160px; }
.captcha__piece { position: absolute; left: 0; top: 0; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6)); will-change: transform; }
.captcha__refresh {
  position: absolute; top: 6px; right: 6px; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%; background: rgba(0, 0, 0, 0.45); color: rgba(255, 255, 255, 0.8);
}
.captcha__track {
  position: relative; height: 40px; margin-top: 8px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1); overflow: hidden;
}
.captcha__fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(143, 179, 255, 0.16); }
.captcha__hint {
  position: absolute; inset: 0; display: grid; place-items: center; padding-left: 40px;
  font-size: 12px; color: rgba(220, 228, 245, 0.45); pointer-events: none;
}
.captcha__knob {
  position: absolute; left: 0; top: 0; width: 44px; height: 38px; border-radius: 7px;
  display: grid; place-items: center; background: #e9eef8; color: #0b1020; cursor: grab; touch-action: none;
}
.captcha__knob:active { cursor: grabbing; }
.captcha[data-state="passed"] .captcha__fill { background: rgba(62, 207, 142, 0.18); }
.captcha[data-state="passed"] .captcha__knob { background: #3ecf8e; color: #fff; }
.captcha[data-state="passed"] .captcha__hint,
.captcha[data-state="failed"] .captcha__hint { padding-left: 0; }
.captcha[data-state="passed"] .captcha__hint { color: #6fe0ad; }
.captcha[data-state="failed"] .captcha__hint { color: #ff8a94; }
.captcha[data-state="failed"] .captcha__track { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Friend search */
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-result { margin-bottom: 16px; padding: 4px 8px; border-radius: var(--radius); background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--border); }
.uid-tag { font: 12px var(--mono); color: var(--text-muted); }
.photo-field { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.photo-field .avatar { box-shadow: 0 0 0 1px var(--border); }
@media (max-width: 400px) {
  .auth__inner { padding-left: 12px; padding-right: 12px; }
  .auth-card { padding: 20px 16px; }
}
