/* ============================================================
 * MiiHealth Protocol Tester - OPUS4.5 Static Mockup
 * ============================================================ */

/* 1. Tokens */
@import url("https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap");

:root {
  --brand-50: #EEFBF8;
  --brand-100: #D0F5EE;
  --brand-200: #A4EADF;
  --brand-300: #6EDCCC;
  --brand-400: #3BCDB9;
  --brand-500: #00C9AF;
  --brand-600: #00A892;
  --brand-700: #008575;
  --brand-800: #006A5E;
  --brand-900: #00564D;
  --surface-0: #FFFFFF;
  --surface-50: #FAF8F6;
  --surface-100: #F0EDE8;
  --surface-200: #E8E4DD;
  --surface-300: #DDD8D0;
  --surface-400: #D0C9BF;
  --surface-500: #C0B8AC;
  --ink-100: #E8E8E8;
  --ink-200: #C4C4C3;
  --ink-300: #9E9D9B;
  --ink-400: #787674;
  --ink-500: #58564F;
  --ink-600: #3E3C38;
  --ink-700: #2A2824;
  --ink-800: #171512;
  --ink-900: #070200;
  --success-50: #EEFBF2;
  --success-100: #D4F5DF;
  --success-500: #2ECC71;
  --success-600: #27AE60;
  --warning-50: #FFF9EB;
  --warning-500: #F0AD4E;
  --warning-700: #9A6400;
  --danger-50: #FEF2F2;
  --danger-500: #E74C3C;
  --danger-600: #C0392B;
  --editor-dark-bg: #1E1E2E;
  --editor-dark-gutter: #181825;
  --editor-dark-fg: #CDD6F4;
  --editor-dark-line: #4A4A5A;
  --shadow-xs: 0 1px 2px rgba(7, 2, 0, .04);
  --shadow-card: 0 1px 4px rgba(7, 2, 0, .06);
  --shadow-panel: 0 2px 8px -2px rgba(7, 2, 0, .08), 0 0 0 1px rgba(7, 2, 0, .04);
  --shadow-elevated: 0 4px 20px -4px rgba(7, 2, 0, .10);
  --shadow-modal: 0 20px 60px -12px rgba(7, 2, 0, .18);
  --shadow-focus: 0 0 0 3px rgba(0, 201, 175, .28);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-shell: 24px;
  --radius-pill: 999px;
  --font-sans: "Figtree", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 17px;
  --motion-fast: 120ms;
  --motion-base: 200ms;
  --motion-slow: 320ms;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --rehearsal-width: 380px;
  --filebrowser-width: 220px;
}

/* 2. Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--ink-800);
  background:
    radial-gradient(circle at 8% 0%, rgba(245, 230, 200, .55), transparent 28%),
    linear-gradient(180deg, var(--surface-100), var(--surface-200));
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--brand-100);
  color: var(--ink-900);
}

/* 3. Desktop Guard */
.desktop-guard {
  display: none;
  min-height: 100vh;
  padding: 20px;
  align-items: center;
  justify-content: center;
}

.desktop-guard-card {
  max-width: 420px;
  padding: 22px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-xl);
  background: var(--surface-0);
  box-shadow: var(--shadow-elevated);
}

.desktop-guard-card h1 {
  font-size: 20px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.desktop-guard-card p {
  font-size: var(--text-sm);
  color: var(--ink-500);
}

/* 4a. Login Screen */
.login-screen {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.login-image-panel {
  position: relative;
  flex: 0 0 55%;
  overflow: hidden;
}

.login-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
}

.login-image-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    rgba(250, 248, 246, 0) 40%,
    rgba(250, 248, 246, 0.08) 100%
  );
  display: flex;
  align-items: flex-end;
  padding: 36px 40px;
}

.login-tagline {
  color: var(--surface-0);
  text-shadow: 0 1px 8px rgba(7, 2, 0, 0.32);
}

.login-tagline-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.82;
  margin-bottom: 5px;
}

.login-tagline p {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  max-width: 340px;
}

.login-form-panel {
  flex: 0 0 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--surface-50);
  overflow-y: auto;
}

.login-form-inner {
  width: 100%;
  max-width: 360px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 36px;
}

.login-product-name {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 3px 10px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-pill);
  background: var(--surface-0);
  color: var(--ink-700);
}

.login-heading {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink-800);
  margin-bottom: 6px;
}

.login-sub {
  font-size: var(--text-sm);
  color: var(--ink-500);
  margin-bottom: 28px;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-field span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-600);
}

.login-field input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  color: var(--ink-800);
  font-size: var(--text-base);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

.login-field input:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: var(--shadow-focus);
}

.login-field input::placeholder {
  color: var(--ink-300);
}

.login-error {
  min-height: 20px;
  font-size: var(--text-sm);
  color: var(--danger-600);
  font-weight: 600;
}

.login-submit {
  width: 100%;
  height: 44px;
  margin-top: 6px;
  border-radius: var(--radius-md);
  background: var(--ink-900);
  color: var(--surface-0);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background var(--motion-fast), transform var(--motion-fast);
}

.login-submit:hover {
  background: var(--ink-700);
}

.login-submit:active {
  transform: scale(0.99);
}

.login-disclaimer {
  margin-top: 20px;
  font-size: 11px;
  color: var(--ink-400);
  line-height: 1.5;
}

.app-shell--hidden {
  display: none !important;
}

.login-screen--hidden {
  display: none !important;
}

/* 4. App Shell */
.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 20px);
  margin: 10px;
  overflow: hidden;
  border-radius: var(--radius-shell);
  background: var(--surface-50);
  box-shadow: var(--shadow-elevated);
  animation: shell-in var(--motion-slow) var(--ease-out) both;
}

.shell-topbar {
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 18px;
  border-bottom: 1px solid var(--surface-200);
  background: rgba(250, 248, 246, .94);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar-left {
  gap: 14px;
}

.topbar-right {
  gap: 10px;
}

.shell-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-700);
}

.brand-logo {
  display: block;
  width: 112px;
  height: auto;
}

.product-label {
  padding: 3px 10px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-pill);
  background: var(--surface-0);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--ink-800);
  white-space: nowrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  color: var(--ink-600);
  font-size: var(--text-sm);
}

.breadcrumb-link,
.breadcrumb-current {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumb-current {
  max-width: 300px;
  color: var(--ink-800);
  font-weight: 700;
}

.breadcrumb-sep {
  color: var(--ink-500);
  font-size: 10px;
}

.validation-pill,
.validation-inline,
.environment-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-pill);
  background: var(--surface-0);
  color: var(--ink-600);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.environment-badge {
  color: var(--brand-800);
  background: var(--brand-50);
  border-color: var(--brand-100);
}

.environment-badge-wrap {
  display: inline-flex;
  align-items: center;
}

.environment-select {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-pill);
  background: var(--brand-50);
  color: var(--brand-800);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--motion-fast), background var(--motion-fast);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23006A5E' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.environment-select:hover {
  border-color: var(--brand-300);
  background-color: var(--brand-100);
}

.environment-select:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: var(--shadow-focus);
}

.status-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-300);
  box-shadow: 0 0 0 3px rgba(167, 173, 183, .18);
}

.status-unchecked {
  background: #A7ADB7;
}

.status-valid {
  background: var(--success-500);
  box-shadow: 0 0 0 3px rgba(46, 204, 113, .16);
}

.status-warning {
  background: var(--warning-500);
  box-shadow: 0 0 0 3px rgba(240, 173, 78, .18);
}

.status-invalid {
  background: var(--danger-500);
  box-shadow: 0 0 0 3px rgba(231, 76, 60, .16);
}

.icon-button {
  position: relative;
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--surface-300);
  border-radius: 50%;
  background: var(--surface-0);
  color: var(--ink-500);
  transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}

.icon-button:hover {
  border-color: var(--surface-400);
  background: var(--surface-100);
  color: var(--ink-800);
}

.profile-button {
  overflow: hidden;
  padding: 0;
  border-color: var(--brand-100);
  background: var(--brand-50);
}

.profile-button:hover,
.profile-button:focus-visible {
  border-color: var(--brand-300);
  background: var(--brand-100);
}

.profile-avatar-small,
.profile-avatar-photo {
  display: block;
  object-fit: cover;
  border-radius: 50%;
}

.profile-avatar-small {
  width: 26px;
  height: 26px;
}

[data-tooltip] {
  position: relative;
}

/* CSS pseudo-element tooltips are disabled — JS cursor-tooltip is used instead */

/* JS-managed tooltip — follows pointer, clamped within viewport */
.cursor-tooltip {
  position: fixed;
  z-index: 9999;
  top: 0;
  left: 0;
  width: max-content;
  max-width: 260px;
  padding: 7px 9px;
  border: 1px solid rgba(7, 2, 0, .12);
  border-radius: var(--radius-md);
  background: var(--ink-900);
  box-shadow: var(--shadow-elevated);
  color: var(--surface-0);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity var(--motion-fast), transform var(--motion-fast);
}

.cursor-tooltip.cursor-tooltip--visible {
  opacity: 1;
  transform: translateY(0);
}

.topbar-menu-wrap,
.create-menu-wrap {
  position: relative;
}

.hover-menu {
  position: absolute;
  z-index: 25;
  right: 0;
  display: none;
  min-width: 178px;
  padding: 5px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .98);
  box-shadow: var(--shadow-elevated);
}

.hover-menu::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  height: 12px;
}

.topbar-menu {
  top: calc(100% + 8px);
}

.profile-popover {
  width: 320px;
  min-width: 320px;
  padding: 0;
  overflow: hidden;
}

.create-menu {
  top: calc(100% + 7px);
}

.topbar-menu-wrap.is-menu-open .topbar-menu,
.create-menu-wrap.is-menu-open .create-menu {
  display: grid;
  gap: 2px;
}

.profile-card {
  display: grid;
  gap: 16px;
  padding: 16px;
}

/* Photo row: avatar left, upload actions right */
.profile-photo-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.profile-avatar-large {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border: 2px solid var(--brand-100);
  border-radius: 18px;
  background: var(--brand-50);
  cursor: pointer;
}

.profile-avatar-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo-meta {
  display: grid;
  gap: 4px;
  padding-top: 4px;
}

.profile-photo-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.profile-photo-link {
  border: none;
  background: none;
  padding: 0;
  color: var(--brand-700);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.profile-photo-link:hover,
.profile-photo-link:focus-visible {
  color: var(--brand-900);
}

.profile-photo-link--remove {
  color: var(--ink-500);
}

.profile-photo-link--remove:hover,
.profile-photo-link--remove:focus-visible {
  color: #c0392b;
}

.profile-photo-sep {
  color: var(--ink-400);
  font-size: var(--text-xs);
  user-select: none;
}

.profile-photo-hint {
  margin: 0;
  color: var(--ink-500);
  font-size: 11px;
}

/* Password section */
.profile-pw-section {
  display: grid;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--surface-200);
}

.profile-section-heading {
  color: var(--ink-700);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.profile-fields {
  display: grid;
  gap: 8px;
}

.profile-field {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--surface-250);
  border-radius: var(--radius-md);
  background: var(--surface-50);
  transition: border-color var(--motion-fast), background var(--motion-fast);
}

.profile-field:focus-within {
  border-color: var(--brand-300);
  background: var(--surface-0);
}

.profile-field label,
.profile-about span {
  color: var(--ink-500);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: default;
}

.profile-input {
  border: none;
  background: transparent;
  color: var(--ink-900);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0;
  outline: none;
  width: 100%;
  overflow-wrap: anywhere;
}

.profile-about {
  display: grid;
  gap: 6px;
  padding: 11px 12px;
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-lg);
  background: var(--brand-50);
}

.profile-about p {
  margin: 0;
  color: var(--ink-650);
  font-size: var(--text-xs);
  font-weight: 560;
  line-height: 1.5;
}

.hover-menu button {
  display: flex;
  width: 100%;
  height: 30px;
  align-items: center;
  padding: 0 9px;
  border-radius: var(--radius-md);
  color: var(--ink-700);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: left;
}

.hover-menu button:hover,
.hover-menu button:focus-visible {
  background: var(--brand-50);
  color: var(--brand-900);
}

/* 5. Main Workbench */
.workspace {
  position: relative;
  display: grid;
  grid-template-columns: var(--filebrowser-width) minmax(0, 1fr) var(--rehearsal-width);
  gap: 0 8px;
  min-height: 0;
  height: calc(100% - 52px);
  padding: 8px 8px 72px;
  overflow: hidden;
}

.rail-resize-handle {
  position: absolute;
  top: 8px;
  bottom: 72px;
  right: calc(var(--rehearsal-width) + 7px);
  z-index: 4;
  width: 10px;
  border-radius: var(--radius-pill);
  cursor: ew-resize;
  touch-action: none;
}

.rail-resize-handle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 4px;
  height: 54px;
  border-radius: var(--radius-pill);
  background: var(--surface-400);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .62);
  opacity: .54;
  transform: translateY(-50%);
  transition: background var(--motion-fast), opacity var(--motion-fast), height var(--motion-fast);
}

.rail-resize-handle:hover::before,
.rail-resize-handle:focus-visible::before,
.is-resizing-rail .rail-resize-handle::before {
  height: 72px;
  background: var(--brand-500);
  opacity: 1;
}

/* File browser right-edge resize handle */
.filebrowser-resize-handle {
  position: absolute;
  top: 8px;
  bottom: 72px;
  left: calc(var(--filebrowser-width) + 11px);
  z-index: 4;
  width: 10px;
  border-radius: var(--radius-pill);
  cursor: ew-resize;
  touch-action: none;
}

.filebrowser-resize-handle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 4px;
  height: 54px;
  border-radius: var(--radius-pill);
  background: var(--surface-400);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .62);
  opacity: .72;
  transform: translateY(-50%);
  transition: background var(--motion-fast), opacity var(--motion-fast), height var(--motion-fast);
}

.filebrowser-resize-handle:hover::before,
.filebrowser-resize-handle:focus-visible::before,
.is-resizing-filebrowser .filebrowser-resize-handle::before {
  height: 72px;
  background: var(--brand-500);
  opacity: 1;
}

.is-resizing-filebrowser,
.is-resizing-filebrowser * {
  cursor: ew-resize !important;
  user-select: none !important;
}

.file-browser,
.editor-panel,
.rehearsal-panel {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-xl);
  background: var(--surface-0);
  box-shadow: var(--shadow-panel);
}

.file-browser {
  display: flex;
  flex-direction: column;
  animation: pane-in var(--motion-slow) var(--ease-out) 40ms both;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  animation: pane-in var(--motion-slow) var(--ease-out) 80ms both;
}

.rehearsal-panel {
  display: flex;
  flex-direction: column;
  animation: pane-in var(--motion-slow) var(--ease-out) 120ms both;
}

.pane-header,
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--surface-200);
}

.editor-header {
  justify-content: stretch;
}

.file-browser-header {
  min-height: 104px;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 12px 12px;
}

.pane-title-group {
  min-width: 0;
}

.pane-header h2 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-700);
}

.pane-title-group p {
  margin-top: 6px;
  color: var(--ink-600);
  font-size: 10px;
  line-height: 1.35;
}

.pane-title-group code {
  font-family: var(--font-mono);
  font-size: 9px;
}

.file-tree {
  flex: 1;
  min-height: 0;
  padding: 8px 6px;
  overflow: auto;
}

.tree-row {
  display: grid;
  grid-template-columns: 14px 17px minmax(0, 1fr) 48px;
  gap: 6px;
  align-items: center;
  height: 28px;
  padding: 0 8px 0 calc(8px + (var(--tree-depth) * 14px));
  border-radius: var(--radius-md);
  color: var(--ink-600);
  font-size: var(--text-sm);
  user-select: none;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.tree-row:hover {
  background: var(--surface-100);
  color: var(--ink-800);
}

.tree-row.active {
  background: var(--brand-50);
  color: var(--ink-900);
  font-weight: 600;
}

.tree-row-invalid .tree-name {
  color: var(--danger-600);
  font-weight: 700;
}

.tree-row-invalid .tree-icon {
  color: var(--danger-500);
}

.tree-row[aria-expanded="true"] .tree-chevron svg {
  transform: rotate(90deg);
}

.tree-chevron {
  color: var(--ink-500);
}

.tree-chevron svg {
  transition: transform var(--motion-fast);
}

.tree-icon {
  color: var(--ink-500);
}

.tree-row.active .tree-icon {
  color: var(--brand-700);
}

.tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-fast);
}

.tree-row:hover .tree-actions,
.tree-row:focus-within .tree-actions,
.tree-row.active .tree-actions {
  opacity: 1;
  pointer-events: auto;
}

.tree-action-button {
  display: inline-flex;
  width: 21px;
  height: 21px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--ink-500);
}

.tree-action-button:hover,
.tree-action-button:focus-visible {
  border-color: var(--surface-300);
  background: var(--surface-0);
  color: var(--ink-800);
}

.tree-action-button.danger:hover,
.tree-action-button.danger:focus-visible {
  border-color: rgba(231, 76, 60, .24);
  background: var(--danger-50);
  color: var(--danger-600);
}

/* 6. YAML Editor */
.editor-actions {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.syntax-actions,
.editor-theme-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.segmented-control {
  display: inline-flex;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-pill);
  background: var(--surface-100);
}

.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  min-width: 78px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  color: var(--ink-600);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  text-align: center;
}

.segment.active {
  background: var(--surface-0);
  color: var(--ink-800);
  box-shadow: var(--shadow-xs);
}

.small-button,
.ghost-button,
.start-button,
.round-control,
.end-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), transform var(--motion-fast);
}

.small-button {
  padding: 0 13px;
  background: var(--ink-900);
  color: var(--surface-0);
}

.small-button:hover,
.start-button:hover {
  transform: translateY(-1px);
}

.editor-body {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 8px;
  overflow: hidden;
  background: var(--surface-50);
}

/* When a file is loaded, editor-body becomes the scroll container */
.editor-body.has-file {
  padding: 0;
  overflow: auto;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-lg);
  background: var(--surface-0);
}

.editor-body.has-file .code-content {
  /* Fill editor-body width exactly; never grow wider than its container. */
  width: 100%;
  padding: 10px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.72;
  tab-size: 2;
  box-sizing: border-box;
}

.editor-placeholder {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--surface-300);
  border-radius: var(--radius-lg);
  color: var(--ink-500);
  font-size: var(--text-sm);
}

.code-line {
  display: grid;
  /* Content column fills the available editor width; no hard floor. */
  grid-template-columns: 52px 1fr;
  min-height: 21px;
}

.line-number {
  padding-right: 14px;
  border-right: 1px solid var(--surface-200);
  color: var(--ink-500);
  text-align: right;
  user-select: none;
}

.line-content {
  display: block;
  padding: 0 20px;
  /* pre-wrap preserves indentation/spacing like pre but allows long lines
     to wrap within the editor-body boundary. */
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* Theme selectors are qualified with .editor-body to match the specificity of
   .editor-body.has-file (0,2,0) and win on cascade order (they appear later). */
.editor-body.theme-light {
  background: var(--surface-0);
  color: var(--ink-800);
}

.editor-body.theme-light .line-number {
  background: var(--surface-100);
}

.editor-body.theme-light .y-key {
  color: #006A5E;
  font-weight: 600;
}

.editor-body.theme-light .y-str {
  color: #A44D00;
}

.editor-body.theme-light .y-num {
  color: #6F42C1;
}

.editor-body.theme-light .y-bool {
  color: #B0005A;
}

.editor-body.theme-light .y-punct {
  color: #C0392B;
}

.editor-body.theme-light .y-comment {
  color: #787674;
  font-style: italic;
}

.editor-body.theme-dark {
  border-color: #3E3D32;
  background: #272822;
  color: #F8F8F2;
}

.editor-body.theme-dark .line-number {
  border-right-color: #3E3D32;
  background: #1F201B;
  color: #75715E;
}

.editor-body.theme-dark .y-key {
  color: #A6E22E;
  font-weight: 600;
}

.editor-body.theme-dark .y-str {
  color: #E6DB74;
}

.editor-body.theme-dark .y-num {
  color: #AE81FF;
}

.editor-body.theme-dark .y-bool {
  color: #AE81FF;
}

.editor-body.theme-dark .y-punct {
  color: #F92672;
}

.editor-body.theme-dark .y-comment {
  color: #75715E;
  font-style: italic;
}

/* 7. Rehearsal Panel */
.rehearsal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--surface-200);
  background: var(--surface-50);
}

.rehearsal-tab {
  height: 32px;
  border-radius: var(--radius-pill);
  color: var(--ink-600);
  font-size: var(--text-sm);
  font-weight: 700;
}

.rehearsal-tab.active {
  background: var(--surface-0);
  color: var(--ink-900);
  box-shadow: var(--shadow-card);
}

.rehearsal-scroll {
  flex: 1;
  min-height: 0;
  padding: 12px;
  overflow: auto;
}

.rehearsal-status {
  min-height: 24px;
  margin: 2px 0 12px;
  padding: 0 8px;
  color: var(--ink-600);
  font-size: var(--text-sm);
  font-style: italic;
  font-weight: 500;
  text-align: center;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span,
.attributes-title {
  color: var(--ink-600);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.field input,
.field select,
.custom-row input {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  color: var(--ink-800);
  font-size: var(--text-xs);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

.field input:focus,
.field select:focus,
.custom-row input:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: var(--shadow-focus);
}

.wizard-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-200);
}

