/* liquid-glass-web — baseline tokens + components. Works on iOS Safari. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  --spring: cubic-bezier(.32, .72, 0, 1);

  --bg: #f2f2f7;
  --bg-wallpaper: radial-gradient(1200px 600px at 10% -10%, #cfe3ff 0%, transparent 60%),
                  radial-gradient(900px 500px at 110% 10%, #e6dcff 0%, transparent 55%), #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --label: #000000;
  --label-2: rgba(60, 60, 67, .6);
  --label-3: rgba(60, 60, 67, .3);
  --separator: rgba(60, 60, 67, .18);
  --tint: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;

  --glass-fill: rgba(255, 255, 255, .55);
  --glass-fill-solid: #f9f9fb;
  --glass-edge: rgba(255, 255, 255, .7);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .06);
  --glass-blur: 24px;

  --r-outer: 28px;
  --pad: 8px;
  --r-inner: calc(var(--r-outer) - var(--pad));
  --r-section: 20px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-wallpaper: radial-gradient(1200px 600px at 10% -10%, #0b2a52 0%, transparent 60%),
                    radial-gradient(900px 500px at 110% 10%, #2a1a4d 0%, transparent 55%), #000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, .6);
    --label-3: rgba(235, 235, 245, .3);
    --separator: rgba(84, 84, 88, .6);
    --tint: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --glass-fill: rgba(40, 40, 44, .55);
    --glass-fill-solid: #2c2c2e;
    --glass-edge: rgba(255, 255, 255, .14);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, .5);
  }
}
/* Explicit override via the panel's own toggle, independent of system preference. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-wallpaper: radial-gradient(1200px 600px at 10% -10%, #0b2a52 0%, transparent 60%),
                  radial-gradient(900px 500px at 110% 10%, #2a1a4d 0%, transparent 55%), #000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, .6);
  --label-3: rgba(235, 235, 245, .3);
  --separator: rgba(84, 84, 88, .6);
  --tint: #0a84ff;
  --green: #30d158;
  --red: #ff453a;
  --orange: #ff9f0a;
  --glass-fill: rgba(40, 40, 44, .55);
  --glass-fill-solid: #2c2c2e;
  --glass-edge: rgba(255, 255, 255, .14);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, .5);
}
:root[data-theme="light"] { color-scheme: light; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.35;
  color: var(--label);
  background: var(--bg-wallpaper);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

svg { display: block; }

/* Glass material — glassEffect() */
.glass {
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-edge);
  border-radius: var(--r-outer);
}
/* GlassEffectContainer — one background for grouped items */
.glass-group { display: inline-flex; gap: 2px; padding: 4px; }
.glass-group > * { border-radius: var(--r-inner); }

/* Top bar + scroll edge effect */
.bar-top {
  position: sticky; top: 8px; z-index: 10;
  margin: 8px; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.scroll-edge-top::before {
  content: ""; position: fixed; inset: 0 0 auto 0; height: 72px; z-index: 9; pointer-events: none;
  background: linear-gradient(var(--bg), transparent);
}
.scroll-edge-bottom::after {
  content: ""; position: fixed; inset: auto 0 0 0; height: 96px; z-index: 9; pointer-events: none;
  background: linear-gradient(transparent, var(--bg));
}
@media (min-width: 900px) {
  .scroll-edge-bottom::after { display: none; }
}

/* Floating tab bar — TabView */
.tab-bar {
  position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; gap: 2px; padding: 6px; border-radius: 999px; z-index: 20;
  transition: transform .4s var(--spring), padding .4s var(--spring);
}
.tab-bar a {
  display: grid; justify-items: center; gap: 2px;
  min-width: 64px; padding: 6px 12px; border-radius: 999px;
  font-size: 11px; font-weight: 500; color: var(--label-2); text-decoration: none;
}
.tab-bar a svg { width: 22px; height: 22px; margin: 0 auto; }
.tab-bar a[aria-current="page"] { color: var(--tint); background: color-mix(in srgb, var(--tint) 14%, transparent); }
.tab-bar.is-minimized { transform: translateX(-50%) scale(.86); }

/* Sidebar — sidebarAdaptable / NavigationSplitView */
.split { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 16px; }
.sidebar { display: none; }
@media (min-width: 900px) {
  .split { grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
  .split.has-inspector { grid-template-columns: 240px minmax(0, 1fr) 320px; }
  .sidebar { display: block; position: sticky; top: 16px; align-self: start; padding: var(--pad); }
  .tab-bar { display: none; }
}
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--r-inner); color: var(--label); text-decoration: none; font-size: 15px; font-weight: 500;
}
.sidebar a svg { width: 20px; height: 20px; flex: none; color: var(--label-2); }
.sidebar a[aria-current="page"] { background: color-mix(in srgb, var(--tint) 16%, transparent); color: var(--tint); }
.sidebar a[aria-current="page"] svg { color: var(--tint); }

