/* macOS-style UI: system font, translucent sidebar, flat panes with hairline separators, light + dark. */
:root {
  color-scheme: light dark;
  --window: #f5f5f7;
  --sidebar: rgba(236, 236, 240, .86);
  --pane: #ffffff;
  --pane-2: #f7f7f9;
  --control: #ffffff;
  --control-hover: #f2f2f4;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, .10);
  --line-strong: rgba(0, 0, 0, .16);
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, .12);
  --accent-ink: #0060df;
  --green: #1f8f3d;
  --green-fill: #34c759;
  --green-bg: rgba(52, 199, 89, .14);
  --red: #d70015;
  --red-bg: rgba(255, 59, 48, .12);
  --amber: #b25000;
  --amber-bg: rgba(255, 149, 0, .14);
  --card: #ffffff;
  --card-on: #f3fbf5;
  --shadow-control: 0 .5px 1px rgba(0, 0, 0, .18), 0 0 0 .5px rgba(0, 0, 0, .08);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .06), 0 0 0 .5px rgba(0, 0, 0, .08);
  --shadow-float: 0 12px 40px rgba(0, 0, 0, .22), 0 0 0 .5px rgba(0, 0, 0, .12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --window: #1c1c1e;
    --sidebar: rgba(44, 44, 46, .86);
    --pane: #232325;
    --pane-2: #2a2a2d;
    --control: #3a3a3c;
    --control-hover: #444447;
    --ink: #f5f5f7;
    --muted: #a1a1a6;
    --line: rgba(255, 255, 255, .10);
    --line-strong: rgba(255, 255, 255, .18);
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, .22);
    --accent-ink: #4da3ff;
    --green: #32d74b;
    --green-fill: #30d158;
    --green-bg: rgba(48, 209, 88, .16);
    --red: #ff6961;
    --red-bg: rgba(255, 69, 58, .18);
    --amber: #ffb340;
    --amber-bg: rgba(255, 159, 10, .18);
    --card: #2c2c2e;
    --card-on: #26332a;
    --shadow-control: 0 .5px 1px rgba(0, 0, 0, .5), 0 0 0 .5px rgba(255, 255, 255, .08);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 .5px rgba(255, 255, 255, .07);
    --shadow-float: 0 16px 48px rgba(0, 0, 0, .6), 0 0 0 .5px rgba(255, 255, 255, .12);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--window);
  font: 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: 28px; padding: 0 12px; border: 0; border-radius: 7px;
  background: var(--control); box-shadow: var(--shadow-control);
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--control-hover); }
button:active:not(:disabled) { filter: brightness(.96); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; }
button.primary { background: var(--accent); color: #fff; box-shadow: 0 .5px 1px rgba(0, 0, 0, .25); }
button.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
button.danger { color: var(--red); }
button.small { min-height: 24px; padding: 0 9px; font-size: 12px; }
button.icon { width: 28px; padding: 0; display: inline-grid; place-items: center; }
button.plain { background: transparent; box-shadow: none; color: var(--muted); }
button.plain:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-ink); }
button.plain.on { color: var(--accent); background: var(--accent-soft); }
input, select, textarea {
  width: 100%; padding: 6px 9px; border: 0; border-radius: 7px;
  background: var(--control); box-shadow: inset 0 0 0 .5px var(--line-strong), 0 .5px 0 rgba(0, 0, 0, .04);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
svg { display: block; }
.kicker { margin: 0; color: var(--muted); font-weight: 600; letter-spacing: .02em; font-size: 11px; }
h2 { margin: 0; font-size: 15px; font-weight: 650; line-height: 1.25; }
h3 { margin: 16px 0 6px; font-size: 13px; font-weight: 650; }
.muted { color: var(--muted); font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12px; }
.hidden { display: none !important; }

/* ─── Window layout: sidebar | detail | log ─────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(380px, 1.15fr) minmax(340px, 1fr);
  height: 100vh; height: 100dvh;
}
.panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--pane); overflow: hidden; }
.panel + .panel { border-left: .5px solid var(--line-strong); }
#panelList { background: var(--sidebar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); container-type: inline-size; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 52px; padding: 8px 14px; border-bottom: .5px solid var(--line);
}
.panel-head > div { min-width: 0; }
#detailTitle, #logTitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#logMeta { font-size: 11.5px; text-align: right; }
.toolbar { display: flex; align-items: center; gap: 2px; }
.scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, .35); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
.mobile-tabs { display: none; }

/* Flags (only shown when something is off) */
.flagbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 0; }
.flagbar:empty { display: none; }
.flag { padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.flag.warn { background: var(--amber-bg); color: var(--amber); }

/* Search (hidden until the magnifier is pressed) */
.search-wrap { position: relative; padding: 8px 12px 2px; }
.search-wrap svg { position: absolute; left: 21px; top: 50%; margin-top: 3px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search { padding-left: 28px; border-radius: 8px; }

/* ─── List: groups of horizontal cards ──────────────────────────────────── */
.list { padding: 6px 10px 24px; }
.group { margin-top: 8px; }
.group-head {
  display: flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 4px;
  color: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .02em; user-select: none;
}
.group-head .disclosure { width: 20px; min-height: 20px; padding: 0; background: transparent; box-shadow: none; color: var(--muted); display: grid; place-items: center; }
.group-head .disclosure svg { transition: transform .15s ease; }
.group.collapsed .disclosure svg { transform: rotate(-90deg); }
.group-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; cursor: default; }
.group-name-input { flex: 1; min-width: 0; padding: 2px 6px; font-size: 12px; font-weight: 600; text-transform: none; }
.group-count { flex: none; padding: 0 6px; border-radius: 999px; background: var(--line); font-size: 10.5px; line-height: 16px; }
.group-tools { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .12s ease; }
.group-head:hover .group-tools, .group-head:focus-within .group-tools { opacity: 1; }
.group-tools button { width: 22px; min-height: 22px; padding: 0; background: transparent; box-shadow: none; color: var(--muted); display: grid; place-items: center; }
.group-tools button:hover { background: var(--accent-soft); color: var(--accent-ink); }
.group-body { display: grid; gap: 6px; min-height: 8px; padding: 2px 0 4px; }
.group.collapsed .group-body { display: none; }
.group-empty { padding: 10px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--muted); font-size: 12px; text-align: center; }

