/* Editorial Warm Paper (Day) & Warm Slate Studio (Night)
 * Dials: ENERGY 2 / RHYTHM 2 / MOTION 1
 * Palette: 2 core paper/ink surfaces + 1 forest-green accent (#1B5E4B / #34A885)
 * All text/background pairs verified >= 4.5:1 (AA) via contrast-check.py.
 */

:root {
  --stage-bg: #C8C9B8;
  --surface: #FAF7F2;
  --surface-overlay: rgba(250, 247, 242, 0.96);
  --surface-subtle: #F1EBE0;
  --surface-hover: #E7DFD1;
  --border: #DFD6C7;
  --border-strong: #786E62;

  --ink: #1C1815;
  --ink-muted: #585047;

  --accent: #1B5E4B;
  --accent-hover: #144839;
  --accent-ink: #FAF7F2;
  --accent-soft: #E5F0EC;

  --warn: #A15C07;
  --warn-soft: #FBF3E6;
  --danger: #B42318;
  --danger-ink: #FAF7F2;
  --danger-soft: #FCEAE8;

  --code-bg: #191D24;
  --code-ink: #EFEBE3;
  --code-muted: #B3ACA2;

  /* Elevation shadows reserved ONLY for the 3 floating layers over the 2.5D canvas */
  --shadow-float: 0 8px 26px rgba(28, 24, 21, 0.13), 0 1px 3px rgba(28, 24, 21, 0.08);
  --shadow-modal: 0 20px 56px rgba(28, 24, 21, 0.24), 0 2px 6px rgba(28, 24, 21, 0.10);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --font-sans: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", Consolas, ui-monospace, monospace;
}

body.night {
  --stage-bg: #1C2639;
  --surface: #151921;
  --surface-overlay: rgba(21, 25, 33, 0.96);
  --surface-subtle: #1D232E;
  --surface-hover: #252D3B;
  --border: #2D3646;
  --border-strong: #738094;

  --ink: #F2EEE7;
  --ink-muted: #A7A29A;

  --accent: #34A885;
  --accent-hover: #45BA96;
  --accent-ink: #0D1412;
  --accent-soft: #182D28;

  --warn: #F0B65E;
  --warn-soft: #302414;
  --danger: #F48A82;
  --danger-ink: #151921;
  --danger-soft: #341B1C;

  --code-bg: #10141A;
  --code-ink: #EFEBE3;
  --code-muted: #B3ACA2;

  --shadow-float: 0 10px 28px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.28);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.62), 0 2px 8px rgba(0, 0, 0, 0.36);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--stage-bg);
  -webkit-font-smoothing: antialiased;
}

/* Base-layer interaction affordances (R-32, R-39) */
a[href],
button,
summary,
select,
label[for],
input[type="checkbox"],
input[type="radio"],
[role="button"],
[role="tab"] {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.52;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==================== STAGE & CANVAS ==================== */
.stage {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--stage-bg);
  transition: width 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

body.night .stage {
  background: var(--stage-bg);
}

#officeCanvas {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  touch-action: none;
}

.stage-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 15;
  pointer-events: none;
  background: var(--ink);
  color: var(--surface);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.82rem;
  max-width: 260px;
}
.stage-tooltip strong { font-weight: 700; }
.stage-tooltip span { opacity: 0.88; font-size: 0.76rem; }

/* ==================== FLOATING HUD (LAYER 1) ==================== */
.top-hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  z-index: 20;
}

.status-strip,
.utility-bar {
  pointer-events: auto;
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
}

.status-strip {
  padding: 5px 12px;
  gap: 10px;
  min-height: 44px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.conn-dot.warn { background: var(--warn); }
.conn-dot.err { background: var(--danger); }

.status-strip h1 {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.v-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex: none;
}

.status-pill-btn {
  border: 0;
  border-radius: var(--r-sm);
  padding: 5px 10px;
  min-height: 32px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface-subtle);
  color: var(--ink);
  white-space: nowrap;
  transition: background-color 120ms ease;
}
.status-pill-btn:hover { background: var(--surface-hover); }
.status-pill-btn:active { transform: translateY(1px); }
.status-pill-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.status-pill-btn.is-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.status-pill-btn.is-err {
  background: var(--danger-soft);
  color: var(--danger);
}

.pending-txt {
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pending-txt:empty {
  display: none;
}

.utility-bar {
  padding: 4px;
  gap: 2px;
}

.hud-btn {
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  padding: 7px 11px;
  min-height: 36px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease;
}
.hud-btn:hover { background: var(--surface-hover); }
.hud-btn:active { background: var(--border); }
.hud-btn[aria-pressed="true"] {
  background: var(--surface-subtle);
  color: var(--accent);
}
.hud-btn.accent {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.hud-btn.accent:hover {
  background: var(--accent);
  color: var(--accent-ink);
}
.help-btn {
  min-width: 36px;
  padding: 7px 10px;
  font-weight: 700;
}

/* ==================== MOBILE 1-TAP ROOM BAR ==================== */
.mobile-room-bar {
  display: none;
}
.dock-mobile-only {
  display: none;
}

/* ==================== COMMAND DOCK ==================== */
.command-dock {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
  padding: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 24px);
  overflow-x: auto;
  scrollbar-width: none;
}
.command-dock::-webkit-scrollbar {
  display: none;
}

.dock-primary {
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--r-sm);
  padding: 8px 15px;
  min-height: 38px;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  transition: background-color 120ms ease;
}
.dock-primary:hover { background: var(--accent-hover); }
.dock-primary:active { transform: translateY(1px); }

.kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
}
body.night .dock-primary .kbd {
  background: rgba(13, 18, 20, 0.14);
  border-color: rgba(13, 18, 20, 0.28);
}

/* ==================== BANNERS ==================== */
.banner-stack {
  position: absolute;
  top: calc(max(14px, env(safe-area-inset-top)) + 56px);
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(540px, calc(100vw - 32px));
  pointer-events: none;
}

.error-banner,
.offline-banner {
  pointer-events: auto;
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 10px 14px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.84rem;
  box-shadow: var(--shadow-float);
}
.error-banner { border: 1.5px solid var(--danger); color: var(--ink); }
.offline-banner { border: 1px solid var(--warn); color: var(--ink); }
.error-banner.show,
.offline-banner.show { display: flex; flex-wrap: wrap; }

/* ==================== DRAWER (LAYER 2) ==================== */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.32);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.drawer-scrim.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: min(450px, calc(100vw - 28px));
  z-index: 35;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 28px));
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.drawer-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 12px;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}

.section-block {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.section-block:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.sub-heading {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

/* ==================== EXECUTIVE DAILY BRIEF & TASK CONTROLS ==================== */
.daily-brief-card {
  margin-bottom: 16px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}
.daily-brief-card.has-alert {
  border-left: 3px solid var(--warn);
}
.daily-brief-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.daily-brief-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}
.daily-brief-date {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--ink-muted);
}
.daily-upgrade-pill {
  padding: 4px 10px;
  min-height: 32px;
  font-size: 0.78rem;
  background: var(--surface);
  border-color: var(--border);
  max-width: 100%;
  white-space: normal;
  text-align: left;
}
.daily-upgrade-pill.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.daily-brief-lead {
  margin: 0 0 10px;
  font-size: 0.84rem;
  line-height: 1.48;
  color: var(--ink);
}
.daily-brief-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 12px;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.daily-stat-item {
  min-width: 0;
}
.daily-stat-item dt {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--ink-muted);
  line-height: 1.3;
  overflow-wrap: break-word;
}
.daily-stat-item dd {
  margin: 2px 0 0;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.daily-stat-item dd.ok { color: var(--accent); }
.daily-stat-item dd.live { color: var(--warn); }
.daily-stat-item dd.warn { color: var(--danger); }

.daily-recent-upgrades {
  margin-bottom: 12px;
}
.daily-upgrades-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.daily-upgrades-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.daily-upgrade-row {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  text-align: left;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.daily-upgrade-row:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.daily-upgrade-row:active {
  transform: translateY(1px);
}
.daily-upgrade-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.daily-brief-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==================== BUTTONS & TABS ==================== */
.task-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.task-search-wrap input {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.86rem;
}
.task-search-wrap input:focus {
  border-color: var(--accent);
}
.missions-more-row {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.quick-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.mini-tab {
  border: 1px solid transparent;
  background: var(--surface-subtle);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  min-height: 36px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-muted);
  transition: background-color 120ms ease, color 120ms ease;
}
.mini-tab:hover {
  background: var(--surface-hover);
  color: var(--ink);
}
.mini-tab:active { transform: translateY(1px); }
.mini-tab[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.mini-tab.danger-tab {
  color: var(--danger);
  background: var(--danger-soft);
}
.mini-tab.danger-tab:hover {
  background: var(--danger);
  color: var(--danger-ink);
}

.btn-line {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--ink);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  min-height: 36px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.btn-line:hover { background: var(--surface-subtle); }
.btn-line:active { background: var(--surface-hover); transform: translateY(1px); }

.btn-line.primary-line {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn-line.primary-line:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-line.danger-line {
  color: var(--danger);
  border-color: var(--danger);
}
.btn-line.danger-line:hover {
  background: var(--danger-soft);
}

.btn-primary {
  width: 100%;
  border: 0;
  border-radius: var(--r-sm);
  padding: 11px 16px;
  min-height: 44px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.9rem;
  transition: background-color 120ms ease;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }

/* ==================== LISTS, FORMS & STATES ==================== */
.row-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.row-item:first-child { padding-top: 2px; }
.row-item:last-child { border-bottom: 0; padding-bottom: 0; }

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

.row-meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.row-title {
  font-weight: 600;
  font-size: 0.94rem;
  margin-bottom: 6px;
  color: var(--ink);
}

.status-txt {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--ink-muted);
  white-space: nowrap;
}
.status-txt.ok { color: var(--accent); }
.status-txt.live { color: var(--warn); }
.status-txt.warn { color: var(--danger); }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.mission-step-list {
  margin: 8px 0 4px;
  padding: 10px 12px;
  background: var(--surface-subtle);
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mission-step-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.81rem;
}
.mission-step-list .status-txt.live {
  background: var(--warn-soft);
  padding: 1px 6px;
  border-radius: 4px;
}

.state-panel {
  padding: 16px;
  background: var(--surface-subtle);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.state-panel strong { font-size: 0.9rem; color: var(--ink); }
.state-panel p { margin: 0; font-size: 0.84rem; color: var(--ink-muted); }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 5px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 9px 12px;
  min-height: 42px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
}
.field textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.55;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.muted-note {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin: 0;
}
.empty-line {
  font-size: 0.86rem;
  color: var(--ink-muted);
  margin: 4px 0;
}

/* ==================== SETTINGS CONTROLS ==================== */
.profile-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.profile-card {
  border: 1.5px solid var(--border);
  background: var(--surface-subtle);
  border-radius: var(--r-md);
  padding: 12px;
  text-align: left;
  transition: border-color 140ms ease, background-color 140ms ease;
}
.profile-card:hover { background: var(--surface-hover); }
.profile-card strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 4px;
  color: var(--ink);
}
.profile-card span {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.42;
}
.profile-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.profile-card.active strong { color: var(--accent); }

.matrix-row {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(218px, 1.18fr);
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.matrix-row:last-child { border-bottom: 0; }
.matrix-row label {
  font-size: 0.82rem;
  font-weight: 500;
  margin: 0;
  color: var(--ink);
}
.matrix-row select {
  padding: 7px 9px;
  min-height: 44px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.85rem;
}
@media (max-width: 760px) {
  .matrix-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .matrix-row select,
  #autoUpgradePanel select {
    min-height: 44px;
    width: 100%;
    font-size: 16px;
  }
}

.slot-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
}

/* ==================== MODALS (LAYER 3) ==================== */
@keyframes modalBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalCardIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.988);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalSheetIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.54);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.modal-backdrop.open {
  display: grid;
  animation: modalBackdropIn 140ms ease;
}
.modal-backdrop.open .modal {
  animation: modalCardIn 170ms cubic-bezier(0.22, 1, 0.36, 1);
}

