/* ═══════════════════════════════════════════════════════════════════════════
   Maya — Ambient Clinical Co-Pilot
   Aesthetic: "Surgical Precision" — obsidian + warm amber instrumentation
   ═══════════════════════════════════════════════════════════════════════════ */

@layer base, layout, components, views, responsive;

/* ── Tokens ──────────────────────────────────────────────────────────────── */

@layer base {
  :root {
    /* Obsidian palette */
    --void:        #06070a;
    --bg:          #0a0b0f;
    --surface:     #111318;
    --surface-up:  #161920;
    --surface-hi:  #1c2029;
    --border:      #232832;
    --border-hi:   #2e3440;

    /* Text */
    --text:        #c8ccd4;
    --text-soft:   #7c8494;
    --text-muted:  #454d5e;

    /* Amber accent (slit-lamp warmth) */
    --amber:       #e5a54b;
    --amber-dim:   #b8863a;
    --amber-glow:  rgba(229,165,75,0.12);
    --amber-ghost: rgba(229,165,75,0.06);

    /* Semantic */
    --green:       #3ecf8e;
    --green-dim:   rgba(62,207,142,0.12);
    --red:         #ef5350;
    --blue:        #56a4fc;
    --yellow:      #facc15;

    --radius:      10px;
    --radius-lg:   14px;
    --mono:        'JetBrains Mono', monospace;
    --sans:        'DM Sans', -apple-system, sans-serif;
    --display:     'Outfit', var(--sans);
  }

  *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 13.5px;
    line-height: 1.55;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
  }

  ::selection { background: var(--amber-glow); color: var(--amber); }

  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

@layer layout {
  .app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }

  .rail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 48px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .main-grid {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  .sidebar-panel {
    width: 272px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--surface);
  }

  .panel-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 14px;
    gap: 2px;
  }

  .content-area {
    flex: 1;
    min-width: 0;
    padding: 24px 28px;
    overflow-y: auto;
    overflow-x: hidden;
    background:
      radial-gradient(ellipse 60% 50% at 70% 0%, rgba(229,165,75,0.02) 0%, transparent 60%),
      var(--bg);
  }
}

/* ── Components ──────────────────────────────────────────────────────────── */