.grip {
  flex: none; width: 16px; align-self: stretch; display: grid; place-items: center;
  color: var(--muted); opacity: .45; cursor: grab; touch-action: none;
}
.grip:hover { opacity: 1; }
.group-head .grip { align-self: center; height: 20px; }
.list.filtering .grip { display: none; }

.item {
  display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 10px 9px 4px;
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow-card);
  cursor: default; transition: box-shadow .15s ease, background-color .15s ease;
}
.item:hover { box-shadow: var(--shadow-card), 0 2px 8px rgba(0, 0, 0, .06); }
.item.selected { box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(0, 0, 0, .08); }
.item:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent); }
.item-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.item-name { font-weight: 600; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 6px; vertical-align: -3px; border-radius: 5px; background: var(--accent); color: #fff; }
.item.off .item-name { color: var(--muted); font-weight: 500; }
.item-meta { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 11.5px; }
.item-meta span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta .dot { flex: none; width: 7px; height: 7px; margin: 0; }
.item-meta .dot.none { background: var(--line-strong); }
.item.off .item-meta .dot { background: var(--line-strong); animation: none; }
.item-alert { justify-self: start; max-width: 100%; margin-top: 2px; padding: 1px 7px; border-radius: 5px; font-size: 11.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-alert.fail { color: var(--red); background: var(--red-bg); }
.item-alert.warn { color: var(--amber); background: var(--amber-bg); }
.item-alert.run { color: var(--accent-ink); background: var(--accent-soft); }
.item-alert.success { display: none; }
.item-side { flex: none; display: flex; align-items: center; gap: 8px; }
.item-side .play { width: 26px; min-height: 26px; padding: 0; display: grid; place-items: center; color: var(--accent); background: transparent; box-shadow: none; opacity: 0; transition: opacity .12s ease; }
.item-side .play:hover:not(:disabled) { background: var(--accent-soft); }
.item:hover .play, .item.selected .play, .item:focus-within .play, .item-side .play:disabled { opacity: 1; }
.item .switch { width: 32px; min-height: 19px; height: 19px; }
.item .switch::after { width: 15px; height: 15px; }
.item .switch[aria-checked="true"]::after { transform: translateX(13px); }

/* macOS switch */
.switch {
  position: relative; width: 38px; min-height: 22px; height: 22px; padding: 0; border-radius: 999px;
  background: rgba(120, 120, 128, .32); box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .06); flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .18s ease;
}
.switch:hover:not(:disabled) { background: rgba(120, 120, 128, .42); }
.switch[aria-checked="true"], .switch[aria-checked="true"]:hover:not(:disabled) { background: var(--green-fill); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }

/* Drag & drop */
.dragging { position: fixed !important; z-index: 100; margin: 0 !important; pointer-events: none; box-shadow: var(--shadow-float) !important; opacity: .96; }
.group.dragging { background: var(--sidebar); border-radius: 10px; padding: 4px; }
.drop-placeholder { border-radius: 10px; background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
body.is-dragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 1px 7px; border-radius: 5px; background: var(--line); font-size: 11px; font-weight: 550; line-height: 17px; }
.chip.success { color: var(--green); background: var(--green-bg); }
.chip.fail { color: var(--red); background: var(--red-bg); }
.chip.run { color: var(--accent-ink); background: var(--accent-soft); }
.chip.warn { color: var(--amber); background: var(--amber-bg); }
.chip.clip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Detail header on/off switch */
.head-switch { flex: none; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; cursor: pointer; }

/* ─── Detail ────────────────────────────────────────────────────────────── */
.detail { padding: 12px 16px; }
.desc { margin: 0 0 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: minmax(90px, auto) 1fr; gap: 6px 12px; margin: 0 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 8px; }
.actions select { width: auto; max-width: 100%; }
.run-row select { flex: 1 1 200px; min-width: 0; }
.run-row button { flex: none; }
.runs-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; border-top: .5px solid var(--line); background: var(--pane-2); }
.runs { list-style: none; margin: 0; padding: 4px 8px 12px; }
.runs li { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; padding: 7px 8px; border-radius: 7px; cursor: default; }
.runs li:hover { background: var(--pane-2); }
.runs li.selected { background: var(--accent-soft); }
.dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #8e8e93; }
.dot.success, .dot.dry_run { background: var(--green-fill); }
.dot.failed, .dot.warning { background: #ff3b30; }
.dot.running { background: var(--accent); animation: pulse 1s infinite; }
.dot.skipped_condition, .dot.skipped_cap, .dot.cancelled { background: #ff9500; }
@keyframes pulse { 50% { opacity: .35; } }
.run-summary { grid-column: 2; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 10px; }
.schedule-table th, .schedule-table td { border-bottom: .5px solid var(--line); padding: 5px 6px; text-align: left; vertical-align: top; }
.schedule-table th { color: var(--muted); font-weight: 600; }

/* ─── Log + chat ────────────────────────────────────────────────────────── */
.tabs.single { display: none; }
.tabs { display: flex; gap: 0; margin: 8px 16px 0; padding: 2px; border-radius: 8px; background: rgba(120, 120, 128, .14); align-self: flex-start; }
.tab { min-height: 24px; border-radius: 6px; background: transparent; box-shadow: none; color: var(--ink); font-size: 12px; }
.tab:hover:not(:disabled) { background: transparent; }
.tab.active, .tab.active:hover:not(:disabled) { background: var(--control); box-shadow: var(--shadow-control); }
.log-body { padding: 10px 16px; }
pre.log { margin: 0; white-space: pre-wrap; word-break: break-word; font: 11.5px/1.55 var(--mono); }
pre.log .err { color: var(--red); }
.msg { border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--pane-2); box-shadow: inset 0 0 0 .5px var(--line); }
.msg-to { font-weight: 600; margin-bottom: 6px; }
.msg pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.5 var(--font); }
.msg table { border-collapse: collapse; font-size: 12px; margin: 6px 0; }
.msg td, .msg th { border: .5px solid var(--line-strong); padding: 3px 7px; text-align: left; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }
.chat { border-top: .5px solid var(--line); background: var(--pane-2); display: flex; flex-direction: column; max-height: 48%; min-height: 200px; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 12px 0 10px; font-size: 12.5px; }
.chat-toggle { display: flex; align-items: center; gap: 6px; padding: 0 6px; background: transparent; box-shadow: none; font-weight: 650; }
.chat-toggle:hover:not(:disabled) { background: var(--line); }
.chat-toggle svg { transition: transform .15s ease; }
.chat-count:not(:empty) { padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10.5px; line-height: 16px; }
.chat.collapsed { min-height: 0; max-height: none; padding-bottom: 6px; }
.chat.collapsed .chat-toggle svg { transform: rotate(-90deg); }
.chat.collapsed .chat-thread, .chat.collapsed .quick, .chat.collapsed .chat-form, .chat.collapsed .chat-tools { display: none; }
.chat-thread { flex: 1; min-height: 60px; overflow: auto; padding: 8px 16px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 88%; padding: 7px 11px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.bubble.assistant { align-self: flex-start; background: var(--control); box-shadow: inset 0 0 0 .5px var(--line); border-bottom-left-radius: 5px; }
.bubble.pending { color: var(--muted); font-style: italic; }
.quick { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 16px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 8px 16px 12px; }
.chat-form textarea { min-height: 38px; border-radius: 10px; }

/* ─── Dialogs (sheets) ──────────────────────────────────────────────────── */
dialog {
  width: min(760px, calc(100% - 24px)); max-height: 90vh; padding: 0; border: 0; border-radius: 12px;
  background: var(--pane); color: var(--ink); box-shadow: var(--shadow-float);
}
dialog::backdrop { background: rgba(0, 0, 0, .28); }
button.primary.destructive { background: #ff3b30; }

/* Alert sheet (replaces confirm()) */
dialog.alert { width: min(300px, calc(100% - 32px)); padding: 20px 16px 16px; text-align: center; border-radius: 14px; overflow: hidden; }
.alert-icon { display: grid; place-items: center; margin-bottom: 8px; color: #ff9500; }
dialog.alert h2 { font-size: 14px; }
dialog.alert p { margin: 6px 0 16px; font-size: 12px; overflow-wrap: anywhere; }
.alert-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dlg-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: var(--pane); border-bottom: .5px solid var(--line); }
.dlg-body { padding: 14px 16px; }
.dlg-foot { position: sticky; bottom: 0; display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px; background: var(--pane); border-top: .5px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: grid; gap: 4px; font-weight: 500; font-size: 12.5px; }
label.field small { font-weight: 400; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
label.check input { width: auto; accent-color: var(--accent); }
fieldset { border: 0; border-radius: 10px; padding: 12px; margin: 14px 0 0; background: var(--pane-2); box-shadow: inset 0 0 0 .5px var(--line); }
legend { float: left; width: 100%; padding: 0 0 8px; font-weight: 650; font-size: 12px; color: var(--muted); }
legend + * { clear: both; }
.script-desc { padding: 9px 11px; border-radius: 8px; background: var(--pane-2); color: var(--muted); font-size: 12.5px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.slot { display: flex; gap: 4px; align-items: center; }
.slot input { width: 112px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { display: flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--control); box-shadow: var(--shadow-control); cursor: pointer; }
.days input { width: auto; accent-color: var(--accent); }
.preview { margin-top: 10px; padding: 8px 11px; border-radius: 8px; background: var(--green-bg); color: var(--green); font-size: 12.5px; }
.preview.error { background: var(--red-bg); color: var(--red); }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.metric { padding: 10px 12px; border-radius: 10px; background: var(--pane-2); box-shadow: inset 0 0 0 .5px var(--line); }
.metric span { display: block; color: var(--muted); font-size: 11.5px; }
.metric strong { font-size: 19px; font-weight: 650; }
.secret-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 4px 14px; font-size: 12.5px; }

/* Toasts */
.toasts { position: fixed; right: 16px; top: 16px; z-index: 200; display: grid; gap: 8px; }
.toast {
  min-width: 240px; max-width: 360px; padding: 10px 14px; border-radius: 12px;
  background: var(--sidebar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-float); border-left: 3px solid var(--accent);
}
.toast.success { border-left-color: var(--green-fill); }
.toast.error { border-left-color: #ff3b30; }

/* Login */
.login { max-width: 380px; margin: 18vh auto; padding: 24px; background: var(--pane); border-radius: 14px; box-shadow: var(--shadow-float); }
.login form { display: grid; gap: 10px; margin-top: 14px; }

/* ─── Responsive ────────────────────────────────────────────────────────── */
/* iPad / narrow desktop: sidebar + one pane; a floating segmented control switches Chi tiết ↔ Log & AI. */
@media (max-width: 1279px) and (min-width: 768px) {
  .app { grid-template-columns: minmax(290px, .8fr) minmax(0, 1.2fr); }
  #panelDetail:not(.active-right), #panelLog:not(.active-right) { display: none; }
  #panelDetail.active-right, #panelLog.active-right { padding-bottom: 56px; }
  .mobile-tabs {
    display: flex; position: fixed; right: 16px; bottom: 14px; z-index: 30; gap: 0; padding: 2px; border-radius: 9px;
    background: var(--sidebar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); box-shadow: var(--shadow-float);
  }
  .mobile-tabs [data-panel="panelList"] { display: none; }
  .mobile-tabs button { min-height: 30px; padding: 0 16px; background: transparent; box-shadow: none; border-radius: 7px; }
  .mobile-tabs button.active-right { background: var(--control); box-shadow: var(--shadow-control); }
}
/* Phone: one pane at a time with an iOS-style tab bar. */
@media (max-width: 767px) {
  .app { grid-template-columns: 1fr; padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  .panel + .panel { border-left: 0; }
  .panel:not(.active-mobile) { display: none; }
  .mobile-tabs {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    background: var(--sidebar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-top: .5px solid var(--line-strong);
  }
  .mobile-tabs button { flex: 1; min-height: 46px; background: transparent; box-shadow: none; color: var(--muted); font-size: 12px; }
  .mobile-tabs button.active { color: var(--accent); font-weight: 650; }
  .form-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .kv { grid-template-columns: 100px 1fr; }
  .toasts { left: 12px; right: 12px; top: 12px; }
  .toast { max-width: none; }
  .group-tools { opacity: 1; }
  dialog:not(.alert) { width: 100%; max-width: 100%; max-height: 94dvh; margin: auto auto 0; border-radius: 14px 14px 0 0; }
}
@media (hover: none) { .group-tools { opacity: 1; } .grip { opacity: .7; } .item:not(.selected) .play:not(:disabled) { opacity: 0; pointer-events: none; } }
/* Bigger hit areas without changing the layout: ~44pt touch targets on touch screens. */
.grip, .item-side .play, .switch, .group-tools button, .group-head .disclosure { position: relative; }
.grip::before { content: ""; position: absolute; inset: -6px -6px; }
@media (pointer: coarse) {
  .grip { width: 22px; }
  .grip::before { inset: -12px -10px; }
  .item-side .play::before, .switch::before, .group-tools button::before, .group-head .disclosure::before { content: ""; position: absolute; inset: -10px -6px; }
  .item-side { gap: 14px; }
}