.modal {
  width: min(580px, 100%);
  max-height: 88dvh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal.reader-modal {
  width: min(840px, 95vw);
  max-height: 90dvh;
  transition: width 180ms ease;
}
.modal.reader-modal.is-expanded {
  width: min(1240px, 96vw);
  max-height: 94dvh;
}
.modal.reader-modal.is-expanded .reader-column {
  max-width: 92ch;
}

.modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

#docModal .modal-head {
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.modal-body {
  flex: 1;
  padding: 22px 24px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ==================== DOCUMENT-FIRST RESULT READER ==================== */
.doc-view-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}
.doc-view-pill {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 6px 14px;
  min-height: 36px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}
.doc-view-pill[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(34, 29, 26, 0.12);
}

.reader-head-left {
  flex: 1 1 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reader-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.reader-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.reader-subtitle {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  margin-left: auto;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-subtle);
  color: var(--ink-muted);
  white-space: nowrap;
}
.status-badge.ok {
  background: var(--accent-soft);
  color: var(--accent);
}
.status-badge.live {
  background: var(--warn-soft);
  color: var(--warn);
}
.status-badge.warn {
  background: var(--danger-soft);
  color: var(--danger);
}

.reader-body {
  flex: 1;
  min-height: 160px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 12px;
  -webkit-overflow-scrolling: touch;
  padding: 24px 28px 28px;
}

.reader-column {
  max-width: 68ch;
  margin: 0 auto;
}

/* Live progress strip while mission is running */
.progress-strip {
  margin-bottom: 22px;
  padding: 14px 16px;
  background: var(--surface-subtle);
  border-radius: var(--r-md);
}
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.progress-track {
  width: 100%;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 260ms ease;
}
.progress-detail {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* Quick Decision Bar (Blocked A/B & Meeting Options) + Section Outline Bar */
.decision-bar {
  margin-bottom: 18px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.decision-bar.is-blocked {
  border-left-color: var(--warn);
}
.decision-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.decision-head strong {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}
.decision-hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
}
.decision-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.doc-outline-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 2px 0 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.outline-chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--ink);
  border-radius: var(--r-sm);
  padding: 5px 11px;
  min-height: 34px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.outline-chip:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

/* Editorial Markdown Prose (68ch, 15px, line-height 1.68) */
.md-view {
  font-size: 15px;
  line-height: 1.68;
  color: var(--ink);
  word-break: break-word;
}
.md-view > :first-child { margin-top: 0; }
.md-view > :last-child { margin-bottom: 0; }

.md-view h1 {
  font-size: 1.32rem;
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: -0.015em;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.md-view h2 {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.38;
  margin: 26px 0 10px;
  color: var(--ink);
  scroll-margin-top: 16px;
}
.md-view h3 {
  font-size: 0.98rem;
  font-weight: 700;
  margin: 20px 0 8px;
}
.md-view p { margin: 0 0 14px; }
.md-view ul,
.md-view ol {
  margin: 0 0 14px;
  padding-left: 22px;
}
.md-view li { margin-bottom: 6px; }
.md-view li:last-child { margin-bottom: 0; }

.md-view hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 22px 0;
}

.md-view blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--surface-subtle);
  border-radius: var(--r-sm);
  color: var(--ink);
}

.md-view code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink);
}