/* Buttons — .glass / .glassProminent */
.btn-glass, .btn-prominent {
  font: 600 15px/1 var(--font); border: 0; cursor: pointer;
  padding: 12px 18px; border-radius: 999px;
  transition: transform .16s var(--spring), filter .2s;
}
.btn-glass {
  color: var(--label); background: var(--glass-fill);
  -webkit-backdrop-filter: blur(16px) saturate(180%); backdrop-filter: blur(16px) saturate(180%);
  box-shadow: inset 0 0 0 1px var(--glass-edge);
}
.btn-prominent { color: #fff; background: var(--tint); }
.btn-glass:active, .btn-prominent:active { transform: scale(.96); }
.btn-glass:disabled, .btn-prominent:disabled { opacity: .5; cursor: default; }
.btn-glass:disabled:active, .btn-prominent:disabled:active { transform: none; }

/* Circular icon-only glass button */
.btn-glass.icon {
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: inline-grid; place-items: center;
}
.btn-glass.icon svg { width: 19px; height: 19px; }

/* Content layer — solid inset grouped list */
.section-title { font-size: 20px; font-weight: 700; margin: 24px 4px 8px; }
.list-inset { background: var(--surface); border-radius: var(--r-section); overflow: hidden; }
.list-inset > .row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px; position: relative;
  width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: default;
}
.list-inset > button.row { cursor: pointer; }
.list-inset > .row + .row::before {
  content: ""; position: absolute; top: 0; right: 0; left: 56px; height: 1px; background: var(--separator);
  transform: scaleY(.5);
}
.row .subtitle { color: var(--label-2); font-size: 15px; }

/* Segmented control */
.segmented { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--separator); }
.segmented button {
  font: 500 13px var(--font); border: 0; background: transparent; color: var(--label);
  padding: 6px 14px; border-radius: 8px; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* Switch — knob goes glassy while pressed */
.switch { appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--separator);
  position: relative; cursor: pointer; transition: background .25s var(--spring); flex: none; }
.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,.2);
  transition: transform .3s var(--spring), width .2s var(--spring); }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.switch:active::after { width: 33px; background: rgba(255,255,255,.7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

/* Sheet — <dialog class="glass sheet"> */
.sheet {
  border: 0; color: var(--label); padding: 0; width: min(560px, calc(100% - 16px));
  max-height: min(88vh, 720px); margin: auto auto 8px; border-radius: 32px;
  overflow: hidden; display: flex; flex-direction: column; overscroll-behavior: contain;
}
.sheet::backdrop { background: rgba(0,0,0,.2); }
.sheet[open] { animation: sheet-in .4s var(--spring); }
@keyframes sheet-in { from { transform: translateY(40px) scale(.98); opacity: 0; } }
.sheet-grabber { width: 36px; height: 5px; border-radius: 999px; background: var(--label-3); margin: 10px auto 0; flex: none; }
.sheet-body { padding: 8px 20px 20px; overflow-y: auto; }

/* Status dot */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--label-3); flex: none; }
.dot.on { background: var(--green); } .dot.off { background: var(--red); }

/* Focus */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--tint) 60%, transparent); outline-offset: 2px; }

/* Accessibility fallbacks */
@media (prefers-reduced-transparency: reduce) {
  .glass, .btn-glass { background: var(--glass-fill-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  .glass, .btn-glass { background: var(--glass-fill-solid); border-color: var(--label-2); }
  .list-inset { box-shadow: inset 0 0 0 1px var(--separator); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
