/* Themes: dark (default), black, light. Pages use these variables only. */
:root, [data-theme="dark"] {
  --bg: #0e0f13; --panel: #181a21; --panel2: #20232c; --line: #2c3040; --text: #eceef4; --dim: #8e93a8;
  --accent: #e9e9ee; --on-accent: #0e0f13; --em: #9a9fae; --quote: #f4f4f7;
  --header: rgba(14,15,19,.85); --hairline: rgba(255,255,255,.06); --soft: rgba(255,255,255,.08);
  --abubble: rgba(32,35,44,.92); --ububble: #2c2f3a; --ring: #4a4f60; --error: #d98a93; --backdrop: brightness(.25);
}
[data-theme="black"] {
  --bg: #000; --panel: #0d0d0f; --panel2: #18181b; --line: #232329; --header: rgba(0,0,0,.85);
  --abubble: rgba(22,22,26,.95); --ububble: #232329; --backdrop: brightness(.15);
}
[data-theme="light"] {
  --bg: #f6f6f8; --panel: #ffffff; --panel2: #eeeef2; --line: #dcdce3; --text: #17181c; --dim: #6b6e7b;
  --accent: #17181c; --on-accent: #ffffff; --em: #6b6e7b; --quote: #17181c;
  --header: rgba(246,246,248,.85); --hairline: rgba(0,0,0,.07); --soft: rgba(0,0,0,.06);
  --abubble: rgba(255,255,255,.95); --ububble: #e4e4ea; --ring: #a9abb6; --error: #b3404f; --backdrop: brightness(1.4) opacity(.35);
}
:root { --fs: 15px; }
[data-size="small"] { --fs: 14px; }
[data-size="large"] { --fs: 17px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: var(--fs)/1.5 "Segoe UI", system-ui, sans-serif; }
button { font: inherit; cursor: pointer; border: 0; }
a { color: inherit; text-decoration: none; }

.btn { background: var(--accent); color: var(--on-accent); font-weight: 600; border-radius: 999px; padding: 10px 20px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--soft); color: var(--text); font-weight: 600; }
.iconbtn { background: none; color: var(--text); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; }
.iconbtn:hover { background: var(--soft); }
.error { color: var(--error); }
.avatar-me { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--panel2); display: grid; place-items: center;
             font-weight: 700; color: var(--dim); flex-shrink: 0; }

/* ---------- phones (shared) ---------- */
[data-device="desktop"] .mobile-only { display: none !important; }
[data-device="mobile"] .desktop-only { display: none !important; }
[data-device="mobile"] input, [data-device="mobile"] textarea, [data-device="mobile"] select { font-size: 16px; }  /* stops phones zooming in on tap */
[data-device="mobile"] .sheet { border-radius: 20px; }
[data-device="mobile"] .btn { min-height: 42px; }

/* bottom tab bar (phones only) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--header); backdrop-filter: blur(14px);
          border-top: 1px solid var(--hairline); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11px; font-weight: 600; color: var(--dim); }
.tabbar a.on { color: var(--text); }
.tabbar .ic { font-size: 20px; line-height: 24px; height: 24px; display: grid; place-items: center; }
.tabbar .plus { width: 44px; height: 28px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 22px;
                display: grid; place-items: center; line-height: 1; }
.tabbar .avatar-me { width: 24px; height: 24px; font-size: 12px; }

/* bottom sheet / modal */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; place-items: center; z-index: 50; padding: 20px; }
.overlay.show { display: grid; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: 100%; max-width: 380px; }
.sheet h2 { margin: 0 0 6px; font-size: 19px; }
.sheet p { margin: 0 0 14px; color: var(--dim); font-size: 14px; }
.field { width: 100%; padding: 11px 13px; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 12px; font: inherit; }
.field:focus { outline: none; border-color: var(--ring); }

/* toggle switch */
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: var(--panel); border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); }

/* segmented choice (themes, text size) */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { background: var(--soft); color: var(--text); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--on-accent); }

.loader { display: inline-flex; gap: 4px; }
.loader i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); animation: bounce 1.2s infinite ease-in-out; }
.loader i:nth-child(2) { animation-delay: .15s; } .loader i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }
