:root {
  --bg: #f4f3f0;
  --panel: #ffffff;
  --panel-2: #f8f7f5;
  --text: #17181b;
  --muted: #6e7179;
  --faint: #a2a5ab;
  --line: rgba(20, 20, 30, 0.08);
  --accent: #5146e1;
  --accent-2: #6d5ff0;
  --accent-soft: rgba(81, 70, 225, 0.1);
  --on-accent: #ffffff;
  --bubble-in: #ffffff;
  --bubble-in-text: var(--text);
  --green: #1fa463;
  --red: #e5484d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.05);
  --radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101113;
    --panel: #18191c;
    --panel-2: #1e1f23;
    --text: #ececef;
    --muted: #8e919a;
    --faint: #5f626a;
    --line: rgba(255, 255, 255, 0.08);
    --accent: #6e64f2;
    --accent-2: #8479ff;
    --accent-soft: rgba(132, 121, 255, 0.16);
    --bubble-in: #232428;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; margin: 8px 0 0; font-size: 13px; }

/* ---------- brand ---------- */
.logo-mark {
  width: 40px; height: 40px; border-radius: 12px; position: relative;
  background: linear-gradient(135deg, var(--accent), #9b5de5);
  box-shadow: 0 6px 20px rgba(81, 70, 225, 0.3);
}
.logo-mark::before, .logo-mark::after {
  content: ""; position: absolute; top: 50%; width: 38%; height: 38%; border-radius: 50%;
  border: 2.5px solid #fff; transform: translateY(-50%);
}
.logo-mark::before { left: 20%; }
.logo-mark::after { right: 20%; background: rgba(255, 255, 255, 0.35); }
.logo-mark.big { width: 64px; height: 64px; border-radius: 18px; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.boot .logo-mark { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(0.92); opacity: 0.7; } }

/* ---------- login / name ---------- */
.center-screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
.card { background: var(--panel); border-radius: 24px; padding: 32px 28px; box-shadow: var(--shadow); text-align: center; }
.card.narrow { width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.card h1 { font-size: 24px; margin: 16px 0 2px; letter-spacing: -0.02em; }
.card p { margin: 0 0 16px; }
.code-input, .text-input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); outline: none; text-align: center; font-size: 17px;
}
.code-input { letter-spacing: 0.12em; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.code-input:focus, .text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field .text-input { text-align: left; font-size: 15px; padding: 10px 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 9px 14px; font-weight: 500;
}
.btn:hover { background: var(--line); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.primary:hover { background: var(--accent-2); }
.btn.wide { width: 100%; padding: 13px; margin-top: 12px; font-size: 16px; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn.danger-text { color: var(--red); width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  border: none; background: transparent; color: var(--text); flex: none;
}
.icon-btn:hover { background: var(--line); }
.icon-btn.round { border-radius: 50%; }
.icon-btn.small { width: 28px; height: 28px; border-radius: 8px; }

/* ---------- chat layout ---------- */
#chat {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding-top: var(--safe-top);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  z-index: 5;
}
.peer { display: flex; align-items: center; gap: 11px; min-width: 0; }
.peer-text { min-width: 0; }
.peer-name { font-weight: 650; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status.typing { color: var(--accent); }
.actions { display: flex; gap: 2px; }
.actions .icon-btn { color: var(--accent); }

.avatar {
  --hue: 250;
  width: 38px; height: 38px; border-radius: 50%; flex: none; position: relative;
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 16px;
  background: linear-gradient(140deg, hsl(var(--hue) 70% 62%), hsl(calc(var(--hue) + 40) 65% 52%));
}
.avatar::after { content: attr(data-initial); }
.avatar .presence-dot {
  position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--faint); border: 2.5px solid var(--bg); transition: background 0.3s;
}
.avatar.online .presence-dot { background: var(--green); }
.avatar.xl { width: 112px; height: 112px; font-size: 44px; }

.banner, .conn-banner {
  display: flex; align-items: center; gap: 10px; margin: 10px auto 0; width: min(760px, calc(100% - 24px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; font-size: 13.5px; box-shadow: var(--shadow);
}
.banner > span { flex: 1; }
.banner .ic { color: var(--accent); flex: none; }
.conn-banner { justify-content: center; color: var(--muted); padding: 7px 12px; font-size: 13px; }

.call-pill {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  margin: 8px auto 0; border: none; border-radius: 999px; padding: 8px 16px;
  background: var(--green); color: #fff; font-weight: 550; font-size: 14px;
}
.call-pill .pulse { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
.call-pill-cta { opacity: 0.85; font-weight: 500; }
@keyframes pulse { 50% { opacity: 0.3; } }

#messages { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.msg-list { width: min(760px, 100%); margin: 0 auto; padding: 12px 14px 8px; display: flex; flex-direction: column; }

.empty { margin: auto; padding: 18vh 24px 0; text-align: center; display: flex; flex-direction: column; align-items: center; }
.empty p { margin: 14px 0 0; font-size: 17px; font-weight: 600; }
.empty p.muted { margin-top: 6px; font-size: 14px; font-weight: 400; max-width: 300px; }

.day { display: flex; justify-content: center; margin: 18px 0 10px; }
.day span { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; }

.row { display: flex; margin-top: 8px; }
.row.grouped { margin-top: 2px; }
.row.out { justify-content: flex-end; }
.row.system { justify-content: center; margin: 10px 0; }

.bubble {
  position: relative; max-width: min(78%, 560px); padding: 8px 12px 7px; border-radius: var(--radius);
  background: var(--bubble-in); color: var(--bubble-in-text); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
  overflow-wrap: anywhere;
}
.row.out .bubble { background: linear-gradient(160deg, var(--accent-2), var(--accent)); color: var(--on-accent); }
.row.in:not(.grouped) .bubble { border-top-left-radius: 8px; }
.row.out:not(.grouped) .bubble { border-top-right-radius: 8px; }
.bubble .text { white-space: pre-wrap; display: inline; }
.bubble .text a { text-decoration: underline; text-underline-offset: 2px; }
.bubble .meta {
  float: right; margin: 6px 0 -3px 10px; font-size: 11px; opacity: 0.6; font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap;
  position: relative; top: 3px;
}
.bubble.emoji { background: none !important; box-shadow: none; padding: 0 2px; }
.bubble.emoji .text { font-size: 44px; line-height: 1.15; }
.bubble.emoji .meta { color: var(--muted); opacity: 1; }
.row.pending .bubble { opacity: 0.65; }
.row.failed .bubble { outline: 2px solid var(--red); }

.bubble.has-image, .bubble.has-video { padding: 4px; }
.bubble.has-image .meta, .bubble.has-video .meta {
  position: absolute; right: 12px; bottom: 11px; margin: 0; top: auto; float: none;
  background: rgba(0, 0, 0, 0.45); color: #fff; opacity: 1; padding: 3px 7px; border-radius: 999px;
}
.bubble.has-image .text, .bubble.has-video .text { display: block; padding: 6px 8px 4px; }
.bubble.has-image:has(.text) .meta, .bubble.has-video:has(.text) .meta { position: static; float: right; background: none; color: inherit; opacity: 0.6; margin: 0 6px 4px 10px; }
.media img, .media video { display: block; border-radius: 16px; max-width: min(320px, 68vw); max-height: 360px; min-width: 120px; min-height: 80px; object-fit: cover; background: var(--line); }
.media img { cursor: zoom-in; image-rendering: auto; }

.file-card { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 200px; padding: 4px 0; }
.file-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: rgba(127, 127, 127, 0.15); flex: none; }
.file-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; opacity: 0.7; }

.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.vplay { width: 34px; height: 34px; border-radius: 50%; border: none; display: grid; place-items: center; flex: none; background: rgba(127, 127, 127, 0.18); }
.row.out .vplay { background: rgba(255, 255, 255, 0.22); color: #fff; }
.vbar { flex: 1; height: 4px; border-radius: 2px; background: rgba(127, 127, 127, 0.25); cursor: pointer; position: relative; }
.row.out .vbar { background: rgba(255, 255, 255, 0.3); }
.vfill { height: 100%; width: 0; border-radius: 2px; background: currentColor; }
.vtime { font-size: 12px; font-variant-numeric: tabular-nums; opacity: 0.8; min-width: 32px; }

.progress { height: 3px; background: rgba(127, 127, 127, 0.25); border-radius: 2px; margin: 6px 4px 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: currentColor; transition: width 0.2s; }

.call-log {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text);
}
.call-log:hover { border-color: var(--accent); }
.call-log .ic { color: var(--green); }
.call-log.missed .ic, .call-log.missed { color: var(--red); }
.call-log .meta { color: var(--muted); font-weight: 400; font-size: 12px; }
.seen { align-self: flex-end; font-size: 11.5px; color: var(--muted); margin: 3px 4px 0; }

.jump {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-bottom));
  border: none; background: var(--accent); color: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 550; box-shadow: var(--shadow); z-index: 6;
}

/* ---------- composer ---------- */
.composer {
  position: relative; display: flex; align-items: flex-end; gap: 8px;
  width: min(760px, 100%); margin: 0 auto; padding: 8px 12px calc(10px + var(--safe-bottom));
}
.input-wrap { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; display: flex; box-shadow: var(--shadow); }
.input-wrap:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
#input {
  flex: 1; resize: none; border: none; outline: none; background: transparent; padding: 10px 16px;
  max-height: 168px; line-height: 1.4; font-size: 16px;
}
.composer .icon-btn.round { width: 42px; height: 42px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--muted); }
.send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none; flex: none; display: grid; place-items: center;
  background: var(--panel); color: var(--accent); border: 1px solid var(--line); box-shadow: var(--shadow); transition: background 0.15s, color 0.15s;
}
.send-btn.has-text, #rec-send { background: var(--accent); color: #fff; border-color: transparent; }
.composer.recording > :not(.recorder) { visibility: hidden; }
.recorder { position: absolute; inset: 8px 12px calc(10px + var(--safe-bottom)); display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 0 0 0 0; box-shadow: var(--shadow); }
.recorder .icon-btn { box-shadow: none; border: none; color: var(--red); }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: pulse 1s infinite; }
#rec-time { font-variant-numeric: tabular-nums; font-weight: 550; min-width: 38px; }
#rec-wave { flex: 1; height: 32px; width: 100%; color: var(--accent); min-width: 0; }
#rec-send { margin-right: -1px; }