@layer components {

  /* ·· Brand ·· */
  .rail-brand { display: flex; align-items: center; gap: 10px; }

  .brand-mark {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--amber) 0%, #c98a32 100%);
    color: var(--void);
    font-family: var(--display);
    font-weight: 700;
    font-size: 15px;
    display: flex; align-items: center; justify-content: center;
  }

  .brand-name {
    font-family: var(--display);
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    letter-spacing: 0.02em;
  }

  .brand-tag {
    font-size: 10.5px;
    color: var(--text-muted);
    letter-spacing: 0.03em;
  }

  .brand-text { display: flex; flex-direction: column; line-height: 1.2; }

  /* ·· Status chip ·· */
  .status-chip {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--surface-up);
    border: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-soft);
  }

  .status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.4s ease;
  }

  .status-dot.connected {
    background: var(--green);
    box-shadow: 0 0 8px rgba(62,207,142,0.5);
  }

  /* ·· Inputs ·· */
  .input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--sans);
    font-size: 13px;
    padding: 8px 11px;
    transition: border-color 0.2s, box-shadow 0.2s;
  }

  .input:focus {
    outline: none;
    border-color: var(--amber-dim);
    box-shadow: 0 0 0 3px var(--amber-glow);
  }

  .input::placeholder { color: var(--text-muted); }
  .input-mono { font-family: var(--mono); font-size: 13px; text-align: center; letter-spacing: 0.04em; }
  select.input { cursor: pointer; }
  textarea.input { resize: vertical; line-height: 1.65; }

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

  /* ·· Buttons ·· */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 18px;
    border: none; border-radius: var(--radius);
    font-family: var(--sans); font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.2s ease;
    white-space: nowrap;
  }

  .btn-accent {
    background: linear-gradient(135deg, var(--amber) 0%, var(--amber-dim) 100%);
    color: var(--void);
    box-shadow: 0 2px 12px rgba(229,165,75,0.2);
  }
  .btn-accent:hover { box-shadow: 0 4px 20px rgba(229,165,75,0.35); transform: translateY(-1px); }
  .btn-accent:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

  .btn-dim {
    background: var(--surface-hi);
    color: var(--text-soft);
    border: 1px solid var(--border);
  }
  .btn-dim:hover { border-color: var(--border-hi); color: var(--text); }

  .btn-sign {
    background: linear-gradient(135deg, var(--green) 0%, #2ba86e 100%);
    color: #fff; font-weight: 600;
    box-shadow: 0 2px 12px rgba(62,207,142,0.2);
  }
  .btn-sign:hover { box-shadow: 0 4px 20px rgba(62,207,142,0.35); transform: translateY(-1px); }
  .btn-sign:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

  .btn-sm { padding: 6px 14px; font-size: 12px; }
  .btn-block { width: 100%; }

  /* ·· Tiles (cards) ·· */
  .tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }

  .tile-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px 0;
  }

  .tile-label {
    font-family: var(--display);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--amber);
  }

  .tile-body { padding: 12px 16px 16px; }
  .tile-compact .tile-body { padding: 10px 14px 14px; overflow: visible; }
  .tile-compact .tile-header { padding: 10px 14px 0; }
  .tile-fill { display: flex; flex-direction: column; flex: 1; }
  .tile-fill .soap-editor { flex: 1; }

  /* ·· Field groups ·· */
  .field { margin-bottom: 10px; }
  .field:last-child { margin-bottom: 0; }
  .field-label {
    display: block; margin-bottom: 4px;
    font-size: 11px; font-weight: 500;
    color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.06em;
  }
  .unit { color: var(--text-muted); text-transform: none; letter-spacing: normal; }
  .field-pair { display: flex; gap: 10px; }
  .field-pair .field { flex: 1; }

  /* ·· Search ·· */
  .patient-selector { position: relative; }
  .search-row { display: flex; gap: 6px; }

  .search-input-wrap {
    flex: 1; position: relative;
  }

  .search-icon {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none;
  }

  .search-input {
    width: 100%;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font-family: var(--sans); font-size: 13px;
    padding: 8px 10px 8px 32px;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .search-input:focus { outline: none; border-color: var(--amber-dim); box-shadow: 0 0 0 3px var(--amber-glow); }
  .search-input::placeholder { color: var(--text-muted); }

  .add-btn {
    width: 34px; height: 34px;
    border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--bg); color: var(--amber);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.2s;
  }
  .add-btn:hover { border-color: var(--amber-dim); background: var(--amber-ghost); }

  /* ·· Dropdown ·· */
  .dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
    background: var(--surface-up); border: 1px solid var(--border-hi);
    border-radius: var(--radius); max-height: 220px; overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
  }

  .dropdown-item {
    padding: 9px 12px; cursor: pointer;
    font-size: 13px; color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
  }
  .dropdown-item:last-child { border-bottom: none; }
  .dropdown-item:hover { background: var(--amber-ghost); color: var(--amber); }
  .dropdown-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

  /* ·· Inline form ·· */
  .inline-form {
    display: flex; flex-direction: column; gap: 6px;
    padding: 10px; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius);
    animation: slideDown 0.2s ease;
  }

  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* ·· Active patient ·· */
  .active-patient {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px;
    background: var(--amber-ghost);
    border: 1px solid rgba(229,165,75,0.2);
    border-radius: var(--radius);
    animation: slideDown 0.2s ease;
  }

  .ap-info { display: flex; flex-direction: column; gap: 1px; }
  .ap-name { font-weight: 600; font-size: 13px; color: var(--amber); }
  .ap-meta { font-size: 11px; color: var(--text-muted); }
  .ap-actions { display: flex; align-items: center; gap: 4px; }

  .ap-edit {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 4px; display: flex; align-items: center;
    border-radius: 4px; transition: all 0.15s;
  }
  .ap-edit:hover { color: var(--amber); background: var(--amber-ghost); }

  .ap-switch {
    background: none; border: 1px solid var(--border); color: var(--text-muted);
    cursor: pointer; padding: 4px; display: flex; align-items: center;
    border-radius: 4px; transition: all 0.15s;
  }
  .ap-switch:hover { color: var(--amber); border-color: var(--amber-dim); background: var(--amber-ghost); }

  /* ·· Sidebar sections ·· */
  .sb-section { margin-bottom: 12px; }
  .sb-grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .sb-header { margin-bottom: 8px; }
  .sb-label {
    font-family: var(--display);
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--text-muted);
  }
  .sb-footer { margin-top: auto; padding-top: 10px; }

  /* ·· Encounter feed ·· */
  .encounter-feed {
    flex: 1; overflow-y: auto;
    display: flex; flex-direction: column; gap: 4px;
  }

  .enc-card {
    padding: 9px 11px; cursor: pointer;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; transition: all 0.15s;
  }
  .enc-card:hover { border-color: var(--amber-dim); background: var(--amber-ghost); }

  .enc-card.signed  { border-left: 3px solid var(--green); }
  .enc-card.draft   { border-left: 3px solid var(--yellow); }
  .enc-card.review  { border-left: 3px solid var(--blue); }
  .enc-card.in_progress { border-left: 3px solid var(--amber); }

  .ec-top { display: flex; justify-content: space-between; align-items: center; }
  .ec-date { font-family: var(--mono); font-size: 11px; color: var(--amber); font-weight: 500; }
  .ec-status {
    font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em;
    padding: 1px 6px; border-radius: 4px;
    background: var(--surface-hi); color: var(--text-muted);
  }
  .ec-metrics { font-size: 11px; color: var(--text-soft); margin-top: 3px; }
  .ec-note { font-size: 11px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .timeline-empty { color: var(--text-muted); font-size: 12px; text-align: center; padding: 24px 8px; }

  /* ·· Upload zone ·· */
  .drop-zone {
    border: 1.5px dashed var(--border-hi);
    border-radius: var(--radius);
    padding: 20px 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    flex-shrink: 0;
  }
  .drop-zone:hover, .drop-zone.dragover {
    border-color: var(--amber-dim);
    background: var(--amber-ghost);
  }
  .drop-zone-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-muted); }
  .dz-text { font-size: 12px; }
  .dz-sub { font-size: 11px; color: var(--text-muted); }
  .dz-sub u { color: var(--amber); text-decoration: none; }

  .scan-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

  .scan-thumb {
    position: relative; width: 72px; height: 72px;
    border-radius: 8px; overflow: hidden;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
  }
  .scan-thumb:hover { border-color: var(--amber-dim); }
  .scan-thumb img { width: 100%; height: 100%; object-fit: cover; }

  .remove-scan {
    position: absolute; top: 3px; right: 3px;
    background: rgba(0,0,0,0.75); color: #fff;
    border: none; border-radius: 50%;
    width: 16px; height: 16px; font-size: 10px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s;
  }
  .scan-thumb:hover .remove-scan { opacity: 1; }

  /* Scan analysis cards */
  .scan-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 8px;
    min-width: 0;
  }

  .scan-card-top {
    display: flex;
    gap: 12px;
    padding: 10px;
    position: relative;
    min-width: 0;
    overflow: hidden;
  }

  .scan-card-top .scan-thumb {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    position: relative;
  }

  .scan-type-badge {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.75);
    color: var(--amber);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .scan-card-top .remove-scan {
    position: absolute;
    top: -4px;
    right: -4px;
    opacity: 1;
    background: var(--surface-hi);
    color: var(--text-soft);
    width: 20px;
    height: 20px;
    font-size: 12px;
    border: 1px solid var(--border);
    z-index: 2;
  }
  .scan-card-top .remove-scan:hover { color: var(--red); border-color: var(--red); }

  .scan-analysis {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-soft);
    overflow-y: auto;
    max-height: 120px;
  }

  .scan-findings {
    white-space: pre-wrap;
    word-break: break-word;
  }

  .scan-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--amber);
    font-size: 12px;
    padding-top: 4px;
  }

  .scan-pending {
    color: var(--text-muted);
    font-style: italic;
  }

  .scan-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* ·· Action bar ·· */
  .action-bar { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
}