.wizard-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.wizard-section-badge {
  padding: 1px 7px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-pill);
  background: var(--surface-100);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-600);
}

.custom-attributes {
  margin-top: 12px;
}

.attributes-title {
  margin-bottom: 6px;
}

.custom-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 28px;
  gap: 6px;
  margin-bottom: 6px;
}

.remove-attribute {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 30px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-md);
  color: var(--ink-500);
}

.remove-attribute:hover {
  background: var(--danger-50);
  border-color: rgba(231, 76, 60, .28);
  color: var(--danger-600);
}

.ghost-button {
  padding: 0 12px;
  border: 1px solid var(--surface-300);
  background: var(--surface-0);
  color: var(--ink-600);
}

.ghost-button:hover {
  background: var(--surface-100);
  color: var(--ink-900);
}

.start-button {
  width: 100%;
  margin-top: 12px;
  padding: 0 14px;
  background: var(--ink-900);
  color: var(--surface-0);
}

.start-button:disabled {
  cursor: not-allowed;
  opacity: .45;
  transform: none;
}

.button-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(0, 201, 175, .16);
}

.rehearsal-footer-note,
.contract-note {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-lg);
  font-size: var(--text-xs);
  line-height: 1.35;
}

.rehearsal-footer-note {
  background: var(--brand-50);
  color: var(--brand-900);
}

.contract-note {
  border: 1px solid rgba(240, 173, 78, .30);
  background: var(--warning-50);
  color: #7A4F00;
}

.session-stage {
  margin-top: 12px;
}

.idle-card,
.connection-card,
.live-card,
.complete-card {
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-xl);
  background: var(--surface-50);
  box-shadow: var(--shadow-card);
}

.idle-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 84px;
  padding: 12px;
}

.idle-icon,
.complete-icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand-800);
}

.idle-card p,
.complete-card p {
  color: var(--ink-600);
  font-size: var(--text-sm);
}

.connection-card,
.live-card,
.complete-card {
  padding: 12px;
}

.visualizer-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 126px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .76), rgba(238, 251, 248, .56)),
    var(--surface-0);
}

.voice-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 160px;
  color: var(--ink-600);
  font-size: var(--text-xs);
  font-weight: 700;
}

.bar-visualizer {
  display: flex;
  width: 132px;
  height: 120px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, .70);
}

.voice-bar {
  width: 10px;
  border-radius: var(--radius-pill);
  background: var(--voice-color, var(--brand-500));
  box-shadow: 0 10px 26px rgba(0, 201, 175, .20);
  animation: voice-pulse 900ms var(--ease-out) infinite alternate;
}

.voice-bar:nth-child(2) {
  animation-delay: 110ms;
}

.voice-bar:nth-child(3) {
  animation-delay: 210ms;
}

.voice-bar:nth-child(4) {
  animation-delay: 320ms;
}

.voice-bar:nth-child(5) {
  animation-delay: 420ms;
}

.connection-steps {
  display: grid;
  gap: 6px;
}

.connection-step {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  color: var(--ink-600);
  font-size: var(--text-xs);
}

.connection-step strong {
  color: var(--ink-700);
  font-size: 10px;
}

.connection-step.done .step-index {
  background: var(--success-500);
  color: white;
}

.connection-step.active {
  border-color: var(--brand-200);
  background: var(--brand-50);
  color: var(--ink-800);
}

.connection-step.active .step-index {
  background: var(--brand-500);
  color: var(--ink-900);
}

.step-index {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-200);
  color: var(--ink-600);
  font-size: 10px;
  font-weight: 800;
}

.transcript {
  display: flex;
  max-height: 214px;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  overflow: auto;
}

.transcript-turn {
  max-width: 92%;
  padding: 8px 10px;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-lg);
  background: var(--surface-0);
}

.transcript-turn.user {
  align-self: flex-end;
  background: var(--ink-800);
  color: var(--surface-0);
}

.turn-label {
  margin-bottom: 3px;
  color: inherit;
  font-size: 10px;
  font-weight: 800;
  opacity: .72;
  text-transform: uppercase;
}

.turn-text {
  font-size: var(--text-sm);
  line-height: 1.42;
}

.control-row {
  display: flex;
  gap: 8px;
}

.round-control {
  flex: 1;
  border: 1px solid var(--surface-300);
  background: var(--surface-0);
  color: var(--ink-700);
}

.end-control {
  flex: 1;
  background: var(--danger-500);
  color: white;
}

.call-timeline {
  display: grid;
  gap: 8px;
  margin: 0 14px 12px;
}

.call-timeline div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  background: var(--surface-0);
}

.call-timeline span {
  color: var(--ink-600);
  font-size: var(--text-xs);
  font-weight: 700;
}

.call-timeline strong {
  color: var(--ink-800);
  font-size: var(--text-xs);
  text-align: right;
}

.complete-card {
  text-align: center;
}

.complete-card .complete-icon {
  margin: 0 auto 8px;
}

.complete-card h3 {
  margin-bottom: 4px;
  font-size: var(--text-lg);
}

/* 8. Agent Logs Drawer */
.logs-drawer {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  z-index: 5;
  display: flex;
  height: 40px;
  min-height: 40px;
  max-height: 75%;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-xl);
  background: rgba(246, 243, 238, .98);
  box-shadow: var(--shadow-modal);
  transition: height var(--motion-slow) var(--ease-out), transform var(--motion-slow) var(--ease-out);
}

.logs-drawer[data-state="open"] {
  height: 20vh;
  min-height: 160px;
}

.logs-resize-handle {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 2;
  width: 76px;
  height: 8px;
  transform: translateX(-50%);
  cursor: ns-resize;
  touch-action: none;
}

.logs-resize-handle::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 12px;
  width: 52px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--surface-400);
}

.logs-header {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid transparent;
}

.logs-drawer[data-state="open"] .logs-header {
  border-bottom-color: var(--surface-300);
}

.logs-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-800);
  font-size: var(--text-sm);
  font-weight: 800;
}

.logs-caret {
  transition: transform var(--motion-fast);
}

.logs-drawer[data-state="open"] .logs-caret {
  transform: rotate(90deg);
}

.logs-status {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--brand-50);
  color: var(--brand-900);
  font-size: var(--text-xs);
  font-weight: 700;
}

.logs-summary {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-600);
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logs-body {
  display: none;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.logs-drawer[data-state="open"] .logs-body {
  display: flex;
  flex-direction: column;
}

.logs-empty {
  padding: 18px 14px;
  color: var(--ink-500);
  font-size: var(--text-sm);
}

.logs-rows {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 7px 8px 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
}

/* Logs tab strip */
.logs-tab-strip {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--surface-200);
  flex-shrink: 0;
}

.logs-tab {
  padding: 5px 12px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: none;
  color: var(--ink-500);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.logs-tab:hover:not(.logs-tab--disabled) {
  background: var(--surface-100);
  color: var(--ink-700);
}

.logs-tab--active {
  background: var(--surface-0);
  color: var(--ink-800);
  border-color: var(--surface-200);
  position: relative;
}

.logs-tab--active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--surface-0);
}

.logs-tab--disabled {
  opacity: 0.45;
  cursor: default;
}

/* Transcript panel */
.tx-line {
  display: flex;
  gap: 8px;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  align-items: flex-start;
}

.tx-line:nth-child(odd) {
  background: rgba(255, 255, 255, .58);
}

.tx-speaker {
  width: 54px;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 1px;
}

.tx-agent .tx-speaker { color: var(--brand-700); }
.tx-patient .tx-speaker { color: var(--ink-500); }

.tx-text {
  flex: 1;
  color: var(--ink-700);
  font-family: var(--font-sans);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* Slots panel */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  padding: 6px 4px;
}

.slot-card {
  padding: 7px 9px;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  background: var(--surface-0);
}

.slot-key {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-500);
  margin-bottom: 3px;
}

.slot-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-800);
  margin-bottom: 4px;
}

.slot-conf {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.conf-high { color: var(--success-600); }
.conf-mid { color: var(--warning-600); }
.conf-low { color: var(--danger-600); }

/* Clinical notes panel */
.cn-yaml-block {
  padding: 14px 16px;
}

.cn-yaml-pre {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-700);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.cn-yaml-line {
  display: block;
  min-height: 1em;
}

.artifact-empty {
  padding: 18px 12px;
  color: var(--ink-400);
  font-size: 12px;
  font-family: var(--font-sans);
}

.log-row {
  display: grid;
  grid-template-columns: 70px 52px 82px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 4px 7px;
  border-radius: var(--radius-sm);
  color: var(--ink-600);
}

.log-row:nth-child(odd) {
  background: rgba(255, 255, 255, .58);
}

.log-time {
  color: var(--ink-500);
}

.log-level {
  font-weight: 800;
  color: var(--brand-700);
}

.level-warn .log-level {
  color: #A86600;
}

.level-error .log-level {
  color: var(--danger-600);
}

.log-source {
  color: var(--ink-500);
  font-weight: 700;
}

.log-message {
  min-width: 0;
  color: var(--ink-700);
  overflow-wrap: anywhere;
}

.logs-footer {
  padding: 5px 12px 8px;
  border-top: 1px solid var(--surface-300);
  color: var(--ink-500);
  font-size: 10px;
}

.is-resizing-logs,
.is-resizing-logs * {
  cursor: ns-resize !important;
  user-select: none !important;
}

.is-resizing-logs .logs-drawer {
  transition: none;
}

.is-resizing-rail,
.is-resizing-rail * {
  cursor: ew-resize !important;
  user-select: none !important;
}

/* ------------------------------------------------------------------ */
/* 10. Commenting System                                                */
/* ------------------------------------------------------------------ */

/* Line selection highlight in editor */
.code-line.selected {
  background: var(--brand-50);
}

.code-line.selected .line-number {
  background: var(--brand-100);
  color: var(--brand-800);
}

/* Lines that have attached comments get a left border accent */
.code-line.commented {
  border-left: 2px solid var(--warning-700);
  padding-left: 0;
}

.code-line.commented .line-number {
  color: var(--warning-700);
}

/* Right-click context menu for editor lines */
.comment-context-menu {
  position: fixed;
  z-index: 9998;
  min-width: 160px;
  padding: 5px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .98);
  box-shadow: var(--shadow-elevated);
}

.comment-context-menu[hidden] {
  display: none;
}

.comment-context-menu button {
  display: flex;
  width: 100%;
  height: 30px;
  align-items: center;
  padding: 0 9px;
  border-radius: var(--radius-md);
  color: var(--ink-700);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: left;
  gap: 7px;
}

.comment-context-menu button:hover {
  background: var(--brand-50);
  color: var(--brand-900);
}

/* Comments panel in rehearsal-scroll */
.comments-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comments-panel-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 1px dashed var(--surface-300);
  border-radius: var(--radius-xl);
  color: var(--ink-500);
  font-size: var(--text-sm);
  text-align: center;
  padding: 20px;
}

