/* ForceLab — Apple macOS 26 (Liquid Glass) + Apple HIG Design System
 * Follows dickwu/apple-design-skill:
 * - Two-layer architecture: opaque neutral content surfaces vs floating Liquid Glass chrome.
 * - Automatic Light & Dark system appearance (prefers-color-scheme).
 * - Restraint in accent color (Apple System Blue/Teal reserved for primary action & active state).
 * - Floating rounded sidebars, segmented control, capsule toolbar, scroll-under glass composer.
 */
:root {
  /* Dark Appearance (Apple macOS Neutral Dark) */
  --bg-canvas: #000000;
  --bg-ambient-1: rgba(56, 189, 248, 0.11);
  --bg-ambient-2: rgba(45, 212, 191, 0.09);

  /* Content Layer (Opaque, elevated neutral grays — zero glass) */
  --surface-primary: #161618;
  --surface-secondary: #1e1e21;
  --surface-inset: #111113;

  /* Functional Layer (Regular Liquid Glass) */
  --glass-bg: rgba(30, 30, 34, 0.68);
  --glass-bg-capsule: rgba(34, 34, 38, 0.74);
  --glass-border: rgba(255, 255, 255, 0.13);
  --glass-specular: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 14px 40px rgba(0, 0, 0, 0.42);

  /* Controls & Separators */
  --separator: rgba(255, 255, 255, 0.09);
  --fill-control: rgba(255, 255, 255, 0.07);
  --fill-control-hover: rgba(255, 255, 255, 0.13);
  --seg-track: rgba(255, 255, 255, 0.08);
  --seg-thumb: rgba(255, 255, 255, 0.18);

  /* Accent (Apple System Blue-Teal) */
  --accent: #0a84ff;
  --accent-text: #409cff;
  --accent-fill: rgba(10, 132, 255, 0.18);
  --accent-border: rgba(64, 156, 255, 0.42);
  --on-accent: #ffffff;

  /* Labels (WCAG AA >= 4.5:1) */
  --label-primary: #f5f5f7;
  --label-secondary: #a1a1a6;
  --label-tertiary: #86868b;

  /* Semantic Status */
  --status-ok: #30d158;
  --status-warn: #ffd60a;
  --status-danger: #ff453a;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-canvas: #f5f5f7;
    --bg-ambient-1: rgba(0, 122, 255, 0.07);
    --bg-ambient-2: rgba(52, 199, 89, 0.06);

    --surface-primary: #ffffff;
    --surface-secondary: #f2f2f7;
    --surface-inset: #f7f7fa;

    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-bg-capsule: rgba(255, 255, 255, 0.78);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-specular: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 10px 30px rgba(0, 0, 0, 0.08);

    --separator: rgba(0, 0, 0, 0.08);
    --fill-control: rgba(0, 0, 0, 0.045);
    --fill-control-hover: rgba(0, 0, 0, 0.085);
    --seg-track: rgba(0, 0, 0, 0.06);
    --seg-thumb: #ffffff;

    --accent: #007aff;
    --accent-text: #007aff;
    --accent-fill: rgba(0, 122, 255, 0.12);
    --accent-border: rgba(0, 122, 255, 0.32);
    --on-accent: #ffffff;

    --label-primary: #1d1d1f;
    --label-secondary: #6e6e73;
    --label-tertiary: #86868b;

    --status-ok: #248a3d;
    --status-warn: #b25000;
    --status-danger: #d70015;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background:
    radial-gradient(900px 520px at 18% 8%, var(--bg-ambient-1), transparent 65%),
    radial-gradient(800px 520px at 85% 90%, var(--bg-ambient-2), transparent 65%),
    var(--bg-canvas);
  color: var(--label-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Liquid Glass Shared Material */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-specular);
}
.glass-capsule {
  background: var(--glass-bg-capsule);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-specular);
}

/* Full-Bleed Split Layout with Floating Sidebars */
.app {
  display: flex;
  height: 100vh;
  padding: 12px;
  gap: 12px;
}