.drop-zone {
  position: fixed; inset: 12px; border: 2px dashed var(--accent); border-radius: 24px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 85%, transparent); font-size: 20px; font-weight: 600; color: var(--accent); z-index: 20; pointer-events: none;
}

/* ---------- call ---------- */
.call-view {
  position: fixed; inset: 0; z-index: 40; background: #0c0c0f; color: #fff;
  display: flex; flex-direction: column;
}
.stage { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; }
#remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.3s; background: #000; }
#remote-video.contain { object-fit: contain; }
.call-view.has-remote-video #remote-video { opacity: 1; }
.remote-placeholder { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.remote-placeholder .avatar { box-shadow: 0 0 0 calc(var(--speak, 0) * 16px) rgba(110, 100, 242, 0.35), 0 0 0 calc(var(--speak, 0) * 30px) rgba(110, 100, 242, 0.12); transition: box-shadow 0.12s; }
.call-name { font-size: 26px; font-weight: 650; margin-top: 18px; letter-spacing: -0.02em; }
.call-status { color: rgba(255, 255, 255, 0.6); min-height: 1.4em; }
.remote-muted {
  position: absolute; top: calc(70px + var(--safe-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; align-items: center;
  background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 6px 12px; border-radius: 999px; font-size: 13px;
}

.call-top {
  position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(12px + var(--safe-top)) 14px 12px; background: linear-gradient(rgba(0, 0, 0, 0.45), transparent);
}
.call-title { display: flex; flex-direction: column; align-items: center; font-weight: 600; font-size: 15px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.timer { font-size: 12.5px; font-weight: 500; opacity: 0.75; font-variant-numeric: tabular-nums; }
.glass-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; display: grid; place-items: center; color: #fff;
  background: rgba(255, 255, 255, 0.14); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.quality {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 999px; border: none; color: #fff; font-size: 12.5px;
  background: rgba(255, 255, 255, 0.14); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-variant-numeric: tabular-nums; min-width: 40px;
}
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.bars i { width: 3px; border-radius: 1px; background: rgba(255, 255, 255, 0.3); }
.bars i:nth-child(1) { height: 5px; } .bars i:nth-child(2) { height: 8px; } .bars i:nth-child(3) { height: 12px; }
.quality[data-q="good"] .bars i { background: #3ddc84; }
.quality[data-q="fair"] .bars i:nth-child(-n+2) { background: #f5c542; }
.quality[data-q="poor"] .bars i:nth-child(1) { background: #ff5c5c; }
.stats-pop {
  position: absolute; z-index: 3; top: calc(62px + var(--safe-top)); right: 14px; width: 280px;
  background: rgba(24, 24, 28, 0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px; padding: 10px 14px; font-size: 12.5px;
}
.stat { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.stat span { color: rgba(255, 255, 255, 0.6); }
.stat b { font-weight: 550; text-align: right; font-variant-numeric: tabular-nums; }

.self-wrap {
  position: absolute; z-index: 2; right: 16px; bottom: calc(104px + var(--safe-bottom));
  width: clamp(120px, 22vw, 260px); aspect-ratio: 16 / 10; border-radius: 16px; overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); background: #1a1a1f; outline: 2px solid transparent; transition: outline-color 0.15s;
}
.self-wrap.speaking { outline-color: #3ddc84; }
@media (max-aspect-ratio: 1/1) { .self-wrap { width: 30vw; aspect-ratio: 3 / 4; } }
#self-video { width: 100%; height: 100%; object-fit: cover; display: block; }
#self-video.mirror { transform: scaleX(-1); }
.self-label { position: absolute; inset: auto 0 0 0; font-size: 11px; padding: 4px 8px; background: rgba(0, 0, 0, 0.5); text-align: center; }
.self-label:empty { display: none; }

.call-controls {
  position: absolute; z-index: 2; left: 50%; transform: translateX(-50%); bottom: calc(22px + var(--safe-bottom));
  display: flex; gap: 12px; padding: 10px 12px; border-radius: 999px;
  background: rgba(30, 30, 36, 0.7); backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.ctl {
  width: 54px; height: 54px; border-radius: 50%; border: none; display: grid; place-items: center; color: #fff;
  background: rgba(255, 255, 255, 0.14); transition: background 0.15s, transform 0.1s;
}
.ctl:hover { background: rgba(255, 255, 255, 0.24); }
.ctl:active { transform: scale(0.94); }
.ctl.off { background: #fff; color: #111; }
.ctl.active { background: var(--accent-2); }
.ctl.danger { background: var(--red); }
.ctl.danger:hover { background: #f05a5f; }
.ctl.accept { background: var(--green); }
.ctl.big { width: 68px; height: 68px; }
@media (max-width: 480px) {
  .call-controls { gap: 8px; padding: 8px 10px; }
  .ctl { width: 50px; height: 50px; }
}

/* ---------- incoming ---------- */
.incoming {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: rgba(10, 10, 14, 0.72); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); color: #fff;
  animation: fadein 0.2s ease-out;
}
@keyframes fadein { from { opacity: 0; } }
.incoming-card { display: flex; flex-direction: column; align-items: center; text-align: center; }
.avatar.ringing { animation: ring 1.6s ease-out infinite; }
@keyframes ring {
  0% { box-shadow: 0 0 0 0 rgba(132, 121, 255, 0.55); }
  100% { box-shadow: 0 0 0 36px rgba(132, 121, 255, 0); }
}
.in-name { font-size: 28px; font-weight: 650; margin-top: 22px; letter-spacing: -0.02em; }
.in-kind { opacity: 0.7; margin-top: 4px; }
.in-actions { display: flex; gap: 40px; margin-top: 48px; }
.in-act { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; opacity: 0.95; }
.in-act .ctl:not(.danger):not(.accept) { background: rgba(255, 255, 255, 0.18); }

/* ---------- settings sheet ---------- */
.sheet {
  width: min(480px, calc(100% - 24px)); max-height: min(86vh, 820px); padding: 0; border: none; border-radius: 22px;
  background: var(--panel); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); overflow: hidden;
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.sheet[open] { display: flex; flex-direction: column; animation: sheetin 0.22s ease-out; }
@keyframes sheetin { from { transform: translateY(16px); opacity: 0; } }
@media (max-width: 560px) {
  .sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92vh; padding-bottom: var(--safe-bottom); }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 22px; }
.sheet-head h2 { margin: 0; font-size: 19px; letter-spacing: -0.01em; }
.sheet-body { overflow-y: auto; padding: 0 22px 22px; }
.group { padding: 14px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.group:last-child { border-bottom: none; }
.group h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field > span { flex: none; }
.field select, .field .text-input { flex: 1; min-width: 0; max-width: 260px; }
select {
  appearance: none; -webkit-appearance: none; border: 1px solid var(--line); background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border-radius: 10px; padding: 9px 30px 9px 11px; outline: none; text-overflow: ellipsis;
}
.segmented { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.segmented button { border: none; background: transparent; padding: 6px 13px; border-radius: 8px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.segmented button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.toggle input { order: 2; appearance: none; -webkit-appearance: none; width: 42px; height: 25px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.2s; flex: none; margin: 0; cursor: pointer; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.toggle input:checked { background: var(--green); }
.toggle input:checked::after { transform: translateX(17px); }
.meter-row { display: flex; align-items: center; gap: 12px; }
.meter { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, var(--green) 0 70%, #f5c542 85%, var(--red)); background-size: 260px 100%; transition: width 0.06s linear; }
.row-btns { display: flex; gap: 8px; }

/* ---------- lightbox & toast ---------- */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.92); display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; border-radius: 6px; }
.lightbox .glass-btn { position: absolute; top: calc(14px + var(--safe-top)); right: 14px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-bottom)); z-index: 70;
  background: rgba(28, 28, 32, 0.92); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 14px; max-width: min(420px, 92vw); text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25); animation: toastin 0.2s ease-out; transition: opacity 0.25s;
}
.toast.out { opacity: 0; }
@keyframes toastin { from { transform: translate(-50%, 8px); opacity: 0; } }
.ic { display: block; flex: none; }