.comments-panel-hint {
  margin-top: 6px;
  color: var(--ink-400);
  font-size: var(--text-xs);
}

/* Comment thread card */
.comment-thread {
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-lg);
  background: var(--surface-0);
  overflow: hidden;
  transition: border-color var(--motion-fast);
}

.comment-thread.is-resolved {
  border-color: var(--surface-200);
  background: var(--surface-50);
  opacity: .72;
}

.comment-thread-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--surface-200);
  background: var(--surface-50);
}

.comment-file-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-pill);
  background: var(--surface-0);
  color: var(--ink-600);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}

.comment-line-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-pill);
  background: var(--brand-50);
  color: var(--brand-800);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.comment-resolved-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--success-100);
  color: var(--success-600);
  font-size: 10px;
  font-weight: 700;
}

/* Main comment body */
.comment-body {
  padding: 10px;
}

.comment-author-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.comment-avatar {
  display: inline-flex;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand-800);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.comment-author {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--ink-700);
}

.comment-time {
  margin-left: auto;
  font-size: 10px;
  color: var(--ink-400);
}

.comment-text {
  font-size: var(--text-sm);
  color: var(--ink-700);
  line-height: 1.45;
}

/* Reply list */
.comment-replies {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--surface-200);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment-reply {
  display: flex;
  gap: 7px;
}

.comment-reply-body {
  flex: 1;
  min-width: 0;
}

.comment-reply-author {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--ink-600);
  margin-bottom: 2px;
}

.comment-reply-text {
  font-size: var(--text-sm);
  color: var(--ink-700);
  line-height: 1.4;
}

/* Thread action bar */
.comment-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--surface-200);
}

.comment-action-btn {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-pill);
  background: var(--surface-0);
  color: var(--ink-600);
  font-size: 10px;
  font-weight: 700;
  gap: 4px;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.comment-action-btn:hover {
  background: var(--surface-100);
  color: var(--ink-800);
}

.comment-action-btn.resolve-btn:hover {
  background: var(--success-50);
  border-color: var(--success-500);
  color: var(--success-600);
}

.comment-action-btn.danger-btn:hover {
  background: var(--danger-50);
  border-color: rgba(231, 76, 60, .28);
  color: var(--danger-600);
}

/* Comment input form in rehearsal panel */
.comment-input-form {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--brand-200);
  border-radius: var(--radius-lg);
  background: var(--brand-50);
}

.comment-input-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.comment-input-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-600);
}

.comment-input-textarea {
  width: 100%;
  min-height: 72px;
  padding: 8px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  color: var(--ink-800);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  resize: vertical;
  transition: border-color var(--motion-fast);
}

.comment-input-textarea:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: var(--shadow-focus);
}

.comment-input-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

/* ------------------------------------------------------------------ */
/* 11. Invocation Form Redesign                                         */
/* ------------------------------------------------------------------ */

.form-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-200);
}

.form-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.form-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-500);
}

/* Invocation target pills showing project + protocol */
.invocation-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.invocation-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-pill);
  background: var(--brand-50);
  color: var(--brand-800);
  font-size: var(--text-xs);
  font-weight: 600;
}

.invocation-pill.pill-protocol {
  border-color: var(--surface-300);
  background: var(--surface-100);
  color: var(--ink-600);
}

/* Collapsible invocation preview */
.invocation-preview {
  margin-top: 8px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.invocation-preview-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 30px;
  padding: 0 10px;
  background: var(--surface-50);
  color: var(--ink-600);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
}

.invocation-preview-toggle:hover {
  background: var(--surface-100);
}

.invocation-preview-body {
  display: none;
  padding: 10px;
  background: var(--editor-dark-bg);
  color: var(--editor-dark-fg);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
  max-height: 200px;
}

.invocation-preview.is-open .invocation-preview-body {
  display: block;
}

.invocation-preview-caret {
  transition: transform var(--motion-fast);
}

.invocation-preview.is-open .invocation-preview-caret {
  transform: rotate(90deg);
}

/* ------------------------------------------------------------------ */
/* 12. In-session LiveKit UI                                            */
/* ------------------------------------------------------------------ */

/* Compact params pills row above visualizer */
.session-params-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.session-param-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-pill);
  background: var(--brand-50);
  color: var(--brand-800);
  font-size: 10px;
  font-weight: 700;
}

/* ------------------------------------------------------------------ */
/* LiveKit-style live session card                                      */
/* Mirrors the AudioConference / VoiceAssistant layout from            */
/* @livekit/components-react and @livekit/agents-ui, adapted to the    */
/* OPUS4.5 light-mode shell.                                           */
/* ------------------------------------------------------------------ */

.live-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-xl);
  background: var(--surface-0);
  box-shadow: var(--shadow-card);
  /* Reset old padding — sections own their own */
  padding: 0;
}

/* Compact session-context strip at top (pills) */
.lk-session-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--surface-150);
  background: var(--surface-50);
}

/* Center column: avatar → name → bars → state label */
.lk-agent-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 20px 16px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-100) 30%, transparent) 0%, transparent 100%);
}

.lk-agent-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand-700);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.lk-agent-name {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-600);
}

/* BarVisualizer: full-width, bars grow from centre baseline */
.lk-bar-visualizer {
  display: flex;
  width: 100%;
  height: 52px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 12px;
}

