/* theme.css — Ultra Xtream's look (ui/theme/Theme.kt): palettes, accent, type scale and the shared
 * components. Colours are set on <html> by lib/config.js (data-theme + --accent*), so the panel's
 * theme and the user's choice apply live. Sizes are the Android dp values in CSS pixels. */
@font-face { font-family: 'Inter'; src: url('/fonts/inter-regular.otf') format('opentype'); font-weight: 400 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-semibold.otf') format('opentype'); font-weight: 600 800; font-display: swap; }

:root, :root[data-theme="dark"] {
  --bg: #141416; --bg-top: #1E1E23; --surface: #222226; --surface-high: #2C2C31; --surface-highest: #38383E;
  --sidebar: rgba(27,27,31,0.85); --glass: rgba(28,28,32,0.85); --separator: rgba(255,255,255,0.12);
  --text: #F5F5F7; --text-2: #A1A1A8; --text-3: #6E6E75;
  --success: #30D158; --warning: #FF9F0A; --danger: #FF453A; --live: #FF453A;
  --scrim: rgba(0,0,0,0.70); --shadow: rgba(0,0,0,0.40);
  --accent: #FF9F0A; --accent-rgb: 255,159,10; --on-accent: #fff;
  --accent-soft: rgba(var(--accent-rgb),0.20); --wash-a: 0.16; --wash-b: 0.08;
  color-scheme: dark;
}
:root[data-theme="black"] {
  --bg: #000000; --bg-top: #050506; --surface: #111113; --surface-high: #1A1A1D; --surface-highest: #242428;
  --sidebar: rgba(10,10,11,0.90); --glass: rgba(16,16,18,0.90);
}
:root[data-theme="light"] {
  --bg: #F2F2F5; --bg-top: #FAFAFC; --surface: #FFFFFF; --surface-high: #F0F0F3; --surface-highest: #E4E4E9;
  --sidebar: rgba(247,247,249,0.90); --glass: rgba(255,255,255,0.90); --separator: rgba(0,0,0,0.10);
  --text: #1D1D1F; --text-2: #5E5E63; --text-3: #9A9AA0;
  --success: #28A745; --warning: #FF9500; --danger: #FF3B30; --live: #FF3B30;
  --scrim: rgba(0,0,0,0.60); --shadow: rgba(0,0,0,0.20);
  --accent-soft: rgba(var(--accent-rgb),0.14); --wash-a: 0.10; --wash-b: 0.05;
  color-scheme: light;
}
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --r-s: 8px; --r-m: 12px; --r-l: 16px; --r-xl: 22px;
  --pad-h: 20px; --pad-v: 14px; --gap: 16px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px); --safe-left: env(safe-area-inset-left, 0px);
  --poster-w: 112px;
  --ease: cubic-bezier(.2,.8,.2,1);
}
/* the layout's width (orientation.js sets these classes; the app may be turned, so no media queries) */
:root.lw-640 { --pad-h: 28px; --poster-w: 134px; }
:root.lw-1000 { --pad-h: 40px; --pad-v: 24px; --poster-w: 150px; }
:root { --lw: 100vw; --lh: 100vh; }

/* type scale (Theme.kt DefaultType) */
.t-display { font: 700 34px/40px var(--font); letter-spacing: -0.6px; }
.t-large { font: 600 28px/34px var(--font); letter-spacing: -0.4px; }
.t-title { font: 600 22px/28px var(--font); letter-spacing: -0.3px; }
.t-title2 { font: 600 18px/24px var(--font); letter-spacing: -0.2px; }
.t-headline { font: 600 15px/20px var(--font); letter-spacing: -0.1px; }
.t-body { font: 400 15px/21px var(--font); }
.t-callout { font: 400 14px/19px var(--font); }
.t-subhead { font: 400 13px/18px var(--font); }
.t-footnote { font: 400 12px/16px var(--font); }
.t-caption { font: 600 11px/14px var(--font); letter-spacing: 0.4px; }
.t-mono { font: 400 12px/16px ui-monospace, Menlo, monospace; }
.c2 { color: var(--text-2); } .c3 { color: var(--text-3); } .ca { color: var(--accent); } .cdanger { color: var(--danger); } .cok { color: var(--success); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 400 15px/21px var(--font); overscroll-behavior: none; }
/* iOS 26+ Home Screen apps open with a viewport one status bar shorter than the screen (812 of 874 pt) and
   leave the rest of the screen unpainted; a page as tall as the screen makes WebKit give it the full height. */
