/* mobiler-web default theme — injected by the shell on mount.
 *
 * The web twin of the concrete look the Android (Material 3) and SwiftUI shells
 * decide in code: each style-intent token (TextStyle, Tone, CardStyle, …) maps to
 * a class here. Colors are CSS variables so `Scaffold.dark_mode` flips the whole
 * theme by adding `.theme-dark`. A consuming app may override any of these classes
 * with its own later stylesheet. */

:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --line: #e3e4ee;
  --ink: #1a1c2a;
  --muted: #6b6f86;
  --primary: #3f4a8a;
  --primary-ink: #ffffff;
  --accent: #3f4a8a;
  --accent2: #3f4a8a;
  --accent-soft: rgba(63, 74, 138, 0.16);
  --radius: 14px;
  /* Spacing + font are theme-overridable (set inline by an app Theme); these are the defaults. */
  --gap: 12px;
  --pad: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.theme-dark {
  --bg: #15171f;
  --surface: #1e212b;
  --surface-2: #262a36;
  --line: #333748;
  --ink: #eceef5;
  --muted: #9aa0b4;
  --primary: #8c9bff;
  --primary-ink: #15171f;
  --accent: #8c9bff;
  --accent2: #8c9bff;
  --accent-soft: rgba(140, 155, 255, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px;
  background: var(--bg);
  color: var(--ink);
}
/* A Scaffold owns its own bars + body padding, so let it bleed to the edges. */
.app:has(.scaffold) { padding: 0; max-width: 430px; }

/* ---- layout ---- */
.col { display: flex; flex-direction: column; gap: calc(var(--gap) * 0.66); }
.row { display: flex; flex-direction: row; align-items: center; gap: calc(var(--gap) * 0.66); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Horizontal scroller / carousel — children lay out in a row that scrolls sideways. */
.scroller { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { flex: 0 0 auto; }

/* Search field — leading magnifier + pill input. */
.searchfield { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
.search-icon { color: var(--muted); }
.search-input { flex: 1; border: none; background: transparent; outline: none; font: inherit; color: var(--ink); }

/* Segmented control — exclusive options in a pill track. */
.segmented { display: flex; gap: 4px; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.segment { flex: 1; border: none; background: transparent; border-radius: 999px; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.segment.selected { background: var(--primary); color: #fff; }

/* Avatar — circular image with an optional status dot. */
.avatar { position: relative; display: inline-block; width: 48px; height: 48px; }
.avatar-img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.avatar-status { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bg); }

/* Star rating. */
.rating { display: inline-flex; gap: 2px; color: var(--accent); font-size: 16px; line-height: 1; }
.star { color: var(--accent); }
.star-tappable { border: none; background: transparent; cursor: pointer; font-size: 20px; color: var(--accent); padding: 0 1px; }

/* Modal bottom sheet — scrim + a panel rising from the bottom. */
.sheet-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 12px 18px 28px;
  box-shadow: 0 -8px 28px rgba(0,0,0,0.28); max-height: 80%; overflow-y: auto;
  animation: sheet-rise 0.24s ease;
}
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 12px; }
.sheet-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
@keyframes sheet-rise { from { transform: translateY(100%); } to { transform: translateY(0); } }

.card {
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}
.card-elevated { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.card-outlined { background: transparent; border: 1px solid var(--line); }
.card-filled { background: var(--surface-2); }
/* Brand gradient card (promo banner) — fills seed → accent. */
.card-brand { background: linear-gradient(135deg, var(--primary), var(--accent2)); color: #fff; border: none; }
.card-brand .t-caption { color: rgba(255,255,255,0.85); }
/* A tappable card is a <button>; strip the native chrome so it reads as a card. */
.card-tappable {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  border: none;
  cursor: pointer;
}

/* Z-stack. Scrim variant: bg image sets the size; overlay + content layer on top. */
.box { position: relative; }
.box-scrim { border-radius: 16px; overflow: hidden; }
.box-scrim > .img { display: block; }
.box-scrim > .scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); }
.box-scrim > .box-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  color: #fff;
}
.align-top-start    > .box-content { justify-content: flex-start; align-items: flex-start; }
.align-top-end      > .box-content { justify-content: flex-start; align-items: flex-end; }
.align-center       > .box-content { justify-content: center;     align-items: center; }
.align-bottom-start > .box-content { justify-content: flex-end;   align-items: flex-start; }
.align-bottom-center> .box-content { justify-content: flex-end;   align-items: center; }
.align-bottom-end   > .box-content { justify-content: flex-end;   align-items: flex-end; }

/* ---- content ---- */
.t-title    { font-size: 28px; font-weight: 750; margin: 2px 0; letter-spacing: -0.01em; }
.t-subtitle { font-size: 18px; font-weight: 650; margin: 0; }
.t-emphasis { font-size: 15px; font-weight: 650; margin: 0; }
.t-caption  { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.4; }
.t-body     { font-size: 15px; margin: 0; }

.img { display: block; width: 100%; object-fit: cover; }
.ratio-wide   { aspect-ratio: 16 / 10; }
.ratio-square { aspect-ratio: 1 / 1; }
.ratio-tall   { aspect-ratio: 3 / 4; }
.img-rounded  { border-radius: 16px; }
.img-circle   { border-radius: 50%; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
}
.tone-neutral { background: var(--surface-2); color: var(--muted); }
.tone-success { background: #e6f4ea; color: #1e7e34; }
.tone-warning { background: #fff4e5; color: #b66a00; }
.tone-danger  { background: #fde8e8; color: #c0392b; }
.tone-info    { background: var(--accent-soft); color: var(--accent); }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.dot-indigo { background: #5c6bc0; }
.dot-teal   { background: #26a69a; }
.dot-coral  { background: #ff7043; }
.dot-amber  { background: #ffb300; }
.dot-lime   { background: #9ccc65; }
.dot-pink   { background: #ec407a; }

.divider { border: none; border-top: 1px solid var(--line); margin: 8px 0; }

.spacer { flex: none; }
.sp-xs { height: 4px; }
.sp-sm { height: 8px; }
.sp-md { height: 12px; }
.sp-lg { height: 16px; }
.sp-xl { height: 24px; }

/* ---- input / actions ---- */
.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.btn-filled   { background: var(--primary); color: var(--primary-ink); }
.btn-outlined { background: transparent; color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.btn-text     { background: transparent; color: var(--primary); padding: 10px 8px; }

.iconbtn { background: transparent; border: none; cursor: pointer; font-size: 17px; padding: 4px; }

.chip {
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.chip.selected { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.field {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  background: var(--surface);
  color: var(--ink);
}

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* A checkbox styled as a switch (Toggle widget). */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 15px; }
.toggle input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.toggle input:checked { background: var(--primary); }
.toggle input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.toggle input:checked::before { transform: translateX(18px); }

.slider { width: 100%; accent-color: var(--primary); }

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
}
.stepper-value { font-size: 18px; min-width: 24px; text-align: center; }

/* ---- shell (Scaffold) ---- */
.scaffold { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg); color: var(--ink); }
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
}
.topbar .title { flex: 1; text-align: center; font-size: 17px; font-weight: 650; }
.back { border: none; background: transparent; color: var(--ink); font-size: 24px; line-height: 1; cursor: pointer; }
.scaffold-body { flex: 1; padding: var(--pad); }
/* Navigation transitions — the web twin of the native shells' push/pop slide and
 * lateral crossfade. The shell alternates the -a/-b class each navigation so the
 * animation restarts; same-route data updates carry no class (re-render in place). */
@keyframes nav-push { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes nav-pop  { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes nav-fade { from { opacity: 0; } to { opacity: 1; } }
.nav-push-a, .nav-push-b { animation: nav-push 0.28s ease; }
.nav-pop-a,  .nav-pop-b  { animation: nav-pop 0.28s ease; }
.nav-fade-a, .nav-fade-b { animation: nav-fade 0.28s ease; }
.tabbar { display: flex; border-top: 1px solid var(--line); background: var(--bg); position: sticky; bottom: 0; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; border: none; background: transparent; padding: 8px 12px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; }
.tab.selected { color: var(--accent); font-weight: 650; }
.tab-icon { font-size: 20px; line-height: 1; }
.tab-label { font-size: 12px; }

/* Floating action button — raised primary action, pinned bottom-right over the body. */
.fab {
  position: fixed; right: 18px; bottom: 84px; z-index: 5;
  width: 56px; height: 56px; border: none; border-radius: 18px;
  background: var(--primary); color: #fff; font-size: 24px; line-height: 1;
  box-shadow: 0 6px 18px rgba(0,0,0,0.28); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.scaffold { position: relative; }

/* Transient toast (cx.toast) — appended to <body>, auto-removed after a beat. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  max-width: 80%;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(26, 28, 42, 0.92);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  animation: toast-in 0.2s ease, toast-out 0.3s ease 2.3s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toast-out { to { opacity: 0; } }

/* ---- responsive: tablets / large viewports ---- */
/* Phone layouts (below the breakpoint) are deliberately left exactly as-is. Past it
 * we *use* the extra width instead of stretching the phone column: grids gain
 * columns, plain screens stop running edge-to-edge, and a Scaffold's bottom tab-bar
 * becomes a left navigation rail — the web twin of the native shells' NavigationRail.
 * The rail is pure layout: the same three Scaffold children (topbar, body, tabbar)
 * are re-placed via grid areas, so there's no DOM/markup change, only CSS. */
@media (min-width: 768px) {
  .app { max-width: 900px; }
  .app:has(.scaffold) { max-width: 1100px; }

  /* Fill the wider space with more columns rather than two stretched ones. */
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

  /* Don't let a plain (non-grid) screen's text/rows run the full width: cap + center. */
  .scaffold-body { max-width: 760px; margin: 0 auto; width: 100%; }

  /* Tab-bar → left navigation rail, only when the Scaffold actually has tabs. */
  .scaffold:has(.tabbar) {
    display: grid;
    grid-template-columns: 224px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "rail topbar" "rail body";
  }
  .scaffold:has(.tabbar) > .topbar { grid-area: topbar; }
  .scaffold:has(.tabbar) > .scaffold-body { grid-area: body; }
  .scaffold:has(.tabbar) > .tabbar {
    grid-area: rail;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    border-top: none;
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 12px 8px;
  }
  .scaffold:has(.tabbar) > .tabbar .tab {
    flex: none;
    text-align: left;
    border-radius: 10px;
    padding: 12px 14px;
  }
  .scaffold:has(.tabbar) > .tabbar .tab.selected { background: var(--accent-soft); }
}