.lk-voice-bar {
  flex: 1;
  max-width: 7px;
  min-height: 4px;
  border-radius: 4px;
  background: var(--voice-color, var(--brand-500));
  animation: lk-bar-pulse 780ms ease-in-out infinite alternate;
  transform-origin: center;
}

.lk-voice-bar:nth-child(2)  { animation-delay:  80ms; }
.lk-voice-bar:nth-child(3)  { animation-delay: 160ms; }
.lk-voice-bar:nth-child(4)  { animation-delay: 240ms; }
.lk-voice-bar:nth-child(5)  { animation-delay: 310ms; }
.lk-voice-bar:nth-child(6)  { animation-delay: 380ms; }
.lk-voice-bar:nth-child(7)  { animation-delay: 450ms; }
.lk-voice-bar:nth-child(8)  { animation-delay: 380ms; }
.lk-voice-bar:nth-child(9)  { animation-delay: 310ms; }
.lk-voice-bar:nth-child(10) { animation-delay: 240ms; }
.lk-voice-bar:nth-child(11) { animation-delay: 160ms; }

@keyframes lk-bar-pulse {
  from { transform: scaleY(.25); opacity: .55; }
  to   { transform: scaleY(1);   opacity: 1;   }
}

/* State label below bars */
.lk-agent-state {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-500);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Control bar: mic + end, full-width, flush to bottom of agent view */
.lk-control-bar {
  display: flex;
  gap: 8px;
  padding: 10px 14px 12px;
}

.lk-btn {
  flex: 1;
  height: 38px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity var(--motion-fast), background var(--motion-fast);
}

.lk-btn:hover { opacity: .88; }

.lk-btn-secondary {
  border: 1px solid var(--surface-300);
  background: var(--surface-0);
  color: var(--ink-700);
}

.lk-btn-danger {
  border: none;
  background: #e03b3b;
  color: white;
}

/* Transcript area inside live card */
.live-card .transcript {
  flex: 1;
  max-height: 220px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--surface-150);
}

/* ------------------------------------------------------------------ */
/* 13. Post-session Results                                             */
/* ------------------------------------------------------------------ */

/* Session complete header */
.session-complete-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--success-100);
  border-radius: var(--radius-lg);
  background: var(--success-50);
}

.session-complete-header h3 {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--success-600);
}

.session-complete-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--success-500);
  color: #fff;
}

/* Full transcript in post-session view */
.session-transcript-full {
  margin-bottom: 12px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.session-transcript-full-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-bottom: 1px solid var(--surface-200);
  background: var(--surface-50);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.session-transcript-full-body {
  max-height: 260px;
  overflow: auto;
  padding: 8px 0;
}

/* HPI clinical notes card */
.session-hpi-notes {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-lg);
  background: var(--brand-50);
}

.session-hpi-notes-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--brand-800);
  margin-bottom: 8px;
}

.session-hpi-summary {
  font-size: var(--text-sm);
  color: var(--ink-700);
  line-height: 1.5;
  margin-bottom: 8px;
}

.session-hpi-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--brand-100);
}

.session-hpi-section-heading {
  font-size: 10px;
  font-weight: 700;
  color: var(--brand-700);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.session-hpi-section-text {
  font-size: var(--text-sm);
  color: var(--ink-600);
  line-height: 1.4;
}

.session-hpi-disclaimer {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--brand-100);
  font-size: 10px;
  color: var(--brand-700);
  font-style: italic;
}

/* Compact slots grid in post-session view */
.session-slots-section {
  margin-bottom: 12px;
}

.session-slots-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-500);
  margin-bottom: 8px;
}

.session-slots-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* Visualizer fade transition on session end */
.visualizer-card.is-fading {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.live-card--livekit {
  min-height: 356px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.livekit-session-host {
  flex: 1;
  min-height: 248px;
  border: 1px solid var(--ink-200);
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}

.lk-control-bar--footer {
  justify-content: flex-end;
}

.pt-livekit-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  color: #f8fafc;
  background: radial-gradient(circle at 20% 18%, rgba(59, 130, 246, 0.22), transparent 54%), #030712;
}

.pt-livekit-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 10px 0 10px;
}

.pt-livekit-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
  font-size: 10px;
  letter-spacing: .03em;
}

.pt-livekit-visualizer {
  padding: 10px;
  min-height: 124px;
}

.pt-livekit-transcript {
  margin: 0 10px 10px 10px;
  max-height: 150px;
  overflow: auto;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  padding: 8px 0;
}

.pt-livekit-transcript-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  color: #e2e8f0;
}

.pt-livekit-transcript-role {
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #93c5fd;
}

.pt-livekit-transcript-text {
  color: #f8fafc;
  line-height: 1.45;
}

.pt-livekit-transcript-empty {
  margin: 0 10px 10px 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  padding: 12px 0;
  font-size: 12px;
  color: #cbd5e1;
}

.pt-livekit-shell .lk-agent-control-bar {
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  padding: 8px 10px;
  background: rgba(2, 6, 23, 0.75);
}

/* 9. Motion */
@keyframes shell-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.992);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pane-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes voice-pulse {
  from {
    transform: scaleY(.74);
    opacity: .72;
  }
  to {
    transform: scaleY(1.04);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media (max-width: 959px) {
  body {
    overflow: auto;
  }

  .desktop-guard {
    display: flex;
  }

  .app-shell {
    display: none;
  }
}

@media (max-height: 760px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .visualizer-card {
    min-height: 104px;
  }

  .bar-visualizer {
    height: 96px;
  }
}