:root.standalone, :root.standalone body { height: 100vh; height: 100lvh; }
body { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overflow: hidden; }
input, textarea { -webkit-user-select: text; user-select: text; font: inherit; color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
img { display: block; -webkit-user-drag: none; }
a { color: var(--accent); }
.mi { width: 1em; height: 1em; fill: currentColor; flex: none; display: inline-block; vertical-align: middle; }

/* The screen behind everything: the soft gradient (AppBackground) or the plain colour. */
#app { position: fixed; inset: 0; overflow: hidden; background: var(--bg); transition: opacity 180ms ease-out; }
/* forced landscape: the whole app is turned 90° when a phone is held upright (orientation.js) */
#app.rot { inset: auto; left: 0; top: 0; transform-origin: 0 0; transform: rotate(-90deg) translateX(-100%); }
#app.switching { opacity: 0; }
:root[data-background="gradient"] #app {
  background:
    radial-gradient(ellipse 70% 55% at 12% 0%, rgba(var(--accent-rgb), var(--wash-a)), transparent 70%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(var(--accent-rgb), var(--wash-b)), transparent 70%),
    linear-gradient(180deg, var(--bg-top), var(--bg));
}
#screen { position: absolute; inset: 0; overflow: hidden; }
#screen > * { position: absolute; inset: 0; }
#overlays { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
#overlays > * { pointer-events: auto; }

.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; scrollbar-width: none; }
.scroll-x { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: none; }
.scroll::-webkit-scrollbar, .scroll-x::-webkit-scrollbar { display: none; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; } .col { display: flex; flex-direction: column; } .grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pad { padding-left: calc(var(--pad-h) + var(--safe-left)); padding-right: calc(var(--pad-h) + var(--safe-right)); }
.divider { height: 1px; background: var(--separator); flex: none; }

/* Pressed feedback: the press shrinks a touch and brightens (hot = finger down, from dom.js). */
.press { transition: transform 140ms var(--ease), background-color 140ms, opacity 140ms; }
.press.hot { transform: scale(0.97); }

/* Buttons (components/Buttons.kt): 44 tall, radius 11; Primary = accent tint; Secondary = surface. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 11px;
  background: var(--surface-high); color: var(--text); font: 600 15px var(--font); letter-spacing: -0.1px; white-space: nowrap; flex: none;
  transition: transform 140ms var(--ease), background-color 140ms, color 140ms; }
.btn .mi { font-size: 19px; }
.btn.compact { height: 36px; padding: 0 12px; border-radius: 9px; font: 600 13px var(--font); gap: 6px; } .btn.compact .mi { font-size: 16px; }
.btn.primary { background: var(--accent-soft); color: var(--accent); }
.btn.solid { background: var(--accent); color: var(--on-accent); }
.btn.danger { background: rgba(255,69,58,0.16); color: var(--danger); }
.btn.plain { background: transparent; }
.btn.glass { background: rgba(255,255,255,0.14); color: #fff; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.btn.hot { transform: scale(0.96); background: var(--accent); color: var(--on-accent); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.ibtn { width: 42px; height: 42px; border-radius: 50%; background: var(--surface-high); color: var(--text); display: inline-flex; align-items: center; justify-content: center; flex: none;
  transition: transform 140ms var(--ease), background-color 140ms; position: relative; }
.ibtn .mi { font-size: 21px; }
.ibtn.sq { border-radius: 10px; width: 40px; height: 40px; }
.ibtn.glass { background: rgba(255,255,255,0.14); color: #fff; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.ibtn.sel { background: var(--accent-soft); color: var(--accent); }
.ibtn.hot { transform: scale(0.92); background: var(--accent); color: var(--on-accent); }
.ibtn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--bg); }

/* Chips (UChip) */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--surface-high); color: var(--text);
  font: 500 13px var(--font); white-space: nowrap; flex: none; transition: transform 140ms var(--ease), background-color 140ms; }