.md-view kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8em;
  font-weight: 600;
  line-height: 1.25;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  box-shadow: inset 0 -1px 0 var(--border-strong);
  color: var(--ink);
  white-space: nowrap;
}
.md-view .kbd-combo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.md-view .kbd-sep {
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.md-view a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.md-view a:hover { color: var(--accent-hover); }

/* Clean editorial horizontal-rule table (smooth horizontal scroll on narrow mobile screens) */
.md-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 18px 0;
  padding-bottom: 4px;
}
.md-view table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  margin: 0;
  font-size: 0.9rem;
}
.md-view th,
.md-view td {
  border-bottom: 1px solid var(--border);
  padding: 10px 16px 10px 0;
  text-align: left;
  vertical-align: top;
  word-break: normal;
  overflow-wrap: break-word;
}
.md-view th {
  font-weight: 700;
  color: var(--ink);
  border-bottom: 1.5px solid var(--border-strong);
  white-space: nowrap;
  overflow-wrap: normal;
}
.md-view td {
  min-width: 88px;
}
@media (max-width: 720px) {
  .md-view table {
    min-width: 560px;
    font-size: 0.88rem;
  }
  .md-view th,
  .md-view td {
    padding: 9px 14px 9px 0;
  }
  .md-view td:last-child {
    min-width: 230px;
  }
}

.md-code-wrap {
  margin: 16px 0;
  max-width: 100%;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--code-bg);
  color: var(--code-ink);
}
.md-code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--code-muted);
}
.md-copy-btn {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: transparent;
  color: var(--code-ink);
  border-radius: 5px;
  padding: 4px 10px;
  min-height: 28px;
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 600;
}
.md-copy-btn:hover { background: rgba(255, 255, 255, 0.14); }
.md-code-wrap pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.58;
}
.md-code-wrap pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

/* Inline Live Visual Deliverable Showcase inside Reader */
.visual-showcase {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.visual-showcase-heading {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}
.visual-item {
  background: var(--surface-subtle);
  border-radius: var(--r-md);
  overflow: hidden;
}
.visual-item-bar {
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 10px;
}
.visual-item-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}
.visual-item-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.vp-switch {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}
.vp-btn {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  border-radius: 4px;
  padding: 5px 9px;
  min-height: 30px;
  font-size: 0.77rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease;
}
.vp-btn:hover { color: var(--ink); background: var(--surface-subtle); }
.vp-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.preview-stage {
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.preview-stage.is-mobile {
  padding: 14px;
  background: var(--surface-subtle);
  display: flex;
  justify-content: center;
}
.visual-iframe {
  display: block;
  width: 100%;
  height: 360px;
  border: 0;
  background: #ffffff;
}
.preview-stage.is-mobile .visual-iframe,
.preview-stage.is-mobile .preview-iframe {
  width: min(375px, 100%);
  height: 540px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-float);
}
.visual-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Follow-up 1-Tap Refinement Bar inside Reader */
.followup-bar {
  margin-top: 22px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
}
.followup-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 2px;
}
.followup-chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  min-height: 32px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.followup-chip:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.followup-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.followup-row input {
  flex: 1 1 200px;
  min-width: 0;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
}
.followup-row input:focus {
  border-color: var(--accent);
}
.followup-row button {
  flex: none;
  min-height: 42px;
}

/* Progressive Disclosure Appendix at Modal Footer */
.doc-appendix {
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}

.doc-appendix-summary {
  list-style: none;
  min-height: 44px;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-muted);
  user-select: none;
  transition: color 120ms ease, background-color 120ms ease;
}
.doc-appendix-summary::-webkit-details-marker { display: none; }
.doc-appendix-summary:hover {
  color: var(--ink);
  background: var(--surface-hover);
}
.doc-appendix-summary::after {
  content: "Mở rộng";
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.doc-appendix[open] .doc-appendix-summary::after {
  content: "Thu gọn";
}

.doc-appendix-body {
  padding: 4px 24px 22px;
  max-height: 44vh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.dept-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.dept-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 12px;
  background: var(--surface);
  border-radius: var(--r-sm);
  font-size: 0.84rem;
}
.dept-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.dept-row-title { font-weight: 600; color: var(--ink); }
.dept-row-sub { font-size: 0.78rem; color: var(--ink-muted); }

/* Quiet underline tabs inside Appendix */
.appendix-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.appendix-tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 8px 12px;
  min-height: 38px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: -1px;
}
.appendix-tab:hover { color: var(--ink); }
.appendix-tab[aria-pressed="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Source Files Explorer inside Appendix */
.files-layout {
  display: grid;
  grid-template-columns: minmax(190px, 240px) 1fr;
  gap: 14px;
  min-height: 240px;
}
.files-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 36vh;
  overflow-y: auto;
}
.file-row {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--ink);
  transition: background-color 120ms ease;
}
.file-row:hover { background: var(--surface-hover); }
.file-row.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
}
.file-name {
  font-size: 0.83rem;
  font-weight: 600;
  word-break: break-word;
}
.file-meta {
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.file-preview-box {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 14px;
  overflow: auto;
  max-height: 36vh;
}
.file-preview-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 600;
}
.preview-iframe {
  width: 100%;
  height: 260px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #ffffff;
}

.appendix-md-pane {
  background: var(--surface);
  border-radius: var(--r-md);
  min-height: 180px;
  padding: 16px;
}