/* ── Views ────────────────────────────────────────────────────────────────── */

@layer views {

  /* ·· Empty ·· */
  .empty-well {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 100%; gap: 12px; opacity: 0.6;
  }
  .empty-glyph { color: var(--text-muted); }
  .empty-text { font-family: var(--display); font-size: 15px; color: var(--text-soft); }
  .empty-sub { font-size: 12px; color: var(--text-muted); }

  /* ·· View header ·· */
  .view-top {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
  }
  .view-title-group { display: flex; align-items: center; gap: 10px; }

  .back-btn {
    width: 32px; height: 32px;
    border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-soft);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
  }
  .back-btn:hover { border-color: var(--amber-dim); color: var(--amber); background: var(--amber-ghost); }

  .view-title {
    font-family: var(--display);
    font-size: 18px; font-weight: 600; color: var(--text);
    letter-spacing: -0.01em;
  }
  .view-badge {
    font-family: var(--mono);
    font-size: 11px; color: var(--amber);
    padding: 3px 10px;
    background: var(--amber-ghost);
    border: 1px solid rgba(229,165,75,0.15);
    border-radius: 6px;
  }

  /* ·· Pre-exam ·· */
  .two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    height: calc(100vh - 200px);
    min-height: 400px;
  }

  .two-col > .tile {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .two-col > .tile > .tile-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
  }

  .field-grow {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .textarea-grow {
    flex: 1;
    min-height: 60px;
    resize: none;
  }

  /* ·· Exam room ·· */
  .exam-shell { display: flex; flex-direction: column; height: calc(100vh - 200px); gap: 16px; }

  .transcript-well {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }

  .transcript-label {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 16px;
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
  }

  .transcript-scroll {
    flex: 1; overflow-y: auto;
    padding: 16px;
    font-size: 14px; line-height: 1.8;
    white-space: pre-wrap;
    color: var(--text);
  }

  .transcript-placeholder {
    color: var(--text-muted); font-style: italic;
    text-align: center; margin-top: 60px;
    font-size: 13px;
  }

  .mic-dock {
    display: flex; align-items: center; justify-content: center;
    gap: 14px; flex-shrink: 0; padding: 4px 0;
  }

  .mic-orb {
    width: 60px; height: 60px;
    border-radius: 50%;
    border: 2px solid var(--amber-dim);
    background: var(--surface);
    color: var(--amber);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    transition: all 0.3s ease;
  }
  .mic-orb:hover { background: var(--amber-ghost); }

  .mic-ring {
    position: absolute; inset: -6px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: border-color 0.3s;
  }

  .mic-orb.active {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
  }
  .mic-orb.active .mic-ring {
    border-color: rgba(239,83,80,0.3);
    animation: mic-pulse 1.8s ease-in-out infinite;
  }

  @keyframes mic-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0; }
  }

  .mic-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.04em; }

  /* Scan reference strip in exam room */
  .exam-scans-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-shrink: 0;
    overflow-x: auto;
  }

  .strip-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    flex-shrink: 0;
  }

  .strip-thumbs {
    display: flex;
    gap: 6px;
  }

  .strip-thumb {
    width: 48px; height: 48px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
    cursor: pointer;
    transition: border-color 0.15s;
  }
  .strip-thumb:hover { border-color: var(--amber-dim); }
  .strip-thumb img { width: 100%; height: 100%; object-fit: cover; }

  /* ·· Review ·· */
  .review-split {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 16px;
    height: calc(100vh - 160px);
    min-height: 400px;
  }

  .review-evidence {
    display: flex; flex-direction: column; gap: 10px;
    overflow-y: auto;
    padding-right: 4px;
  }

  .review-note { display: flex; flex-direction: column; min-height: 0; }

  .metrics-readout,
  .transcript-readout,
  .review-scan-detail {
    font-size: 12.5px;
    line-height: 1.75;
    font-family: var(--sans);
    color: var(--text-soft);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .metrics-readout strong {
    color: var(--amber);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
  .metrics-readout div { padding: 2px 0; }

  /* Review scan thumbnails + detail */
  .review-thumbs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
  }

  .review-thumb {
    width: 64px; height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: border-color 0.2s;
    flex-shrink: 0;
  }
  .review-thumb img { width: 100%; height: 100%; object-fit: cover; }
  .review-thumb:hover { border-color: var(--amber-dim); }
  .review-thumb.active { border-color: var(--amber); box-shadow: 0 0 8px var(--amber-glow); }

  .review-scan-detail {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .scan-detail-text {
    white-space: pre-wrap;
    word-break: break-word;
  }

  /* Signed note & addendums */
  .signed-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-top: 8px;
    background: var(--green-dim);
    border: 1px solid rgba(62,207,142,0.2);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--green);
  }

  .soap-editor[readonly] {
    opacity: 0.7;
    cursor: not-allowed;
    border-color: var(--border);
  }
  .soap-editor[readonly]:focus {
    border-color: var(--border);
    box-shadow: none;
  }

  .addendums-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .addendum-item {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--amber);
    border-radius: var(--radius);
    font-size: 12.5px;
    line-height: 1.65;
  }

  .addendum-timestamp {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--mono);
    margin-bottom: 4px;
  }

  .addendum-body {
    color: var(--text);
    white-space: pre-wrap;
  }

  .addendum-section {
    margin-top: 10px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .addendum-input {
    min-height: 60px;
    font-size: 12.5px;
  }

  .post-sign-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
    padding: 12px;
    background: var(--surface-up);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .soap-editor {
    width: 100%; flex: 1;
    min-height: 400px;
    max-height: calc(100vh - 260px);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--sans);
    font-size: 12.5px;
    line-height: 1.75;
    padding: 14px 16px;
    resize: vertical;
    overflow-y: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .soap-editor:focus { outline: none; border-color: var(--amber-dim); box-shadow: 0 0 0 3px var(--amber-glow); }
  .soap-editor::placeholder { color: var(--text-muted); }

  .gen-indicator {
    display: flex; align-items: center; gap: 7px;
    font-size: 11px; color: var(--amber);
  }

  .gen-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--amber);
    animation: gen-blink 1s ease-in-out infinite;
  }

  @keyframes gen-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
  }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@layer responsive {
  @media (max-width: 960px) {
    .two-col { grid-template-columns: 1fr; }
    .review-split { grid-template-columns: 1fr; height: auto; }
    .sidebar-panel { width: 240px; }
  }

  @media (max-width: 768px) {
    .main-grid { flex-direction: column; }
    .sidebar-panel {
      width: 100%; max-height: 220px;
      border-right: none; border-bottom: 1px solid var(--border);
    }
    .brand-tag { display: none; }
    .content-area { padding: 16px; }
    .exam-shell { height: calc(100vh - 280px); }
    .review-split { height: auto; }

    /* Tablet-optimized mic */
    .mic-orb { width: 80px; height: 80px; }
    .mic-orb svg { width: 36px; height: 36px; }
    .mic-ring { inset: -8px; }
    .mic-dock { padding: 8px 0; }
  }
}
