/* iOS grouped surfaces. Structural and data-specific rules stay in styles.css. */
:root {
  --ground: #f2f2f7;
  --surface: #ffffff;
  --raised: #f5f5f8;
  --active: #e8e8ef;
  --border: #e5e5eb;
  --rule: #ededf2;
  --control: #d6d6df;
  --text: #1c1c1e;
  --muted: #62626a;
  --faint: #62626a;
  --accent: #0065d5;
  --accent-tint: #edf4ff;
  --primary: #0065d5;
  --primary-ink: #ffffff;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  --fs-title: 28px;
  --fs-section: 16px;
  --sidebar-width: 236px;
  --topbar-height: 76px;
  --sheet-inset: 0px;
  --gap: 22px;
  --radius-sheet: 22px;
  --radius-card: 18px;
  --radius-control: 12px;
  --control-height: 40px;
  --nav-row: 44px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ground: #000000;
  --surface: #1c1c1e;
  --raised: #2c2c2e;
  --active: #36363a;
  --border: #38383c;
  --rule: #333337;
  --control: #505057;
  --text: #f5f5f7;
  --muted: #b9b9c1;
  --faint: #a6a6af;
  --accent: #80b9ff;
  --accent-tint: #172d47;
  --primary: #80b9ff;
  --primary-ink: #091828;
  color-scheme: dark;
}
html { scrollbar-gutter: stable; scroll-padding-top: 20px; }
html:has(.about-dialog[open]), html.navigation-open { overflow: hidden; }
body { min-width: 320px; }
::selection { background: #cce1ff; color: #1c1c1e; }
button, summary, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, summary { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
input, textarea { caret-color: var(--accent); }
.app-shell { min-height: 100dvh; }
.sidebar { margin: 16px 0 16px 16px; height: calc(100dvh - 32px); padding: 22px 12px 16px; border-radius: 22px; background: var(--surface); top: 16px; }
.brand { padding: 0 8px 26px; gap: 10px; }
.brand-mark-bg { fill: none; stroke: var(--accent); }
.brand-name { font-size: 16px; line-height: 22px; letter-spacing: -.4px; }
.brand-scope { margin-top: 2px; font-size: 12px; }
.nav-section { gap: 5px; }
.nav-count, .nav-badge, .sidebar-app-meta, .tab-count, .pill { font-size: 12px; }
.nav-btn { min-height: 44px; border-radius: 12px; padding-inline: 12px; }
.nav-btn[aria-current="page"] { background: var(--accent-tint); color: var(--accent); }
.nav-btn[aria-current="page"]::before { display: none; }
.sidebar-app-btn { border-radius: 10px; min-height: 40px; }
.sidebar-footer { padding-top: 16px; font-size: 12px; }
.topbar { background: transparent; padding: 0 28px; gap: 16px; grid-template-columns: 1fr auto; padding-top: env(safe-area-inset-top, 0px); }
.topbar-left { display: none; }
.search-box { width: min(100%, 440px); justify-self: start; }
.search-input { height: 42px; background: var(--active); border-color: transparent; border-radius: 12px; font-size: 14px; }
.search-input:focus { outline: 3px solid #0065d522; border-color: var(--accent); }
.search-icon { color: var(--muted); }
.search-kbd { display: none; }
.search-clear { min-width: 28px; min-height: 28px; border-radius: 50%; }
.topbar-right { gap: 12px; }
.sheet-wrap { padding: 0 28px 28px; }
.sheet { border: 0; border-radius: 0; padding: 14px 0 calc(78px + env(safe-area-inset-bottom, 0px)); background: transparent; min-height: calc(100dvh - var(--topbar-height)); }
.view { gap: 26px; }
.title-row { gap: 20px; }
.title-block { flex-basis: 100%; }
.title-block h1 { font-weight: 700; letter-spacing: -.7px; line-height: 1.25; }
.title-sub { margin-top: 9px; max-width: 78ch; font-size: 14px; line-height: 1.6; }
.title-actions { gap: 8px; width: 100%; }
.title-actions .primary { margin-left: auto; }
.btn { height: auto; min-height: 40px; padding: 9px 15px; border-color: transparent; border-radius: 999px; background: var(--surface); color: var(--accent); font-size: 13px; font-weight: 550; transition: background-color 140ms ease-out, transform 140ms var(--ease-out); }
.btn.primary { border-color: transparent; min-height: 44px; }
.btn:disabled, .btn.primary:disabled { opacity: .45; border-color: transparent; cursor: default; }
.btn.sm { height: auto; min-height: 36px; padding: 7px 12px; font-size: 12px; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.theme-toggle { background: var(--surface); min-height: 40px; }
.text-action { min-height: 28px; }
.kpis { border: 0; border-radius: 22px; padding: 18px 0; }
.kpi { padding: 0 20px; }
.kpi-label { font-size: 12px; line-height: 1.5; }
.kpi-value { font-weight: 600; font-size: 26px; line-height: 1.3; margin-block: 5px; }
.kpi-meta { line-height: 1.5; font-size: 12px; }
.workspace-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: stretch; }
.panel { border: 0; border-radius: 22px; padding: 22px; }
.panel-header { align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-header h2 { letter-spacing: -.2px; font-size: 16px; }
.panel-meta { font-size: 12px; }
.input-hint { font-size: 12px; line-height: 1.6; margin-bottom: 18px; }
.code-input { min-height: 320px; padding: 16px; background: var(--raised); border-color: transparent; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: 14px; line-height: 1.9; }
.code-input:focus { outline: 3px solid #0065d522; border-color: var(--accent); }
.input-status { font-size: 12px; line-height: 1.5; }
.input-footer { margin-top: 16px; gap: 10px; }
.input-footer .btn { background: var(--accent-tint); }
.mode-bar { border: 0; margin-bottom: 18px; gap: 12px; }
.mode-tabs { display: flex; gap: 2px; padding: 4px; background: var(--active); border-radius: 12px; width: 100%; }
.mode-tab { flex: 1; justify-content: center; min-height: 38px; padding: 8px 10px; border-radius: 9px; font-size: 12px; }
.mode-tab[aria-selected="true"] { color: var(--text); background: var(--surface); }
.mode-tab[aria-selected="true"]::after { display: none; }
.tab-count, .mode-tab[aria-selected="true"] .tab-count { background: transparent; padding-inline: 2px; color: var(--muted); min-width: 0; }
.global-summary-strip, .mode-bar-actions { display: none; }
.global-summary-stats { gap: 3px; line-height: 1.6; }
.global-batch-card { padding: 16px; border: 1px solid transparent; border-radius: 15px; background: var(--raised); }
.global-batch-card.is-copied { border-color: var(--positive); }
.app-card { border: 1px solid var(--rule); border-radius: 15px; overflow: hidden; }
.app-card-head { padding: 16px; background: var(--raised); }
.app-card-name { font-size: 14px; overflow-wrap: anywhere; }
.batch-head { gap: 10px; flex-wrap: wrap; }
.batch-info { flex-wrap: wrap; row-gap: 8px; }
.batch-label { font-size: 13px; }
.batch-count { font-size: 12px; }
.batch-actions { flex-wrap: wrap; gap: 8px; }
.global-batch-card .btn { background: var(--surface); }
.query-code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; white-space: pre-wrap; }
.query-code code { font: inherit; }
.slot-cell { border-radius: 2px; }
.slot-cell.filled { background: var(--accent); }
.output-list { gap: 14px; max-height: 560px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.output-empty { gap: 22px; }
.empty-callout { border: 0; background: transparent; padding: 22px 0 8px; }
.empty-title { font-size: 16px; letter-spacing: -.3px; }
.empty-desc { font-size: 13px; line-height: 1.65; margin-top: 8px; }
.empty-actions { margin-top: 16px; }
.empty-actions .btn { background: var(--accent-tint); }
.syntax-preview { border: 0; background: var(--raised); padding: 16px; border-radius: 15px; }
.syntax-preview-title { font-size: 12px; font-weight: 550; }
.syntax-preview-meter { font-size: 12px; }
.syntax-preview-head { flex-wrap: wrap; margin: 0; gap: 10px; }
.table-wrap { overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
table th { font-size: 12px; }
table td { font-size: 12px; overflow-wrap: anywhere; }
.guide-card { border: 0; border-radius: 22px; background: var(--surface); padding: 22px; }
.guide-card p { color: var(--muted); font-size: 13px; line-height: 1.65; }
.guide-sample-code { border: 0; background: var(--raised); border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.8; }
.toast { display: flex; align-items: center; gap: 12px; right: 90px; border: 1px solid var(--border); border-radius: 16px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); max-width: min(440px, calc(100vw - 130px)); background: var(--surface); color: var(--text); font-size: 13px; line-height: 1.5; box-shadow: 0 8px 28px #00000014; }
.toast.visible { pointer-events: auto; }
.toast.is-error { background: var(--surface); border-color: var(--negative); color: var(--negative); }
.toast-close { display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0; border: 0; border-radius: 50%; background: var(--raised); color: var(--muted); font-size: 20px; cursor: pointer; }
.information-button { position: fixed; right: max(22px, env(safe-area-inset-right, 0px)); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); display: grid; place-items: center; width: 50px; height: 50px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--accent); box-shadow: 0 6px 22px #00000012; z-index: 20; }
.information-button:active { transform: scale(.96); }
.about-dialog { width: min(490px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 0; border: 0; border-radius: 26px; color: var(--text); background: var(--surface); box-shadow: 0 18px 64px #00000026; overscroll-behavior: contain; }
.about-dialog::backdrop { background: #1c1c2455; }
.about-content { padding: 22px 26px 28px; }
.about-toolbar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: flex-end; gap: 14px; padding-block: 3px; margin-bottom: 22px; background: var(--surface); }
.about-toolbar > span { color: var(--muted); font-size: 12px; }
.about-toolbar .btn { background: var(--accent-tint); }
.about-dialog h2 { font-size: 25px; line-height: 1.3; letter-spacing: -.6px; }
#about-description { font-size: 14px; color: var(--muted); line-height: 1.6; margin: 8px 0 24px; }
.about-section { padding-block: 20px; border-top: 1px solid var(--rule); }
.about-section:last-child { padding-bottom: 0; }
.about-section h3 { font-size: 14px; font-weight: 600; }
.about-section p { margin-top: 8px; font-size: 13px; line-height: 1.7; color: var(--muted); }
@media (min-width: 1600px) { .sheet, .topbar { max-width: 1380px; } }
@media (max-width: 1200px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .code-input { min-height: 240px; }
}
@media (max-width: 860px) {
  :root { --topbar-height: 72px; }
  .sidebar { top: 12px; margin: 0; left: 12px; height: calc(100dvh - 24px); border: 0; border-radius: 22px; transform: translateX(calc(-100% - 12px)); visibility: hidden; }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .sidebar-close { border: 0; background: var(--raised); width: 40px; height: 40px; border-radius: 50%; }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; padding-inline: 20px; gap: 12px; }
  .topbar-left { display: flex; }
  .topbar-brand-mobile { display: none; }
  .menu-toggle { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--surface); }
  .search-box { width: 100%; }
  .sheet-wrap { padding: 0 20px 20px; }
  .sheet { border: 0; border-radius: 0; padding-top: 14px; }
  .kpis { padding: 0; }
  .kpi { padding: 18px; }
  .code-input { min-height: 220px; }
  .title-block h1 { font-size: 27px; }
  .workspace-grid { gap: 18px; }
  .theme-toggle-label { display: none; }
  .btn.theme-toggle { width: 40px; padding: 0; }
  .search-input { font-size: 16px; }
}
@media (max-width: 540px) {
  .topbar { gap: 8px; padding-inline: 16px; }
  .sheet-wrap { padding-inline: 16px; }
  .view { gap: 22px; }
  .title-row { gap: 18px; }
  .title-block h1 { font-size: 25px; }
  .title-sub { font-size: 13px; }
  .title-actions { gap: 8px; }
  .title-actions .btn { min-height: 42px; padding-inline: 12px; flex: 1 1 auto; font-size: 12px; }
  .title-actions .primary { margin-left: 0; flex-basis: 100%; }
  .panel { padding: 18px; }
  .panel-header h2 { font-size: 15px; }
  .panel-header-right { gap: 8px; }
  .panel-meta { font-size: 12px; }
  .code-input { font-size: 16px; line-height: 1.75; min-height: 230px; padding: 13px; }
  .mode-bar { margin-top: 3px; }
  .mode-tab { padding-inline: 6px; font-size: 12px; min-height: 40px; }
  .mode-tabs { min-width: 0; }
  .global-summary-stats { gap: 2px; }
  .global-batch-card { padding: 14px; }
  .output-list { max-height: none; overflow-y: visible; }
  .global-batch-card .batch-head { align-items: flex-start; }
  .global-batch-card .batch-info { width: 100%; }
  .batch-actions { margin-left: auto; }
  .slot-meter { gap: 2px; }
  .batch-count { font-size: 12px; }
  .app-card-head { padding: 14px; }
  .app-card-actions { width: 100%; justify-content: flex-end; }
  .btn.sm { min-height: 40px; }
  .kpi-label { font-size: 12px; }
  .kpi-meta { font-size: 12px; }
  .kpi-value, .kpi-lead .kpi-value { font-size: 26px; }
  .syntax-preview { padding: 13px; }
  .query-code { font-size: 12px; }
  .guide-card { padding: 18px; }
  .guide-card-head { flex-wrap: wrap; }
  .information-button { right: max(18px, env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); width: 48px; height: 48px; }
  .about-dialog { margin: auto auto max(12px, env(safe-area-inset-bottom, 0px)); }
  .about-content { padding: 18px 22px 24px; }
  .toast { left: 16px; right: auto; max-width: calc(100vw - 98px); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { background: var(--active); border-color: transparent; }
  .btn.primary:hover:not(:disabled) { background: var(--primary); opacity: .9; }
  .information-button:hover { background: var(--accent-tint); }
}
@media (hover: none) {
  .btn:hover:not(:disabled) { background: var(--surface); border-color: transparent; }
  .btn.primary:hover:not(:disabled) { background: var(--primary); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