.chip .mi { font-size: 16px; }
.chip.sel { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip.hot { transform: scale(0.96); background: var(--accent); color: var(--on-accent); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 5px; font: 600 10px/14px var(--font); letter-spacing: 0.3px; background: var(--surface-highest); color: var(--text); white-space: nowrap; }
.badge.live { background: var(--live); color: #fff; letter-spacing: 0.6px; }
.badge.accent { background: var(--accent); color: var(--on-accent); }
.badge.soft { background: var(--accent-soft); color: var(--accent); }
.badge.dark { background: rgba(0,0,0,0.62); color: #fff; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

/* Cards and surfaces */
.card { background: var(--surface); border-radius: var(--r-l); }
.glass-panel { background: var(--glass); border: 0.6px solid var(--separator); border-radius: 18px; -webkit-backdrop-filter: blur(30px) saturate(1.4); backdrop-filter: blur(30px) saturate(1.4); }
.section-title { font: 600 18px/24px var(--font); letter-spacing: -0.2px; color: var(--text); }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.section-head .more { margin-left: auto; font: 400 13px var(--font); color: var(--text-2); }

/* Text fields (UTextField) */
.field { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; border-radius: 12px; background: var(--surface-high); color: var(--text); border: 1.5px solid transparent; transition: border-color 140ms; }
.field:focus-within { border-color: var(--accent); }
.field .mi { color: var(--text-2); font-size: 20px; }
.field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font: 400 16px var(--font); color: var(--text); }
.field input::placeholder { color: var(--text-3); }
.field.compact { height: 40px; border-radius: 10px; } .field.compact input { font-size: 15px; }
.label { font: 600 13px var(--font); color: var(--text-2); margin: 0 0 6px 2px; }

/* Switch */
.switch { position: relative; width: 51px; height: 31px; border-radius: 16px; background: var(--surface-highest); flex: none; transition: background-color 180ms; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.3); transition: transform 220ms var(--ease); }
.switch.on { background: var(--success); }
.switch.on::after { transform: translateX(20px); }

/* Segmented control */
.segmented { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--surface-high); gap: 2px; }
.segmented button { height: 32px; padding: 0 14px; border-radius: 8px; font: 500 13px var(--font); color: var(--text-2); white-space: nowrap; }
.segmented button.sel { background: var(--surface-highest); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }

/* States */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 32px 24px; color: var(--text-2); }
.state .state-icon { width: 64px; height: 64px; border-radius: 18px; background: var(--surface-high); display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); margin-bottom: 6px; }
.state .state-icon .mi { font-size: 30px; }
.state h3 { margin: 0; font: 600 18px/24px var(--font); color: var(--text); letter-spacing: -0.2px; }
.state p { margin: 0; font: 400 14px/19px var(--font); color: var(--text-2); max-width: 420px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(var(--accent-rgb),0.22); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; } .spinner.lg { width: 40px; height: 40px; border-width: 4px; }
.spinner.white { border-color: rgba(255,255,255,0.25); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast { position: absolute; left: 50%; top: calc(var(--safe-top) + 14px); transform: translate(-50%, -16px); opacity: 0; z-index: 90; display: flex; align-items: center; gap: 10px;
  max-width: min(calc(var(--lw) * 0.92), 520px); padding: 11px 16px; border-radius: 14px; background: var(--glass); border: 0.6px solid var(--separator); color: var(--text);
  font: 500 14px/19px var(--font); box-shadow: 0 12px 32px var(--shadow); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); transition: opacity 200ms, transform 260ms var(--ease); pointer-events: none !important; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .mi { color: var(--accent); font-size: 20px; }

/* Backdrop + dialog (NoticeDialog / ConfirmDialog) */
.backdrop { position: absolute; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 24px; opacity: 0; transition: opacity 200ms; z-index: 70; }
.backdrop.show { opacity: 1; }
.dialog { width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px; padding: 22px; box-shadow: 0 24px 60px rgba(0,0,0,0.5); transform: scale(0.96); transition: transform 240ms var(--ease); }
.backdrop.show .dialog { transform: scale(1); }
.dialog .d-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.dialog .d-icon .mi { font-size: 26px; }
.dialog h3 { margin: 0 0 6px; font: 600 18px/24px var(--font); letter-spacing: -0.2px; }
.dialog p { margin: 0; font: 400 14px/20px var(--font); color: var(--text-2); white-space: pre-line; }
.dialog .d-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

/* Sheet (USheet): a panel from the bottom on phones, centred on wide screens */
.sheet-wrap { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity 220ms; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap.show { opacity: 1; }
.sheet { width: 100%; max-height: 88%; background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px 0 calc(var(--safe-bottom) + 12px); display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform 300ms var(--ease); box-shadow: 0 -12px 40px rgba(0,0,0,0.4); }
.sheet-wrap.show .sheet { transform: none; }
.sheet .grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-highest); margin: 0 auto 8px; flex: none; }
.sheet .sh-head { display: flex; align-items: center; gap: 12px; padding: 6px calc(20px + var(--safe-right)) 12px calc(20px + var(--safe-left)); flex: none; }
.sheet .sh-title { font: 600 18px/24px var(--font); letter-spacing: -0.2px; }
.sheet .sh-sub { font: 400 13px/18px var(--font); color: var(--text-2); }
.sheet .sh-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 calc(20px + var(--safe-right)) 0 calc(20px + var(--safe-left)); flex: 1; min-height: 0; scrollbar-width: none; }
/* centred on wide screens (not on a phone on its side: too short) */
:root.lw-700:not(.lh-short) {
  .sheet-wrap { align-items: center; }
  .sheet { width: min(560px, calc(var(--lw) * 0.92)); max-height: 82%; border-radius: 22px; padding-bottom: 14px; transform: scale(0.96); opacity: 0; transition: transform 240ms var(--ease), opacity 200ms; }
  .sheet-wrap.show .sheet { transform: none; opacity: 1; }
  .sheet .grabber { display: none; }
  .sheet .sh-head { padding-left: 20px; padding-right: 20px; } .sheet .sh-body { padding-left: 20px; padding-right: 20px; }
}

/* Lists of options (OptionPicker / ActionMenu rows) */
.opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 12px; text-align: left; transition: background-color 120ms; }
.opt .mi { font-size: 21px; color: var(--text-2); }
.opt .opt-text { flex: 1; min-width: 0; }
.opt .opt-label { font: 500 15px/20px var(--font); }
.opt .opt-detail { font: 400 12px/16px var(--font); color: var(--text-2); }
.opt .opt-check, .opt .opt-check .mi { color: var(--accent); }
.opt.sel .opt-label { color: var(--accent); font-weight: 600; }
.opt.hot { background: var(--surface-high); }
.opt.danger, .opt.danger .mi { color: var(--danger); }

/* Skeletons */
.sk { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-high) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.4s ease-in-out infinite; border-radius: 10px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* Screen transitions (router) */
#screen.enter-push > * { animation: push-in 300ms var(--ease); }
#screen.enter-pop > * { animation: pop-in 280ms var(--ease); }
#screen.enter-fade > * { animation: fade-in 240ms ease; }
@keyframes push-in { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop-in { from { transform: translateX(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
:root[data-animations="off"] *, :root[data-animations="off"] *::before, :root[data-animations="off"] *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }

/* haptics.js: an invisible <label>+switch laid over tappable controls so iOS ticks on the tap (as in v3).
   :where() keeps it at zero specificity, so a control's own position: absolute still wins. */
:where(.has-hap) { position: relative; }
label.hap-in { position: absolute; inset: 0; z-index: 3; margin: 0; padding: 0; border: 0; opacity: 0; border-radius: inherit; -webkit-tap-highlight-color: transparent; cursor: inherit; }