/* Left Floating Sidebar */
.sidebar-left {
  width: 236px;
  flex-shrink: 0;
  border-radius: 20px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 4px 10px;
  border-bottom: 1px solid var(--separator);
}
.brand-icon {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(145deg, #329eff, #007aff);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 3px 10px rgba(0, 122, 255, 0.35);
  flex-shrink: 0;
}
.brand-text { flex: 1; min-width: 0; }
.brand-title { font-size: 14.5px; font-weight: 600; letter-spacing: -0.015em; }
.brand-sub { font-size: 11px; color: var(--label-secondary); }
.sidebar-section-label {
  font-size: 11px; font-weight: 600; color: var(--label-tertiary);
  padding: 0 8px; letter-spacing: 0.03em; text-transform: uppercase;
}
.ws-list { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; }
.ws-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 8px 10px; border-radius: 11px;
  cursor: pointer; transition: background 0.15s ease;
}
.ws-item:hover { background: var(--fill-control); }
.ws-item.active { background: var(--accent-fill); }
.ws-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--label-tertiary); opacity: 0.5;
}
.ws-item.active .ws-dot { background: var(--accent); opacity: 1; }
.ws-meta { min-width: 0; flex: 1; }
.ws-name {
  font-size: 13px; font-weight: 500; color: var(--label-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ws-item.active .ws-name { color: var(--accent-text); font-weight: 600; }
.ws-id { font-size: 11px; color: var(--label-tertiary); margin-top: 1px; font-family: var(--font-mono); }
.ws-action-btn {
  opacity: 0; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 6px;
  border: none; background: transparent;
  color: var(--label-tertiary); cursor: pointer;
  display: grid; place-items: center;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.ws-item:hover .ws-action-btn, .ws-action-btn:focus-visible { opacity: 1; }
.ws-action-btn:hover { background: var(--fill-control-hover); color: var(--label-primary); }

.archived-section {
  border-top: 1px solid var(--separator);
  padding-top: 8px;
  margin-top: 6px;
}
.archived-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  height: 28px; padding: 0 8px; border-radius: 8px;
  border: none; background: transparent; cursor: pointer;
  color: var(--label-tertiary); font-size: 12px; font-weight: 500;
}
.archived-toggle:hover { background: var(--fill-control); color: var(--label-secondary); }
.archived-list { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; max-height: 180px; overflow-y: auto; }
.archived-row {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 5px 8px; border-radius: 7px; font-size: 12px; color: var(--label-secondary);
}
.archived-row:hover { background: var(--fill-control); }
.archived-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.restore-btn {
  flex-shrink: 0; height: 22px; padding: 0 8px; border-radius: 999px;
  border: none; background: var(--accent-fill); color: var(--accent-text);
  font-size: 11px; font-weight: 500; cursor: pointer;
}
.restore-btn:hover { filter: brightness(1.08); }

/* Center Full-Height Stage */
.center {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
}

/* Floating Top Capsule Toolbar */
.floating-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  padding: 0 16px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.breadcrumb-ws {
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ws-badge {
  padding: 2px 8px; border-radius: 999px;
  background: var(--fill-control); color: var(--label-secondary);
  font-size: 11px; font-family: var(--font-mono); flex-shrink: 0;
}

/* Apple Segmented Control */
.segmented-control {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--seg-track);
  gap: 2px;
}
.seg-btn {
  height: 26px; padding: 0 13px; border-radius: 999px;
  border: none; background: transparent;
  color: var(--label-secondary); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.16s ease;
}
.seg-btn:hover { color: var(--label-primary); }
.seg-btn.active {
  background: var(--seg-thumb);
  color: var(--label-primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.toolbar-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px; border-radius: 999px;
  background: var(--fill-control); border: none;
  color: var(--label-primary); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: background 0.15s ease;
}
.toolbar-btn:hover { background: var(--fill-control-hover); }
.toolbar-btn.active { background: var(--accent-fill); color: var(--accent-text); }
.count-pill { font-size: 11px; font-family: var(--font-mono); opacity: 0.85; }

/* Scrollable Chat Canvas — extends behind floating header & composer */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 72px 24px 168px;
}
.chat-panes-host {
  width: 100%; max-width: 760px; margin: 0 auto;
  min-height: 100%; display: flex; flex-direction: column;
}
.ws-chat-pane { display: none; flex-direction: column; gap: 16px; flex: 1; }
.ws-chat-pane.active { display: flex; }

/* Hero (Apple Intelligence centered aesthetic) */
.hero {
  margin: auto 0;
  padding: 36px 0;
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.hero-icon {
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(145deg, #329eff, #007aff);
  color: #fff; display: grid; place-items: center;
  margin-bottom: 18px;
  box-shadow: 0 10px 28px rgba(0, 122, 255, 0.32);
}
.hero-kicker {
  font-size: 11px; letter-spacing: 0.12em; font-weight: 600;
  color: var(--accent-text); margin-bottom: 8px;
}
.hero-title {
  font-size: 32px; font-weight: 700; letter-spacing: -0.028em;
  color: var(--label-primary); margin-bottom: 10px;
}
.hero-sub {
  font-size: 14.5px; color: var(--label-secondary); line-height: 1.6;
  max-width: 480px;
}

/* Opaque Content Cards */
.msg-user {
  align-self: flex-end; max-width: 80%;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 18px 18px 4px 18px;
  padding: 11px 16px; line-height: 1.6; white-space: pre-wrap;
  font-size: 13.5px;
  box-shadow: 0 4px 16px rgba(0, 122, 255, 0.22);
}
.msg-user-label { font-size: 10.5px; opacity: 0.78; margin-bottom: 3px; font-weight: 600; }

.msg-assistant {
  align-self: flex-start; width: 100%;
  background: var(--surface-primary);
  border: 1px solid var(--separator);
  border-radius: 18px;
  padding: 16px 20px;
}
.msg-assistant-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; font-size: 12px; color: var(--label-secondary); font-weight: 600;
}
.msg-assistant-meta { font-size: 11px; color: var(--label-tertiary); font-family: var(--font-mono); font-weight: 400; }
.msg-assistant-body { line-height: 1.7; font-size: 14px; color: var(--label-primary); }
.msg-assistant-body p { margin: 6px 0; }
.msg-assistant-body ul, .msg-assistant-body ol { padding-left: 20px; margin: 6px 0; }
.msg-assistant-body code { background: var(--surface-secondary); padding: 1px 6px; border-radius: 5px; font-family: var(--font-mono); font-size: 12px; color: var(--accent-text); }

/* 5-Stage Pipeline Card */
.pipeline-card {
  background: var(--surface-primary);
  border: 1px solid var(--separator);
  border-radius: 20px;
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.pipeline-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pipeline-title { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.pipeline-meta { font-size: 11px; color: var(--label-tertiary); font-family: var(--font-mono); }
.text-btn {
  background: var(--fill-control); border: none; color: var(--label-secondary);
  font-size: 11.5px; cursor: pointer; height: 26px; padding: 0 10px; border-radius: 999px;
}
.text-btn:hover { color: var(--label-primary); background: var(--fill-control-hover); }

.stepper { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.step-pill {
  padding: 7px 9px; border-radius: 10px;
  background: var(--surface-secondary);
  font-size: 11.5px; color: var(--label-secondary);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.step-pill.running { background: var(--accent-fill); color: var(--accent-text); font-weight: 600; }
.step-pill.done { color: var(--label-primary); }
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--label-tertiary); flex-shrink: 0; }
.step-pill.running .step-dot { background: var(--accent); animation: pulse 1.1s infinite; }
.step-pill.done .step-dot { background: var(--status-ok); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Accordion Stages */
details.stage-box {
  background: var(--surface-inset);
  border: 1px solid var(--separator);
  border-radius: 13px; overflow: hidden;
}
details.stage-box.running { border-color: var(--accent-border); }
details.stage-box summary {
  min-height: 42px; padding: 9px 14px; cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 13px; font-weight: 600; color: var(--label-primary);
}
details.stage-box summary::-webkit-details-marker { display: none; }
.stage-summary-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; overflow: hidden; }
.stage-chevron { display: inline-block; font-size: 11px; color: var(--label-tertiary); transition: transform 0.15s ease; flex-shrink: 0; }
details.stage-box[open] > summary .stage-chevron { transform: rotate(90deg); }
.stage-label { white-space: nowrap; flex-shrink: 0; }
.stage-preview { flex: 1; min-width: 0; font-size: 12px; font-weight: 400; color: var(--label-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-summary-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.stage-duration { font-size: 11px; color: var(--label-tertiary); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
details.stage-box summary .stage-tag { font-size: 11.5px; color: var(--status-ok); font-weight: 500; }
details.stage-box.running summary .stage-tag { color: var(--accent-text); }

.stage-body { padding: 0 14px 14px; border-top: 1px solid var(--separator); font-size: 13px; line-height: 1.65; color: var(--label-primary); }
.stage-body h4 { font-size: 11.5px; color: var(--accent-text); margin: 12px 0 4px; font-weight: 600; }
.stage-body ul { padding-left: 18px; }
.stage-body li { margin: 3px 0; }

.activity-log {
  margin-top: 10px; padding: 8px 11px;
  background: var(--surface-primary); border-radius: 10px;
  display: flex; flex-direction: column; gap: 5px;
}
.log-row { display: flex; align-items: flex-start; gap: 7px; font-size: 12px; color: var(--label-secondary); line-height: 1.5; }
.log-icon { flex-shrink: 0; width: 14px; text-align: center; color: var(--accent-text); }

.stream-box { margin-top: 8px; background: var(--surface-primary); border: 1px solid var(--separator); border-radius: 10px; overflow: hidden; }
.stream-head {
  padding: 6px 10px; font-size: 11px; color: var(--label-secondary); font-family: var(--font-mono);
  border-bottom: 1px solid var(--separator); display: flex; align-items: center; justify-content: space-between;
}
.stream-toggle-raw {
  background: var(--fill-control); border: none; border-radius: 999px;
  color: var(--label-secondary); font-size: 10.5px; padding: 2px 8px; cursor: pointer;
}
.stream-toggle-raw:hover { color: var(--label-primary); }
.stream-readable { padding: 10px 12px; max-height: 220px; overflow-y: auto; font-size: 12.5px; line-height: 1.6; display: flex; flex-direction: column; gap: 6px; }
.stream-field { display: flex; flex-direction: column; gap: 2px; }
.stream-field-label { font-size: 11px; font-weight: 600; color: var(--accent-text); }
.stream-field-val { color: var(--label-primary); white-space: pre-wrap; word-break: break-word; }
.stream-cursor { display: inline-block; width: 6px; height: 12px; margin-left: 3px; background: var(--accent); vertical-align: -1px; animation: pulse 0.9s infinite; }
.stream-pre { display: none; padding: 8px 10px; max-height: 180px; overflow-y: auto; font-family: var(--font-mono); font-size: 11.5px; color: var(--label-secondary); white-space: pre-wrap; }
.stage-result { margin-top: 8px; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; margin-top: 8px; }
.kv-item { background: var(--surface-primary); border: 1px solid var(--separator); border-radius: 10px; padding: 9px 11px; }
.kv-k { font-size: 11px; color: var(--label-secondary); font-family: var(--font-mono); }
.kv-v { font-size: 14px; font-weight: 600; color: var(--accent-text); margin-top: 2px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* HITL Confirmation */
.hitl-box { background: var(--accent-fill); border: 1px solid var(--accent-border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.hitl-title { font-size: 13px; font-weight: 600; color: var(--accent-text); }
.hitl-input { width: 100%; min-height: 54px; resize: vertical; background: var(--surface-primary); border: 1px solid var(--separator); border-radius: 10px; padding: 8px 10px; color: var(--label-primary); font-family: var(--font-sans); font-size: 13px; }
.hitl-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn-accent { background: var(--accent); color: var(--on-accent); border: none; height: 32px; padding: 0 15px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.btn-accent:hover { filter: brightness(1.08); }
.btn-accent:disabled { opacity: 0.45; cursor: not-allowed; }

/* Final Report */
.report-md { background: var(--surface-inset); border: 1px solid var(--separator); border-radius: 14px; padding: 18px 20px; line-height: 1.72; font-size: 13.5px; color: var(--label-primary); }
.report-md h1 { font-size: 18px; margin-bottom: 10px; letter-spacing: -0.015em; }
.report-md h2 { font-size: 14.5px; color: var(--accent-text); margin: 16px 0 8px; border-bottom: 1px solid var(--separator); padding-bottom: 4px; }
.report-md h3 { font-size: 13.5px; margin: 12px 0 6px; }
.report-md p { margin: 6px 0; }
.report-md ul, .report-md ol { padding-left: 20px; margin: 6px 0; }
.report-md code { background: var(--surface-secondary); padding: 1px 6px; border-radius: 5px; font-family: var(--font-mono); font-size: 12px; color: var(--accent-text); }
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 12px 0;
  border: 1px solid var(--separator);
  border-radius: 10px;
}
.report-md table, .msg-assistant-body table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.report-md th, .report-md td, .msg-assistant-body th, .msg-assistant-body td {
  border-bottom: 1px solid var(--separator);
  border-right: 1px solid var(--separator);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.report-md th:last-child, .report-md td:last-child,
.msg-assistant-body th:last-child, .msg-assistant-body td:last-child {
  border-right: none;
}
.report-md tr:last-child td, .msg-assistant-body tr:last-child td {
  border-bottom: none;
}
.report-md th, .msg-assistant-body th {
  background: var(--surface-secondary);
  font-weight: 600;
  white-space: nowrap;
}
.report-md td, .msg-assistant-body td {
  min-width: 84px;
  max-width: 300px;
  word-break: break-word;
}
.report-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--separator); font-size: 12px; color: var(--label-secondary); flex-wrap: wrap; }

/* Floating Liquid Glass Composer Dock */
.composer-dock {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 14px 2px;
  pointer-events: none;
  z-index: 20;
}
.composer-glass {
  max-width: 760px;
  margin: 0 auto;
  border-radius: 22px;
  padding: 12px 14px 10px;
  pointer-events: auto;
}
.quick-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.chips, .mode-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip, .control-pill {
  height: 27px; padding: 0 11px; border-radius: 999px;
  background: var(--fill-control); border: none;
  color: var(--label-primary); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: background 0.14s ease;
}
.chip:hover, .control-pill:hover { background: var(--fill-control-hover); }
.control-pill { color: var(--label-secondary); }
.control-pill.on { background: var(--accent-fill); color: var(--accent-text); }

.input-box {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface-primary);
  border: 1px solid var(--separator);
  border-radius: 16px;
  padding: 8px 8px 8px 14px;
}
.input-box:focus-within { border-color: var(--accent-border); }
.input-box textarea {
  flex: 1; background: transparent; border: none; outline: none; resize: none;
  color: var(--label-primary); font-family: var(--font-sans); font-size: 13.5px;
  line-height: 1.5; max-height: 120px; min-height: 22px;
}
.input-box textarea::placeholder { color: var(--label-tertiary); }
.send-btn {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); border: none;
  color: var(--on-accent); cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(0, 122, 255, 0.35);
  transition: transform 0.12s ease, filter 0.15s ease;
}
.send-btn:hover { filter: brightness(1.08); transform: scale(1.03); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.status-line { margin-top: 6px; padding: 0 4px; font-size: 11px; color: var(--label-tertiary); display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Right Floating Liquid Glass Inspector (Assets) */
.sidebar-right {
  width: 296px;
  flex-shrink: 0;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, opacity 0.2s ease, margin 0.2s ease;
  z-index: 10;
}
.sidebar-right.collapsed { width: 0; opacity: 0; border-width: 0; margin-left: -12px; pointer-events: none; }
.assets-header {
  height: 50px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; border-bottom: 1px solid var(--separator); flex-shrink: 0;
}
.assets-title { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.assets-title span { font-size: 11.5px; color: var(--label-tertiary); font-family: var(--font-mono); font-weight: 400; }
.assets-head-actions { display: flex; align-items: center; gap: 3px; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 8px;
  background: transparent; border: none;
  color: var(--label-secondary); cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--fill-control); color: var(--label-primary); }

.assets-body { padding: 12px; overflow-y: auto; flex: 1; transition: background 0.15s ease; }
.assets-body.drag-over { background: var(--accent-fill); }
.drop-hint {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px 10px; margin-bottom: 6px;
  border-bottom: 1px solid var(--separator);
  font-size: 11.5px; color: var(--label-tertiary);
}
.drop-hint span:first-child { font-family: var(--font-mono); color: var(--label-secondary); font-weight: 600; }
.folder-group { margin-bottom: 4px; }
.folder-row {
  display: flex; align-items: center; justify-content: space-between;
  height: 30px; padding: 0 8px; border-radius: 8px; cursor: pointer;
  color: var(--label-primary); font-size: 12.5px; font-weight: 500;
}
.folder-row:hover { background: var(--fill-control); }
.folder-left { display: flex; align-items: center; gap: 6px; }
.folder-count { font-size: 11px; color: var(--label-tertiary); font-family: var(--font-mono); }
.folder-files { padding-left: 16px; display: flex; flex-direction: column; gap: 1px; margin-bottom: 4px; }
.folder-files.closed { display: none; }
.file-row {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  height: 28px; padding: 0 6px 0 8px; border-radius: 7px;
  cursor: pointer; color: var(--label-secondary); font-size: 12px;
}
.file-row:hover { background: var(--fill-control); color: var(--label-primary); }
.file-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-row-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
}
.file-del-btn {
  opacity: 0; flex-shrink: 0;
  width: 20px; height: 20px; border-radius: 5px;
  border: none; background: transparent;
  color: var(--label-tertiary); cursor: pointer;
  display: grid; place-items: center;
  transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.file-row:hover .file-del-btn, .file-del-btn:focus-visible { opacity: 1; }
.file-del-btn:hover { color: var(--label-primary); background: var(--fill-control-hover); }
.file-del-btn.danger:hover { color: var(--status-danger); background: rgba(255, 69, 58, 0.12); }

.btn-danger {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px;
  border-radius: 999px; background: rgba(255, 69, 58, 0.12); border: none;
  color: var(--status-danger); font-size: 12.5px; font-weight: 500; cursor: pointer;
  margin-right: auto;
}
.btn-danger:hover { background: rgba(255, 69, 58, 0.2); }

/* Apple Sheet Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 680px; max-height: 84vh; border-radius: 22px; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { padding: 15px 20px; border-bottom: 1px solid var(--separator); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 14px; font-weight: 600; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.modal-body pre { background: var(--surface-inset); border: 1px solid var(--separator); border-radius: 12px; padding: 14px; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; white-space: pre-wrap; color: var(--label-primary); }
.modal-body input, .modal-body select, .modal-body textarea { width: 100%; background: var(--surface-inset); border: 1px solid var(--separator); border-radius: 10px; padding: 9px 12px; color: var(--label-primary); font-family: var(--font-sans); font-size: 13px; }
.modal-body textarea { min-height: 200px; font-family: var(--font-mono); }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--separator); display: flex; justify-content: flex-end; gap: 8px; }
.pill-btn { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 999px; background: var(--fill-control); border: none; color: var(--label-primary); font-size: 12.5px; cursor: pointer; }
.pill-btn:hover { background: var(--fill-control-hover); }

/* Accessibility States (Apple HIG) */
@media (prefers-reduced-transparency: reduce) {
  .glass-panel, .glass-capsule { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface-primary); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