/* ==================== TOAST ==================== */
.toast {
  position: fixed;
  right: 16px;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 68px);
  z-index: 60;
  background: var(--ink);
  color: var(--surface);
  padding: 11px 16px;
  border-radius: var(--r-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(440px, calc(100vw - 32px));
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast button {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  border-radius: 5px;
  padding: 5px 10px;
  min-height: 32px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.toast button:hover { opacity: 0.85; }

/* History Governance & Meeting Helper Controls */
.history-card {
  background: var(--surface-subtle);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.history-advice {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink);
  font-weight: 500;
}
.history-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.history-stat {
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-stat span {
  font-size: 0.76rem;
  color: var(--ink-muted);
}
.history-stat strong {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--ink);
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
  color: var(--ink);
  margin: 8px 0 12px;
}
.checkbox-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.action-row .btn-primary {
  width: auto;
  flex: 1 1 180px;
}

/* ==================== LOGIN GATEWAY & SECURITY CONTROLS ==================== */
html.login-root,
body.login-page {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

.skip-link {
  position: absolute;
  top: -56px;
  left: 16px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus {
  top: 12px;
}

.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(16px, 3.5vw, 32px) clamp(16px, 4vw, 40px) max(24px, env(safe-area-inset-bottom));
  gap: 24px;
}

.login-topbar {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px 8px 6px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.login-brand {
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.login-main {
  width: 100%;
  max-width: 820px;
  margin: auto;
}
.login-main:focus:not(:focus-visible) {
  outline: none;
}
.login-main:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.login-ledger {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  overflow: hidden;
}

.login-brief {
  min-width: 0;
  background: var(--surface-subtle);
  border-right: 1px solid var(--border);
  padding: clamp(20px, 3.5vw, 34px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
}

.login-brief h1 {
  margin: 0 0 10px;
  font-size: clamp(1.32rem, 2.3vw, 1.56rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.login-lead {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink-muted);
  max-width: 38ch;
}

.login-recovery {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-recovery strong {
  font-size: 0.84rem;
  color: var(--ink);
}
.login-recovery p {
  margin: 0;
  font-size: 0.81rem;
  line-height: 1.5;
  color: var(--ink-muted);
}
.login-recovery code {
  display: block;
  max-width: 100%;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.login-form-pane {
  min-width: 0;
  padding: clamp(20px, 3.5vw, 34px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.auth-alert {
  background: var(--danger-soft);
  border: 1.5px solid var(--danger);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.auth-alert strong {
  font-size: 0.86rem;
  color: var(--ink);
}
.auth-alert p {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--ink);
}

.password-input-wrap {
  display: flex;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  min-width: 0;
}
.password-input-wrap input {
  width: 0;
  flex: 1 1 0%;
  min-width: 0;
}
.pwd-toggle {
  flex: 0 0 auto;
  min-width: 58px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.pwd-toggle:hover {
  background: var(--surface-hover);
}
.pwd-toggle:active {
  transform: translateY(1px);
}
.pwd-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
  border-width: 1.5px;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 0.79rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

.login-remember {
  margin: 4px 0 16px;
}

.login-footer {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
}

.security-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.security-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.security-head .sub-heading {
  margin: 0;
}

.form-feedback {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--danger);
  background: var(--danger-soft);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* ==================== FILE & IMAGE ATTACHMENTS ==================== */
.attach-mount {
  margin: -4px 0 14px;
}

form.is-dragover .attach-bar {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.attach-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface-subtle);
  transition: background-color 120ms ease, border-color 120ms ease;
}

.attach-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.attach-hint {
  font-size: 0.77rem;
  color: var(--ink-muted);
  line-height: 1.4;
}

.attach-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(26dvh, 196px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

@media (min-width: 761px) {
  #meetingPresets,
  #missionPresets,
  #cmdPresets {
    max-height: 112px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 2px;
  }
}

.attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  min-width: 0;
}

.attach-item.is-error {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.attach-thumb {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex: none;
  background: var(--surface-subtle);
}

.attach-ext {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  text-transform: uppercase;
}

.attach-info {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.attach-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
a.attach-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

.attach-meta {
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.attach-item.is-error .attach-meta {
  color: var(--danger);
  font-weight: 600;
}

.attach-progress {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
  margin-top: 3px;
}
.attach-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 120ms ease;
}

.attach-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.sent-attach-box {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-subtle);
}
.sent-attach-title {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
}

/* ==================== PC SPLIT WORKSPACE (>= 1200px) ==================== */
@media (min-width: 1200px) {
  body.split-open .stage {
    width: 58%;
  }
  body.split-open .pending-txt,
  body.split-open .v-sep {
    display: none;
  }
  body.split-open .drawer-scrim {
    opacity: 0 !important;
    pointer-events: none !important;
  }
  body.split-open .drawer {
    top: 0;
    right: 0;
    bottom: 0;
    width: 42%;
    border-radius: 0;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    box-shadow: -8px 0 28px rgba(29, 25, 22, 0.12);
  }
  body.night.split-open .drawer {
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
  }
}
@media (min-width: 1200px) and (max-width: 1480px) {
  body.split-open .command-dock {
    max-width: calc(100% - 16px);
    padding: 4px;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
    overflow: visible;
  }
  body.split-open .command-dock .dock-primary {
    padding: 7px 10px;
    font-size: 0.8rem;
  }
  body.split-open .command-dock .dock-primary .kbd {
    display: none;
  }
  body.split-open .command-dock .hud-btn {
    padding: 6px 7px;
    font-size: 0.76rem;
  }
}

/* ==================== RESPONSIVE (iOS / 375px / 768px / 1280px+) ==================== */
@media (max-width: 768px) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  .top-hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    background: var(--surface-overlay);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-float);
    padding: 8px 10px;
    pointer-events: auto;
  }
  .status-strip,
  .utility-bar {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    min-height: 0;
    width: 100%;
  }
  .status-strip {
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
  }
  .status-strip h1 {
    font-size: 0.92rem;
    margin-right: auto;
  }
  .status-pill-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    font-size: 0.78rem;
  }
  .utility-bar {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .utility-bar .hud-btn {
    flex: 1 1 0%;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid var(--border);
    background: var(--surface-subtle);
  }
  .utility-bar #btnLatestResult {
    flex: 1.32 1 0%;
  }
  .utility-bar .hud-btn.accent {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
  }
  .banner-stack {
    top: calc(max(8px, env(safe-area-inset-top)) + 120px);
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    max-width: none;
  }
  .pending-txt,
  .v-sep,
  .dock-desktop-only,
  .hud-desktop-only {
    display: none !important;
  }
  .dock-mobile-only {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  .hud-btn,
  .status-pill-btn,
  .dock-primary,
  .btn-line,
  .mini-tab,
  .appendix-tab,
  .outline-chip,
  .followup-chip,
  .md-copy-btn,
  .pwd-toggle,
  .vp-btn,
  .doc-view-pill,
  .doc-appendix-summary,
  .file-row,
  .field input,
  .field select,
  .matrix-row select,
  .followup-row input,
  .followup-row button,
  .task-search-wrap input,
  .chat-composer input,
  .chat-composer .btn-primary,
  .attach-btns button,
  .attach-actions button,
  .daily-upgrade-row,
  .toast button {
    min-height: 44px;
  }

  .checkbox-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  .daily-brief-actions .btn-line {
    flex: 1 1 132px;
    white-space: normal;
    text-align: center;
  }

  .checkbox-row {
    min-height: 44px;
    padding: 6px 0;
    margin: 4px 0 8px;
  }

  .file-row {
    justify-content: center;
  }

  #cmdModeTabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  #cmdModeTabs .mini-tab {
    white-space: normal;
    text-align: center;
    line-height: 1.25;
    padding: 6px 6px;
    font-size: 0.76rem;
  }
  #taskFilters {
    flex-wrap: wrap;
    gap: 6px;
  }
  #taskFilters .mini-tab {
    flex: 1 1 auto;
    text-align: center;
  }

  #missionPresets,
  #meetingPresets,
  #cmdPresets,
  #stationQuickSwitch {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  #missionPresets::-webkit-scrollbar,
  #meetingPresets::-webkit-scrollbar,
  #cmdPresets::-webkit-scrollbar,
  #stationQuickSwitch::-webkit-scrollbar {
    display: none;
  }
  #missionPresets .mini-tab,
  #meetingPresets .mini-tab,
  #cmdPresets .mini-tab,
  #stationQuickSwitch .mini-tab {
    flex: none;
    white-space: nowrap;
  }

  .login-ledger {
    grid-template-columns: minmax(0, 1fr);
  }
  .login-brief {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    gap: 18px;
  }

  .mobile-room-bar {
    position: absolute;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 58px);
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: var(--r-md) var(--r-md) 0 0;
  }
  .room-jump-btn {
    border: 0;
    background: transparent;
    color: var(--ink-muted);
    border-radius: var(--r-sm);
    min-height: 44px;
    padding: 4px 2px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 120ms ease, color 120ms ease;
  }
  .room-jump-btn:hover {
    background: var(--surface-hover);
    color: var(--ink);
  }
  .room-jump-btn:active,
  .room-jump-btn.active {
    background: var(--accent);
    color: var(--accent-ink);
  }

  .command-dock {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    transform: none;
    max-width: none;
    width: auto;
    border-radius: 0 0 var(--r-md) var(--r-md);
    display: grid;
    grid-template-columns: 1.05fr 1.15fr 0.98fr 0.85fr;
    gap: 6px;
    padding: 6px;
    overflow: visible;
  }
  .command-dock .dock-primary,
  .command-dock .hud-btn {
    width: 100%;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    font-size: 0.84rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .dock-primary .kbd {
    display: none;
  }

  .drawer {
    top: auto;
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    height: min(82dvh, calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom))));
    transform: translateY(calc(100% + 24px));
  }
  .drawer.open { transform: translateY(0); }
  .drawer-body { padding: 16px; }

  .modal-backdrop {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    align-items: end;
  }
  .modal-backdrop.open .modal {
    animation: modalSheetIn 180ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .modal,
  .modal.reader-modal {
    width: 100%;
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
    border-radius: var(--r-lg) var(--r-lg) 10px 10px;
  }
  .modal-head {
    padding: 13px 16px;
    flex-wrap: wrap;
  }
  #docModal .modal-head {
    padding: 12px 14px;
    gap: 10px;
  }
  .reader-head-left {
    flex: 1 1 100%;
  }
  .reader-title {
    font-size: 1.05rem;
  }
  .reader-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 2px;
  }
  .reader-actions::-webkit-scrollbar {
    display: none;
  }
  .reader-actions .btn-line {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  .doc-view-switch {
    display: flex;
    width: 100%;
  }
  .doc-view-pill {
    flex: 1 1 0%;
    min-width: 0;
    padding: 8px 10px;
    font-size: 0.81rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .modal-body,
  .reader-body { padding: 16px; }
  .doc-appendix-summary { padding: 12px 16px; }
  .doc-appendix-body {
    max-height: min(36dvh, 260px);
    padding: 4px 16px 18px;
  }

  .followup-row {
    flex-direction: column;
    align-items: stretch;
  }
  .followup-row input {
    flex: none;
    width: 100%;
  }
  .followup-row button {
    width: 100%;
  }

  .grid-2,
  .profile-switch,
  .matrix-row,
  .files-layout {
    grid-template-columns: 1fr;
  }

  .attach-hint {
    width: 100%;
  }

  .attach-btns button,
  .attach-actions button,
  .attach-info a.attach-name,
  .reader-actions .btn-line,
  .doc-view-pill,
  .md-copy-btn,
  .outline-chip,
  .followup-chip,
  .mini-tab,
  .appendix-tab,
  .toast button,
  .modal-head [data-close-modal] {
    min-width: 44px;
    min-height: 44px;
  }
  .attach-info a.attach-name {
    display: block;
    line-height: 44px;
  }

  .attach-item.is-error {
    flex-wrap: wrap;
  }

  .attach-item.is-error .attach-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 2px;
  }

  #meetingForm .action-row .btn-primary,
  #meetingForm .action-row .btn-line {
    flex: 1 1 100%;
    min-height: 44px;
  }

  .toast {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 124px);
    max-width: none;
  }
}

.chat-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22C55E;
  margin-left: 5px;
  vertical-align: middle;
}

.chat-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 280px;
}
.chat-view[hidden] { display: none; }
.chat-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.chat-feed {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
}
.chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 92%;
  min-width: 0;
}
.chat-msg.is-ceo {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-avatar {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
}
.chat-avatar[style*="background"] {
  color: #FAF7F2;
}
.chat-bubble {
  padding: 8px 11px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.45;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-msg.is-ceo .chat-bubble {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.chat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.73rem;
  color: var(--ink-muted);
  margin-bottom: 3px;
}
.chat-msg.is-ceo .chat-meta {
  color: var(--accent-ink);
  opacity: 0.84;
  justify-content: flex-end;
}
.chat-composer {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: none;
}
.chat-composer input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
}
.chat-composer input:focus {
  border-color: var(--accent);
}
.chat-composer .btn-primary {
  width: auto;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 9px 16px;
}
@media (max-width: 768px) {
  .chat-view {
    height: 100%;
    min-height: 240px;
  }
}

@media (max-width: 420px) {
  .top-hud { padding: 6px 8px; gap: 6px; }
  .status-strip h1 { font-size: 0.84rem; }
  .utility-bar .hud-btn { padding: 6px 6px; font-size: 0.75rem; }
  .room-jump-btn { font-size: 0.72rem; }
  .command-dock .dock-primary,
  .command-dock .hud-btn { padding: 6px 4px; font-size: 0.76rem; }
}

/* ==================== CALM EXECUTIVE DECLUTTER & POLISH (PC + iOS) ==================== */
/* Suppress redundant stacked addon bars/chips on primary surfaces while keeping deep tools cleanly accessible inside Settings (#addonSettingsPulseBtn) & keyboard shortcuts (H / E) */
#addonHudPulseBtn,
#addonDockExec,
#addonCeoExecBar,
#addonCompanyPulseStrip,
#addonQuickFilterBar,
#addonChatQuickBar,
#addonMissionTplBar,
#addonCmdTplBar,
#addonSmartBriefCard,
#addonDeskPaceChip,
#addonBtnPinScope,
#addonBtnAckScope,
#addonBtnNextReview,
#addonBtnToggleBrief,
#addonBtnSendDirective {
  display: none !important;
}

/* Refined floating glass-paper HUD & Dock on PC (dose-capped to the 2 primary floating bars) */
.status-strip,
.utility-bar,
.command-dock {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
}

.command-dock {
  padding: 5px 6px;
  gap: 5px;
}

/* Compact 1-row Daily Brief inside Tasks drawer so missions appear immediately above the fold */
#ceoDailyBrief {
  padding: 10px 12px;
  margin-bottom: 10px;
  gap: 8px;
}
#ceoDailyBrief .daily-brief-lead,
#ceoDailyBrief .daily-recent-upgrades,
#ceoDailyBrief .daily-brief-actions:empty {
  display: none !important;
}
#ceoDailyBrief .daily-brief-head {
  gap: 8px;
}
#ceoDailyBrief .daily-brief-title {
  font-size: 0.84rem;
}
#ceoDailyBrief .daily-brief-stats {
  gap: 6px;
  margin: 0;
}
#ceoDailyBrief .daily-stat-item {
  padding: 6px 8px;
}
#ceoDailyBrief .daily-stat-item dt {
  font-size: 0.72rem;
}
#ceoDailyBrief .daily-stat-item dd {
  font-size: 1rem;
}

/* Subtle, out-of-the-way canvas zoom pill on PC; hidden on mobile where native pinch-zoom handles the room */
#addonCanvasControls {
  opacity: 0.84;
  transition: opacity 160ms ease;
}
#addonCanvasControls:hover {
  opacity: 1;
}

/* Cleaner task filter strip & reader header */
#view-tasks .task-search-wrap {
  margin-bottom: 8px;
}
#view-tasks #taskFilters {
  margin-bottom: 12px;
}
.reader-actions {
  gap: 6px;
}

/* Mobile / iOS clean single-tier HUD & calm native-feel bottom dock */
@media (max-width: 768px) {
  #addonCanvasControls,
  #addonDeskPaceChip {
    display: none !important;
  }

  .top-hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 12px;
  }

  .status-strip {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
    padding: 0 2px;
    gap: 7px;
    min-height: 44px;
  }

  .status-strip .v-sep,
  .status-strip .pending-txt,
  .status-strip .status-pill-btn {
    display: none;
  }

  .status-strip h1 {
    margin-right: 0;
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .utility-bar {
    width: auto;
    flex: 0 0 auto;
    padding: 0;
    gap: 5px;
    min-height: 44px;
  }

  .utility-bar .hud-btn {
    flex: 0 0 auto;
    width: auto;
    min-height: 44px;
    padding: 6px 10px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  #btnLatestResult {
    display: none !important;
  }

  .mobile-room-bar {
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 58px);
    padding: 4px;
    gap: 4px;
    border-radius: 12px;
  }

  .room-jump-btn {
    min-height: 44px;
    font-size: 0.76rem;
    border-radius: 8px;
  }

  .command-dock {
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100% - 20px);
    max-width: calc(100% - 20px);
    padding: 4px;
    gap: 4px;
    border-radius: 14px;
    justify-content: space-between;
  }

  .command-dock .dock-primary,
  .command-dock .hud-btn {
    flex: 1 1 0;
    min-height: 44px;
    padding: 6px 6px;
    font-size: 0.78rem;
    text-align: center;
    justify-content: center;
  }

  .command-dock .kbd {
    display: none;
  }

  /* Give Group Chat full comfortable height inside mobile drawer without clipping composer */
  .chat-view {
    height: 100%;
    min-height: 240px;
  }
  .chat-top-bar {
    padding: 6px 0;
  }

  /* Clean mobile reader modal */
  .reader-body {
    padding: 16px 16px 24px;
  }
  .doc-quick-summary {
    padding: 10px 12px;
    margin-bottom: 14px;
  }
}

/* 3-line quick summary box at top of Result Reader */
.doc-quick-summary {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.doc-quick-head {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 6px;
}
.doc-quick-row {
  margin: 3px 0;
}
.doc-quick-label {
  font-weight: 600;
  color: var(--ink);
}
.doc-quick-val {
  color: var(--ink-muted);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  html,
  body,
  body.night {
    --surface: #ffffff;
    --surface-subtle: #F4F1EA;
    --surface-hover: #EAE3D6;
    --border: #D8CFC2;
    --border-strong: #786E62;
    --ink: #1C1815;
    --ink-muted: #585047;
    --accent: #1B5E4B;
    --accent-hover: #144839;
    --accent-ink: #FAF7F2;
    --accent-soft: #E5F0EC;
    --warn: #A15C07;
    --warn-soft: #FBF3E6;
    --danger: #B42318;
    --danger-ink: #FAF7F2;
    --danger-soft: #FCEAE8;
    --code-bg: #F4F1EA;
    --code-ink: #1C1815;
    --code-muted: #585047;
    height: auto !important;
    overflow: visible !important;
    background: #ffffff !important;
    color: #1C1815 !important;
  }
  .stage,
  .drawer-scrim,
  .drawer,
  #cmdModal,
  #guideModal,
  .toast,
  .reader-actions,
  .doc-view-switch,
  .decision-bar,
  .doc-outline-bar,
  .progress-strip,
  .followup-bar,
  .doc-appendix,
  .md-copy-btn {
    display: none !important;
  }
  #docModal:not(.open) {
    display: none !important;
  }
  #docModal.open {
    position: static !important;
    display: block !important;
    padding: 0 !important;
    background: transparent !important;
  }
  #docModal.open .modal.reader-modal {
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    border: 0 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #1C1815 !important;
    overflow: visible !important;
  }
  #docModal.open .modal-head {
    padding: 0 0 12px !important;
    border-bottom: 1.5px solid #786E62 !important;
  }
  #docModal.open .reader-body {
    padding: 18px 0 0 !important;
    overflow: visible !important;
  }
  #docModal.open .reader-column {
    max-width: none !important;
  }
  #docModal.open .md-table-wrap {
    overflow: visible !important;
  }
  #docModal.open .md-view table {
    min-width: 0 !important;
    width: 100% !important;
  }
  #docModal.open .md-code-wrap {
    border: 1px solid #D8CFC2 !important;
  }
  #docModal.open .md-code-head {
    background: #EAE3D6 !important;
    border-bottom: 1px solid #D8CFC2 !important;
  }
}
