/* PublishPath app UI — uses design-tokens.css + legacy-bridge.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    /* ── App header (SpeechGradebook pattern, rebranded) ── */
    .app-header {
      background: var(--primary-dark);
      border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    .header-content {
      max-width: 1440px;
      margin: 0 auto;
      padding: 0 20px;
      height: 56px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
    }
    .header-left { display: flex; align-items: center; gap: 24px; }
    .logo-section { display: flex; align-items: center; gap: 10px; }
    .logo-mark {
      width: 32px;
      height: 32px;
      background: rgba(255,255,255,0.1);
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--accent);
    }
    .app-title h1 {
      font-size: 1rem;
      font-weight: 700;
      color: #fff;
      letter-spacing: -0.01em;
    }
    .primary-nav { display: flex; gap: 4px; }
    .nav-link {
      padding: 7px 14px;
      border-radius: 9999px;
      font-size: 0.82rem;
      font-weight: 500;
      color: rgba(255,255,255,0.65);
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
    }
    .nav-link.active { background: rgba(255,255,255,0.12); color: #fff; }
    .header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
    .workspace-select-label {
      font-size: 12px;
      color: rgba(255,255,255,0.72);
      margin: 0;
    }
    .workspace-select {
      max-width: 180px;
      padding: 6px 10px;
      border-radius: 8px;
      border: 1px solid rgba(255,255,255,0.18);
      background: rgba(255,255,255,0.08);
      color: #fff;
      font-size: 13px;
    }
    .workspace-select.hidden,
    .workspace-select-label.hidden { display: none; }

    /* Account menu — matches SpeechGradebook header icons */
    .account-dropdown-wrapper { position: relative; }
    .account-dropdown-trigger {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 2.75rem;
      height: 2.75rem;
      background: transparent;
      border: none;
      color: white;
      cursor: pointer;
      border-radius: var(--radius-md, 8px);
      transition: background 150ms ease;
      flex-shrink: 0;
    }
    .account-dropdown-trigger:hover { background: rgba(255,255,255,0.12); }
    .account-dropdown-trigger:focus-visible {
      outline: 2px solid white;
      outline-offset: 2px;
    }
    .account-dropdown-trigger[aria-expanded="true"] { background: rgba(255,255,255,0.18); }
    .account-icon { width: 1.25rem; height: 1.25rem; }
    .account-dropdown-menu {
      position: absolute;
      top: calc(100% + 4px);
      right: 0;
      min-width: 220px;
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: var(--radius-md, 8px);
      box-shadow: var(--elevation-3, 0 8px 24px rgba(0,0,0,0.12));
      z-index: 1000;
      padding: 4px 0;
    }
    .account-dropdown-menu.hidden { display: none; }
    .dropdown-header {
      padding: 10px 16px;
      border-bottom: 1px solid var(--border);
      margin-bottom: 4px;
    }
    .dropdown-user-name {
      font-size: 0.875rem;
      font-weight: 600;
      color: var(--text);
      display: block;
    }
    .dropdown-user-role {
      display: block;
      margin-top: 2px;
      font-size: 0.75rem;
      color: var(--text-light);
    }
    .dropdown-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px 16px;
      color: var(--text);
      text-decoration: none;
      font-size: 0.9375rem;
      transition: background 150ms ease;
      cursor: pointer;
    }
    .dropdown-item:hover { background: var(--bg-alt); }
    .dropdown-item i, .dropdown-item svg { width: 1rem; height: 1rem; color: var(--text-light); }
    .dropdown-item-logout { font-weight: 500; }
    .dropdown-divider {
      height: 1px;
      background: var(--border);
      margin: 4px 0;
    }

    .icon-btn {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: rgba(255,255,255,0.08);
      border: none;
      color: rgba(255,255,255,0.7);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      position: relative;
    }
    .badge-dot {
      position: absolute;
      top: 6px; right: 6px;
      width: 8px; height: 8px;
      background: var(--accent);
      border-radius: 50%;
      border: 2px solid var(--primary-dark);
    }

    /* ── Main content ── */
    .main-content {
      flex: 1;
      max-width: 1440px;
      margin: 0 auto;
      width: 100%;
      padding: 20px 24px 40px;
    }

    .card {
      background: var(--card);
      border: 1px solid var(--border-light);
      border-radius: 12px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.05);
      overflow: hidden;
    }
    .card-header {
      padding: 16px 20px;
      border-bottom: 1px solid var(--border-light);
      font-size: 1.05rem;
      font-weight: 600;
      color: var(--primary);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    /* Progress steps */
    .progress-steps {
      display: flex;
      justify-content: center;
      gap: 0;
      padding: 20px 20px 0;
      border-bottom: 1px solid var(--border-light);
      margin-bottom: 0;
    }
    .step {
      display: flex;
      flex-direction: column;
      align-items: center;
      flex: 1;
      max-width: 140px;
      position: relative;
      padding-bottom: 16px;
    }
    .step:not(:last-child)::after {
      content: '';
      position: absolute;
      top: 14px;
      left: calc(50% + 18px);
      width: calc(100% - 36px);
      height: 2px;
      background: var(--border-light);
    }
    .step.done:not(:last-child)::after,
    .step.active:not(:last-child)::after { background: var(--accent); }
    .step-circle {
      width: 28px; height: 28px;
      border-radius: 50%;
      background: var(--bg-alt);
      border: 2px solid var(--border);
      display: flex; align-items: center; justify-content: center;
      font-size: 0.75rem; font-weight: 600;
      color: var(--text-light);
      position: relative; z-index: 1;
    }
    .step.done .step-circle,
    .step.active .step-circle {
      background: var(--primary);
      border-color: var(--primary);
      color: #fff;
    }
    .step-label {
      margin-top: 6px;
      font-size: 0.72rem;
      font-weight: 500;
      color: var(--text-light);
      text-align: center;
    }
    .step.active .step-label { color: var(--primary); font-weight: 600; }

    /* Summary strip */
    .summary-card {
      margin: 20px;
      padding: 16px 20px;
      background: linear-gradient(135deg, rgba(30,58,95,0.05) 0%, rgba(30,58,95,0.02) 100%);
      border: 1px solid var(--border-light);
      border-radius: 12px;
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
      gap: 16px;
    }
    .summary-item label {
      display: block;
      font-size: 0.68rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--text-light);
      margin-bottom: 4px;
    }
    .summary-item span { font-size: 0.9rem; font-weight: 500; color: var(--text); }
    .status-pill {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 3px 10px;
      border-radius: 9999px;
      font-size: 0.78rem;
      font-weight: 600;
      background: var(--warning-bg);
      color: #92400e;
    }

    /* Split review layout */
    .review-layout {
      display: grid;
      grid-template-columns: minmax(340px, 400px) 1fr;
      gap: 0;
      min-height: 640px;
      border-top: 1px solid var(--border-light);
    }
    @media (max-width: 960px) {
      .review-layout { grid-template-columns: 1fr; }
    }

    .media-panel {
      border-right: 1px solid var(--border-light);
      background: var(--bg-alt);
      display: flex;
      flex-direction: column;
    }
    .media-panel-header {
      padding: 14px 16px;
      border-bottom: 1px solid var(--border-light);
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: var(--card);
    }
    .media-panel-header h3 {
      font-size: 0.85rem;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .loom-badge {
      font-size: 0.68rem;
      font-weight: 600;
      padding: 2px 8px;
      border-radius: 9999px;
      background: #6221ea18;
      color: #6221ea;
    }
    .video-wrap {
      padding: 16px;
      background: #000;
      position: relative;
    }
    .video-wrap video,
    .video-placeholder {
      width: 100%;
      aspect-ratio: 16/9;
      background: #1a1a1a;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: rgba(255,255,255,0.5);
      font-size: 0.85rem;
      position: relative;
      overflow: hidden;
    }
    .video-time-overlay {
      position: absolute;
      bottom: 10px;
      left: 10px;
      background: rgba(0,0,0,0.75);
      color: #fff;
      font-size: 0.78rem;
      font-weight: 600;
      padding: 4px 10px;
      border-radius: 6px;
      font-variant-numeric: tabular-nums;
    }
    .seek-hint {
      position: absolute;
      top: 10px;
      right: 10px;
      background: rgba(232,168,56,0.95);
      color: #1a1a1a;
      font-size: 0.72rem;
      font-weight: 600;
      padding: 5px 10px;
      border-radius: 6px;
      display: none;
    }
    .video-wrap.seeking .seek-hint { display: block; }

    .screenshot-slots {
      flex: 1;
      padding: 12px 16px 16px;
      overflow-y: auto;
    }
    .slots-label {
      font-size: 0.68rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--text-light);
      margin-bottom: 10px;
      display: flex;
      justify-content: space-between;
    }
    .slot-card {
      background: var(--card);
      border: 1.5px solid var(--border-light);
      border-radius: 10px;
      padding: 12px;
      margin-bottom: 8px;
      cursor: pointer;
      transition: all 150ms ease;
    }
    .slot-card:hover { border-color: var(--accent); }
    .slot-card.active {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(232,168,56,0.2);
      background: #fffdf8;
    }
    .slot-card.resolved { border-color: var(--success); opacity: 0.85; }
    .slot-time {
      font-size: 0.75rem;
      font-weight: 700;
      color: var(--accent-dark);
      font-variant-numeric: tabular-nums;
    }
    .slot-desc {
      font-size: 0.8rem;
      color: var(--text-secondary);
      margin-top: 4px;
      line-height: 1.4;
    }
    .slot-status {
      font-size: 0.68rem;
      font-weight: 600;
      margin-top: 6px;
      display: flex;
      align-items: center;
      gap: 4px;
    }
    .slot-status.pending { color: var(--warning); }
    .slot-status.resolved { color: var(--success); }
    .slot-status.active { color: var(--accent-dark); }

    .capture-bar {
      padding: 12px 16px;
      border-top: 1px solid var(--border-light);
      background: var(--card);
      display: none;
      flex-direction: column;
      gap: 8px;
    }
    .capture-bar.visible { display: flex; }
    .capture-bar p {
      font-size: 0.78rem;
      color: var(--text-secondary);
      line-height: 1.4;
    }
    .capture-actions { display: flex; gap: 8px; }
    .btn {
      padding: 8px 14px;
      border-radius: 8px;
      font-size: 0.8rem;
      font-weight: 600;
      border: none;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-family: var(--font);
    }
    .btn-primary { background: var(--primary); color: #fff; }
    .btn-primary:hover { background: var(--primary-light); }
    .btn-accent { background: var(--accent); color: #1a1a1a; }
    .btn-outline {
      background: transparent;
      border: 1.5px solid var(--border);
      color: var(--text-secondary);
    }

    /* Document panel */
    .doc-panel {
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
    .doc-toolbar {
      padding: 10px 16px;
      border-bottom: 1px solid var(--border-light);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
      background: var(--card);
    }
    .doc-toolbar-left { display: flex; gap: 6px; align-items: center; }
    .toolbar-chip {
      padding: 5px 10px;
      border-radius: 6px;
      font-size: 0.75rem;
      font-weight: 500;
      background: var(--bg-alt);
      border: 1px solid var(--border-light);
      color: var(--text-secondary);
      cursor: pointer;
    }
    .toolbar-chip.active {
      background: rgba(30,58,95,0.08);
      border-color: var(--primary);
      color: var(--primary);
    }
    .training-chip {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 4px 10px;
      border-radius: 9999px;
      font-size: 0.68rem;
      font-weight: 500;
      color: var(--info);
      background: var(--info-bg);
      border: 1px solid rgba(2,132,199,0.2);
      cursor: help;
    }
    .doc-body {
      flex: 1;
      padding: 24px 28px;
      overflow-y: auto;
      line-height: 1.65;
      font-size: 0.92rem;
      color: var(--text);
    }
    .doc-body h2 {
      font-size: 1.35rem;
      font-weight: 700;
      color: var(--primary);
      margin-bottom: 12px;
      letter-spacing: -0.02em;
    }
    .doc-body h3 {
      font-size: 1rem;
      font-weight: 600;
      color: var(--primary);
      margin: 20px 0 8px;
    }
    .doc-body p { margin-bottom: 12px; color: var(--text-secondary); }
    .doc-body ol, .doc-body ul { margin: 0 0 12px 20px; color: var(--text-secondary); }
    .doc-body li { margin-bottom: 6px; }

    .screenshot-placeholder {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 14px 16px;
      margin: 12px 0;
      border: 2px dashed var(--accent);
      border-radius: 10px;
      background: rgba(232,168,56,0.06);
      cursor: pointer;
      transition: all 150ms ease;
    }
    .screenshot-placeholder:hover,
    .screenshot-placeholder.highlight {
      background: rgba(232,168,56,0.14);
      box-shadow: 0 0 0 3px rgba(232,168,56,0.15);
    }
    .screenshot-placeholder.resolved {
      border-style: solid;
      border-color: var(--success);
      background: var(--success-bg);
      padding: 0;
      overflow: hidden;
      flex-direction: column;
      align-items: stretch;
    }
    .placeholder-icon {
      width: 40px; height: 40px;
      border-radius: 8px;
      background: rgba(232,168,56,0.2);
      display: flex; align-items: center; justify-content: center;
      color: var(--accent-dark);
      flex-shrink: 0;
    }
    .placeholder-text strong {
      display: block;
      font-size: 0.82rem;
      color: var(--accent-dark);
      margin-bottom: 2px;
    }
    .placeholder-text span { font-size: 0.78rem; color: var(--text-light); }
    .resolved-img {
      width: 100%;
      height: 160px;
      background: linear-gradient(135deg, #e8ecf0, #d1d5db);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-light);
      font-size: 0.8rem;
    }
    .resolved-caption {
      padding: 8px 12px;
      font-size: 0.78rem;
      color: var(--text-secondary);
      border-top: 1px solid rgba(5,150,105,0.2);
    }

    .doc-meta-bar {
      padding: 12px 16px;
      border-top: 1px solid var(--border-light);
      background: var(--bg-alt);
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
    }
    .tag {
      padding: 4px 10px;
      border-radius: 9999px;
      font-size: 0.72rem;
      font-weight: 600;
      background: var(--card);
      border: 1px solid var(--border-light);
      color: var(--text-secondary);
    }
    .tag.dest { background: rgba(30,58,95,0.08); border-color: rgba(30,58,95,0.2); color: var(--primary); }

    .action-bar {
      padding: 14px 20px;
      border-top: 1px solid var(--border-light);
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      gap: 10px;
      background: var(--card);
    }
    .action-bar-group {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 10px;
    }
    .review-action-bar .action-bar-primary {
      margin-left: auto;
    }

    /* Template selection screen */
    .step-content { padding: 24px 28px 32px; }
    .form-group { margin-bottom: 20px; }
    .form-group label {
      display: block;
      font-size: 0.85rem;
      font-weight: 600;
      color: var(--text);
      margin-bottom: 6px;
    }
    .form-group input,
    .form-group textarea,
    .form-group select {
      width: 100%;
      padding: 10px 12px;
      border: 2px solid var(--border-light);
      border-radius: 8px;
      font-size: 0.9rem;
      font-family: var(--font);
      color: var(--text);
    }
    .form-group textarea { min-height: 80px; resize: vertical; }
    .field-hint { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; }

    .template-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
      gap: 12px;
    }
    .template-card {
      border: 2px solid var(--border-light);
      border-radius: 10px;
      padding: 16px;
      cursor: pointer;
      transition: all 150ms ease;
      background: var(--card);
    }
    .template-card:hover { border-color: var(--primary-light); }
    .template-card.selected {
      border-color: var(--primary);
      background: rgba(30,58,95,0.04);
      box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
    }
    .template-card .tpl-icon {
      width: 36px; height: 36px;
      border-radius: 8px;
      background: var(--bg-alt);
      display: flex; align-items: center; justify-content: center;
      color: var(--primary);
      margin-bottom: 10px;
    }
    .template-card h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
    .template-card p { font-size: 0.78rem; color: var(--text-light); line-height: 1.4; }

    .upload-loom {
      border: 2px dashed var(--border);
      border-radius: 10px;
      padding: 24px;
      text-align: center;
      background: var(--bg-alt);
      margin-bottom: 20px;
    }
    .upload-loom.connected {
      border-color: #6221ea;
      background: #6221ea08;
      text-align: left;
      display: flex;
      align-items: center;
      gap: 14px;
    }

    .source-tabs {
      display: flex;
      gap: 8px;
      margin-bottom: 16px;
      flex-wrap: wrap;
    }
    .source-tab {
      padding: 8px 16px;
      border-radius: 9999px;
      font-size: 0.8rem;
      font-weight: 600;
      border: 1.5px solid var(--border-light);
      background: var(--card);
      color: var(--text-secondary);
      cursor: pointer;
    }
    .source-tab.active {
      border-color: var(--primary);
      background: rgba(30,58,95,0.06);
      color: var(--primary);
    }
    .source-panel { display: none; }
    .source-panel.active { display: block; }

    /* Hub search screen */
    .hub-search-row {
      display: flex;
      gap: 10px;
      margin-bottom: 16px;
      flex-wrap: wrap;
    }
    .hub-search-input {
      flex: 1;
      min-width: 240px;
      padding: 10px 14px 10px 40px;
      border: 1px solid var(--border-light);
      border-radius: 8px;
      font-size: 0.9rem;
      background: var(--card);
      box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    .hub-search-wrap { position: relative; flex: 1; min-width: 240px; }
    .hub-search-wrap i {
      position: absolute;
      left: 12px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-light);
      width: 16px; height: 16px;
    }
    .filter-chip {
      padding: 8px 14px;
      border-radius: 8px;
      border: 1px solid var(--border-light);
      background: var(--card);
      font-size: 0.8rem;
      font-weight: 500;
      color: var(--text-secondary);
      cursor: pointer;
    }
    .filter-chip.active {
      background: var(--primary);
      border-color: var(--primary);
      color: #fff;
    }
    .results-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
    .results-table th {
      text-align: left;
      padding: 10px 16px;
      font-size: 0.68rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-light);
      border-bottom: 1px solid var(--border-light);
      background: var(--bg-alt);
    }
    .results-table td {
      padding: 12px 16px;
      border-bottom: 1px solid var(--border-light);
      vertical-align: middle;
    }
    .results-table tr:hover td { background: var(--bg-alt); }
    .results-table tr[data-go] { cursor: pointer; }
    .results-table .title-cell { font-weight: 600; color: var(--primary); }

    /* Settings — AI configuration (admin) */
    .settings-layout {
      display: grid;
      grid-template-columns: 200px 1fr;
      min-height: 520px;
    }
    @media (max-width: 768px) {
      .settings-layout { grid-template-columns: 1fr; }
    }
    .settings-sidebar {
      border-right: 1px solid var(--border-light);
      padding: 16px 12px;
      background: var(--bg-alt);
    }
    .settings-sidebar h4 {
      font-size: 0.68rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--text-light);
      padding: 0 8px 8px;
    }
    .settings-nav-item {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%;
      padding: 9px 10px;
      border: none;
      border-radius: 8px;
      background: transparent;
      font-size: 0.82rem;
      font-weight: 500;
      color: var(--text-secondary);
      cursor: pointer;
      text-align: left;
      font-family: var(--font);
    }
    .settings-nav-item.active {
      background: var(--card);
      color: var(--primary);
      font-weight: 600;
      box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }
    .settings-nav-item.admin-only::after {
      content: 'Admin';
      margin-left: auto;
      font-size: 0.62rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--accent-dark);
      background: rgba(232,168,56,0.15);
      padding: 2px 6px;
      border-radius: 9999px;
    }
    .settings-panel { padding: 24px 28px 32px; }
    .settings-panel h2 {
      font-size: 1.15rem;
      font-weight: 700;
      color: var(--primary);
      margin-bottom: 4px;
    }
    .settings-panel .subtitle {
      font-size: 0.85rem;
      color: var(--text-light);
      margin-bottom: 20px;
      line-height: 1.5;
    }
    .info-callout {
      display: flex;
      gap: 12px;
      padding: 14px 16px;
      border-radius: 10px;
      background: var(--info-bg);
      border: 1px solid rgba(2,132,199,0.2);
      margin-bottom: 20px;
      font-size: 0.82rem;
      color: var(--text-secondary);
      line-height: 1.5;
    }
    .info-callout strong { color: var(--primary); }
    .provider-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
      gap: 10px;
      margin-bottom: 20px;
    }
    .provider-card {
      border: 2px solid var(--border-light);
      border-radius: 10px;
      padding: 14px 12px;
      text-align: center;
      cursor: pointer;
      background: var(--card);
      transition: all 150ms ease;
    }
    .provider-card:hover { border-color: var(--primary-light); }
    .provider-card.selected {
      border-color: var(--primary);
      background: rgba(30,58,95,0.04);
      box-shadow: 0 0 0 3px rgba(30,58,95,0.08);
    }
    .provider-card .provider-name {
      font-size: 0.78rem;
      font-weight: 600;
      color: var(--text);
      margin-top: 8px;
    }
    .provider-card .provider-sub {
      font-size: 0.68rem;
      color: var(--text-light);
      margin-top: 2px;
    }
    .settings-section {
      background: var(--bg-alt);
      border: 1px solid var(--border-light);
      border-radius: 10px;
      padding: 16px 18px;
      margin-bottom: 16px;
    }
    .settings-section h3 {
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--primary);
      margin-bottom: 12px;
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .form-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 14px;
    }
    @media (max-width: 640px) {
      .form-row { grid-template-columns: 1fr; }
    }
    .key-input-wrap {
      position: relative;
    }
    .key-input-wrap input { padding-right: 80px; font-family: monospace; font-size: 0.82rem; }
    .key-mask-btn {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      border: none;
      background: var(--bg-alt);
      padding: 4px 8px;
      border-radius: 6px;
      font-size: 0.72rem;
      font-weight: 600;
      color: var(--text-light);
      cursor: pointer;
    }
    .connection-status {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 0.78rem;
      font-weight: 600;
      padding: 6px 12px;
      border-radius: 9999px;
      margin-top: 12px;
    }
    .connection-status.ok {
      background: var(--success-bg);
      color: #065f46;
    }
    .usage-mini {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      margin-top: 16px;
    }
    .usage-mini .stat {
      background: var(--card);
      border: 1px solid var(--border-light);
      border-radius: 8px;
      padding: 12px;
      text-align: center;
    }
    .usage-mini .stat-val {
      font-size: 1.25rem;
      font-weight: 700;
      color: var(--primary);
    }
    .usage-mini .stat-lbl {
      font-size: 0.68rem;
      color: var(--text-light);
      margin-top: 2px;
    }

    /* Dashboard */
    .dash-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 16px;
      margin-bottom: 20px;
      flex-wrap: wrap;
    }
    .dash-header h2 {
      font-size: 1.35rem;
      font-weight: 700;
      color: var(--primary);
      letter-spacing: -0.02em;
      margin-bottom: 4px;
    }
    .dash-header p {
      font-size: 0.88rem;
      color: var(--text-light);
    }
    .role-toggle {
      display: flex;
      background: var(--card);
      border: 1px solid var(--border-light);
      border-radius: 9999px;
      padding: 3px;
      gap: 2px;
    }
    .role-toggle button {
      padding: 6px 14px;
      border: none;
      border-radius: 9999px;
      font-size: 0.75rem;
      font-weight: 600;
      cursor: pointer;
      background: transparent;
      color: var(--text-light);
      font-family: var(--font);
    }
    .role-toggle button.active {
      background: var(--primary);
      color: #fff;
    }
    .stat-row {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      gap: 12px;
      margin-bottom: 20px;
    }
    @media (max-width: 1100px) {
      .stat-row { grid-template-columns: repeat(3, 1fr); }
    }
    @media (max-width: 640px) {
      .stat-row { grid-template-columns: repeat(2, 1fr); }
    }
    .stat-card {
      background: var(--card);
      border: 1px solid var(--border-light);
      border-radius: 10px;
      padding: 14px 16px;
      cursor: pointer;
      transition: all 150ms ease;
      box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    .stat-card:hover {
      border-color: var(--accent);
      box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }
    .stat-card.highlight {
      border-color: var(--accent);
      background: #fffdf8;
    }
    .stat-card .stat-num {
      font-size: 1.75rem;
      font-weight: 700;
      color: var(--primary);
      line-height: 1;
    }
    .stat-card .stat-num.warn { color: var(--warning); }
    .stat-card .stat-label {
      font-size: 0.72rem;
      font-weight: 600;
      color: var(--text-light);
      margin-top: 6px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .dash-grid {
      display: grid;
      grid-template-columns: 1.4fr 1fr;
      gap: 16px;
    }
    @media (max-width: 960px) {
      .dash-grid { grid-template-columns: 1fr; }
    }
    .dash-panel {
      background: var(--card);
      border: 1px solid var(--border-light);
      border-radius: 12px;
      overflow: hidden;
      box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    .dash-panel-header {
      padding: 14px 18px;
      border-bottom: 1px solid var(--border-light);
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
    }
    .dash-panel-header h3 {
      font-size: 0.88rem;
      font-weight: 600;
      color: var(--primary);
      display: flex;
      align-items: center;
      gap: 7px;
    }
    .dash-panel-header a {
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--accent-dark);
      text-decoration: none;
    }
    .queue-list { list-style: none; }
    .queue-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 18px;
      border-bottom: 1px solid var(--border-light);
      cursor: pointer;
      transition: background 150ms ease;
    }
    .queue-item:last-child { border-bottom: none; }
    .queue-item:hover { background: var(--bg-alt); }
    .queue-item-main { flex: 1; min-width: 0; }
    .queue-item-title {
      font-size: 0.85rem;
      font-weight: 600;
      color: var(--primary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .queue-item-meta {
      font-size: 0.75rem;
      color: var(--text-light);
      margin-top: 2px;
    }
    .queue-item-age {
      font-size: 0.72rem;
      font-weight: 600;
      color: var(--warning);
      white-space: nowrap;
    }
    .activity-item {
      padding: 10px 18px;
      border-bottom: 1px solid var(--border-light);
      font-size: 0.8rem;
      color: var(--text-secondary);
      line-height: 1.45;
    }
    .activity-item:last-child { border-bottom: none; }
    .activity-item time {
      display: block;
      font-size: 0.68rem;
      color: var(--text-light);
      margin-top: 3px;
    }
    .activity-item strong { color: var(--text); font-weight: 600; }
    .schedule-item {
      display: flex;
      gap: 12px;
      padding: 12px 18px;
      border-bottom: 1px solid var(--border-light);
      align-items: flex-start;
    }
    .schedule-item:last-child { border-bottom: none; }
    .schedule-date {
      flex-shrink: 0;
      width: 44px;
      text-align: center;
      background: var(--bg-alt);
      border-radius: 8px;
      padding: 6px 4px;
    }
    .schedule-date .day {
      font-size: 1rem;
      font-weight: 700;
      color: var(--primary);
      line-height: 1;
    }
    .schedule-date .mon {
      font-size: 0.62rem;
      font-weight: 600;
      color: var(--text-light);
      text-transform: uppercase;
    }
    .schedule-body { flex: 1; min-width: 0; }
    .schedule-title {
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--text);
    }
    .schedule-dest {
      font-size: 0.72rem;
      color: var(--text-light);
      margin-top: 2px;
    }
    .quick-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }
    .sme-hero {
      background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
      border-radius: 12px;
      padding: 28px 32px;
      color: #fff;
      margin-bottom: 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 20px;
      flex-wrap: wrap;
    }
    .sme-hero h2 {
      font-size: 1.25rem;
      font-weight: 700;
      margin-bottom: 6px;
      color: #fff;
    }
    .sme-hero p {
      font-size: 0.88rem;
      opacity: 0.85;
      max-width: 480px;
      line-height: 1.5;
    }
    .sme-hero .btn {
      background: var(--accent);
      color: #1a1a1a;
      padding: 10px 18px;
      font-size: 0.85rem;
      flex-shrink: 0;
    }
    .sme-hero .btn:hover { background: var(--accent-dark); color: #fff; }
    .dash-view { display: none; }
    .dash-view.active { display: block; }
    .progress-mini {
      display: flex;
      gap: 4px;
      margin-top: 8px;
    }
    .progress-dot {
      height: 4px;
      flex: 1;
      border-radius: 9999px;
      background: var(--border-light);
    }
    .progress-dot.done { background: var(--success); }
    .progress-dot.current { background: var(--accent); }

/* App shell polish */
body.app-body {
  margin: 0;
  background: var(--bg, var(--color-bg-page));
  min-height: 100vh;
  font-family: var(--body-font, var(--font-primary));
  font-size: var(--text-body-size, 1rem);
  color: var(--text-secondary, var(--color-gray-600));
  -webkit-font-smoothing: antialiased;
}
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.app-shell .screen {
  display: none;
  flex: 1;
  flex-direction: column;
}
.app-shell .screen.active {
  display: flex;
}
.app-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: #eef1f5;
  color: var(--primary);
}
.app-loading-overlay.hidden { display: none; }
.app-loading-overlay .auth-loading-spinner {
  border-color: rgba(30, 58, 95, 0.15);
  border-top-color: var(--primary);
}
.app-header .logo-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  overflow: hidden;
}
.app-header .logo-mark [data-lucide] {
  width: 18px;
  height: 18px;
}
.app-header .logo-mark .header-logo {
  width: 20px;
  height: 20px;
  max-width: 20px;
  max-height: 20px;
  object-fit: contain;
  display: block;
}
.header-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
}
.app-title {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.1;
}
.header-brand-tag {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}
.app-title h1 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}
.primary-nav .nav-link [data-lucide],
.card-header [data-lucide],
.btn [data-lucide],
.app-header .logo-mark [data-lucide] {
  width: 15px;
  height: 15px;
}
.app-header .logo-mark [data-lucide] {
  width: 18px;
  height: 18px;
}
.user-pill {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
}
.main-content-narrow {
  max-width: 820px;
}
.btn-cta {
  padding: 10px 18px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.empty-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 12px;
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 20px;
}
.empty-hero h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: #fff;
}
.empty-hero p {
  margin: 0;
  font-size: 0.88rem;
  opacity: 0.9;
  max-width: 520px;
  line-height: 1.5;
}
.label-optional {
  font-weight: 400;
  color: var(--text-light);
}
.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.form-actions-end {
  justify-content: flex-end;
}
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 20px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--bg-alt);
  cursor: pointer;
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease;
}
.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: var(--accent);
  background: #fffdf8;
}
.upload-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--border-light);
  overflow: hidden;
  margin: 8px 0 4px;
}
.upload-part-progress {
  margin: 10px 0 8px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: #fffdf8;
}
.upload-part-progress[aria-busy='true'] .upload-part-label {
  color: var(--primary);
}
.upload-part-label {
  margin: 0 0 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.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;
}
.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 200ms ease;
}
.upload-status.uploading {
  color: var(--primary);
  font-weight: 500;
}
.upload-dropzone [data-lucide] {
  width: 32px;
  height: 32px;
  color: var(--text-light);
}
.upload-dropzone strong {
  font-size: 0.9rem;
  color: var(--text);
}
.upload-dropzone span {
  font-size: 0.78rem;
  color: var(--text-light);
}
.upload-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
#source-upload {
  position: relative;
}
.submit-status {
  min-height: 1.25rem;
  font-size: 0.85rem;
  color: var(--info);
  margin-top: 8px;
}
.submit-status.is-error { color: #991b1b; }

/* SpeechGradebook-style processing indicator */
.spinner {
  border: 3px solid var(--border-light);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg, 1.5rem);
  padding: 32px 24px 40px;
  text-align: center;
}
.loading-state-body {
  width: 100%;
  max-width: 520px;
}
.loading-state-title {
  margin: 0 0 8px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.loading-state-message {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
}
.loading-state-submessage {
  color: var(--text-light);
  font-size: 0.82rem;
  margin: 6px 0 0;
}
.icon-with-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.icon-with-text [data-lucide] {
  width: 18px;
  height: 18px;
}
.background-gen-notice {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--info-bg);
  border: 1px solid rgba(74, 124, 143, 0.2);
  text-align: left;
}
.background-gen-notice-title {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
}
.background-gen-notice p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.generation-stages {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.processing-stage {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-alt);
  border-radius: 10px;
  opacity: 0.5;
  transition: opacity 150ms ease, background 150ms ease;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}
.processing-stage [data-lucide]:first-child {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-light);
}
.processing-stage span { flex: 1; }
.processing-stage .stage-complete {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: none;
  color: var(--success);
}
.processing-stage.is-current {
  opacity: 1;
  background: rgba(30, 58, 95, 0.08);
  border: 1px solid rgba(30, 58, 95, 0.12);
}
.processing-stage.is-current [data-lucide]:first-child { color: var(--primary); }
.processing-stage.is-current .stage-spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
  margin: 0;
  flex-shrink: 0;
}
.processing-stage.is-done {
  opacity: 1;
  background: var(--success-bg);
}
.processing-stage.is-done .stage-complete { display: block; }
.form-actions-center {
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
  gap: 10px;
}
#generationCancelBtn {
  border-color: var(--error-border, #991b1b);
  color: var(--error-text, #991b1b);
}
.status-pill.is-processing {
  background: rgba(30, 58, 95, 0.08);
  color: var(--primary);
}
.status-pill.is-failed {
  background: var(--error-bg);
  color: var(--error-text);
}
.status-pill .status-spinner {
  width: 14px;
  height: 14px;
  border-width: 2px;
  margin: 0;
  display: inline-block;
  vertical-align: middle;
}
.queue-item.is-generating .queue-item-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
@media (prefers-reduced-motion: reduce) {
  .spinner, .status-spinner, .stage-spinner {
    animation: none;
    border-top-color: var(--primary);
    opacity: 0.85;
  }
}
.progress-steps-compact {
  padding-top: 16px;
}
.review-layout-single {
  grid-template-columns: 1fr !important;
}
.review-layout-single .media-panel {
  display: none !important;
}
.review-layout {
  min-height: 520px;
}
.review-layout .media-panel {
  min-width: 0;
}
.review-layout .doc-panel {
  min-width: 0;
}
.frame-preview-panel {
  border-top: 1px solid var(--border-light);
  background: var(--card);
  padding: 12px 16px 14px;
}
.frame-preview-panel.active-slot {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.frame-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 8px;
}
.frame-preview-time {
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent-dark);
}
.frame-preview-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}
.frame-preview-canvas-wrap canvas,
.frame-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.frame-preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
}
.toolbar-chip {
  cursor: pointer;
  font-family: var(--font);
}
.toolbar-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.doc-body .resolved-img,
.doc-body .screenshot-placeholder img.resolved-img {
  width: 100%;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
}
.doc-body .screenshot-placeholder {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 14px 0;
  background: var(--bg-alt);
}
.doc-body .screenshot-placeholder.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 168, 56, 0.2);
}
.placeholder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.placeholder-time {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}
.placeholder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.slot-action-btn {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: var(--card);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font);
}
.slot-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.slot-action-btn.slot-action-danger:hover {
  border-color: #dc2626;
  color: #dc2626;
}
.visual-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-light);
  margin: 0 2px;
}
.visual-cmd-accent {
  color: var(--primary);
  border-color: var(--accent);
}
.doc-body .placeholder-icon {
  color: var(--text-light);
  margin-bottom: 6px;
}
.doc-body .placeholder-text strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}
.doc-body .placeholder-text span {
  font-size: 0.78rem;
  color: var(--text-light);
}
.review-markdown.hidden { display: none; }
#reviewDocPreview.hidden { display: none; }
.slots-empty {
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.45;
  padding: 8px 0;
}
.capture-loom-hint {
  font-size: 0.72rem;
  color: var(--text-light);
  margin: 0;
  line-height: 1.45;
}
#reviewUseFrameBtn.hidden {
  display: none;
}
.visual-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-alt);
}
.visual-editor-toolbar.hidden {
  display: none;
}
.visual-cmd-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: var(--card);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.visual-cmd-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.review-mode-hint {
  margin: 0;
  padding: 8px 16px 10px;
  font-size: 0.76rem;
  color: var(--text-light);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border-light);
  line-height: 1.45;
}
.doc-body-readonly {
  cursor: default;
  background: var(--card);
}
.doc-body-readonly .screenshot-placeholder {
  cursor: pointer;
}
.visual-editor-body {
  min-height: 360px;
  outline: none;
  background: #fffef8;
  border-left: 3px solid var(--accent);
}
.visual-editor-body:focus {
  box-shadow: inset 0 0 0 1px rgba(232, 168, 56, 0.25);
}
.doc-body h1,
.doc-body h2,
.doc-body h3 {
  color: var(--primary);
  margin: 1.1em 0 0.55em;
  line-height: 1.25;
}
.doc-body h2 { font-size: 1.25rem; }
.doc-body h3 { font-size: 1.05rem; }
.doc-body p { margin-bottom: 0.85em; line-height: 1.6; }
.doc-body ul,
.doc-body ol { margin: 0 0 0.85em 1.25em; line-height: 1.55; }
.doc-body li { margin-bottom: 0.35em; }
.doc-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-alt);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.doc-body img.resolved-img,
.doc-body .screenshot-placeholder img {
  max-width: 100%;
  border-radius: 8px;
}
.review-markdown.hidden,
#reviewDocVisual.hidden,
#reviewDocPreview.hidden {
  display: none;
}
.EasyMDEContainer {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 360px;
}
.EasyMDEContainer .CodeMirror {
  flex: 1;
  min-height: 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  border: none;
}
.EasyMDEContainer .editor-toolbar {
  border: none;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-alt);
}
.crop-screenshot-wrap {
  max-height: min(60vh, 520px);
  background: #111;
  border-radius: 8px;
  overflow: hidden;
}
.crop-screenshot-wrap img {
  display: block;
  max-width: 100%;
}
.review-slots-empty .slot-card { cursor: default; }
#reviewVideoHost video,
#reviewVideoHost iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: 0;
  border-radius: 8px;
  display: block;
  background: #000;
}
.summary-link {
  font-size: 0.9rem;
  color: var(--info);
  word-break: break-all;
}
.save-hint {
  font-size: 0.75rem;
  color: var(--text-light);
}
.meta-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light);
  margin-right: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hub-table-wrap {
  padding: 20px;
  overflow-x: auto;
}
.hub-actions-cell {
  white-space: nowrap;
}
.hub-retry-btn {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.hub-retry-btn:hover {
  background: rgba(0, 122, 255, 0.08);
}
.hub-cancel-btn {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--error);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--error);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.hub-cancel-btn:hover {
  background: rgba(220, 53, 69, 0.08);
}
.queue-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}
.regenerate-notice {
  padding: 0.75rem 1rem;
  background: rgba(255, 149, 0, 0.1);
  border: 1px solid rgba(255, 149, 0, 0.35);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.45;
  margin-bottom: 1rem;
}
.regenerate-mode-options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.regenerate-mode-option {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  font-size: 0.875rem;
  line-height: 1.45;
  cursor: pointer;
}
.regenerate-mode-option input {
  margin-top: 0.2rem;
}
.modal-box-wide {
  max-width: min(720px, 96vw);
}
.template-card.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}
.template-card {
  position: relative;
}
.hub-action-muted {
  font-size: 0.8rem;
  color: var(--text-light);
}
.hub-error-hint {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--error);
  line-height: 1.35;
  max-width: 280px;
}

.settings-card .card-header { border-bottom: 1px solid var(--border-light); }
.settings-panel-section.hidden { display: none; }
.settings-account-card { margin-top: 0.5rem; }
.team-add-form {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-light);
}
.team-add-row {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 200px) auto;
  gap: 1rem;
  align-items: end;
}
@media (max-width: 768px) {
  .team-add-row { grid-template-columns: 1fr; }
}
.team-add-actions .btn { white-space: nowrap; }
.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-light);
  cursor: pointer;
}
.team-role-select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  background: var(--card);
}
.team-table td span { font-size: 0.82rem; color: var(--text-light); }
.settings-section {
  margin-top: 1.5rem;
}
.settings-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.dash-panel-header a {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--info);
  text-decoration: none;
}
.dash-panel-header a:hover { text-decoration: underline; }
.queue-empty {
  padding: 32px 24px;
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
}
.queue-empty a {
  color: var(--primary);
  font-weight: 600;
}
@media (max-width: 768px) {
  .header-left { gap: 12px; }
  .primary-nav { display: none; }
  .user-pill { display: none; }

  /* Modals — bottom sheet with sticky footer (matches SpeechGradebook) */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal-box {
    max-width: 100%;
    width: 100%;
    max-height: min(92dvh, 92vh);
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  .modal-box-header {
    padding: 18px 16px 0;
    padding-top: calc(18px + env(safe-area-inset-top, 0));
  }
  .modal-box-body {
    padding: 14px 16px;
  }
  .modal-box-footer {
    flex-direction: column-reverse;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  }
  .modal-box-footer .btn {
    width: 100%;
    justify-content: center;
  }

  /* Review screen — sticky bottom action bar */
  #screen-review .main-content {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0));
  }
  #screen-review .review-action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    margin: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  }
  #screen-review .review-action-bar .action-bar-group {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  #screen-review .review-action-bar .action-bar-primary {
    margin-left: 0;
  }
  #screen-review .review-action-bar .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  /* Screenshot capture + placeholder controls */
  .capture-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .capture-actions .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
  .placeholder-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .placeholder-actions .slot-action-btn {
    width: 100%;
    min-height: 40px;
    justify-content: center;
    padding: 8px 10px;
    font-size: 0.72rem;
  }

  /* Template picker in regenerate modal */
  .modal-box .template-grid {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .summary-card {
    grid-template-columns: 1fr 1fr;
  }
  .doc-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .doc-toolbar-left {
    width: 100%;
    flex-wrap: wrap;
  }
  .visual-editor-toolbar {
    padding: 8px 12px;
  }
  .visual-editor-toolbar .visual-cmd-btn {
    min-height: 40px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .modal-box-wide {
    max-width: min(680px, 94vw);
  }
  .modal-box .template-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .placeholder-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .placeholder-actions .slot-action-btn {
    width: 100%;
    justify-content: center;
    min-height: 38px;
  }
  .capture-actions {
    flex-wrap: wrap;
  }
  .capture-actions .btn {
    min-height: 44px;
  }
  #screen-review .review-action-bar {
    gap: 12px;
  }
  #screen-review .review-action-bar .action-bar-secondary {
    flex: 1;
  }
  #screen-review .review-action-bar .action-bar-secondary .btn {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    justify-content: center;
  }
  #screen-review .review-action-bar .action-bar-primary .btn {
    min-height: 44px;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .placeholder-actions {
    grid-template-columns: 1fr;
  }
  .summary-card {
    grid-template-columns: 1fr;
  }
  .toolbar-chip {
    flex: 1;
    text-align: center;
    min-height: 36px;
  }
}

.nav-link { cursor: pointer; }
.icon-btn { cursor: pointer; }
.hidden { display: none !important; }
body.modal-open {
  overflow: hidden;
  touch-action: none;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--card);
  border-radius: 12px;
  max-width: min(520px, 96vw);
  width: 100%;
  max-height: min(90vh, 900px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-box-header {
  flex-shrink: 0;
  padding: 20px 24px 0;
}
.modal-box-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 24px;
}
.modal-box-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--card);
}
.modal-box h3 {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 1.15rem;
  line-height: 1.35;
}
.modal-lead {
  color: var(--text-light);
  font-size: 0.9rem;
  margin: 0 0 4px;
  line-height: 1.5;
}
.modal-box-body .form-group:last-child {
  margin-bottom: 0;
}
.modal-box-body .regenerate-notice {
  margin-bottom: 1rem;
}
.modal-box-footer .btn {
  min-height: 44px;
}
.dest-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.dest-option { border: 1.5px solid var(--border-light); border-radius: 10px; padding: 14px 16px; cursor: pointer; display: flex; align-items: flex-start; gap: 12px; }
.dest-option:hover { border-color: var(--accent); }
.dest-option.selected { border-color: var(--primary); background: rgba(30,58,95,0.04); }
.dest-option.disabled { opacity: 0.45; cursor: not-allowed; }
.dest-option input { margin-top: 4px; }
.dest-option-body h4 { margin: 0 0 4px; font-size: 0.95rem; }
.dest-option-body p { margin: 0; font-size: 0.8rem; color: var(--text-light); }
.form-group textarea { width: 100%; padding: 0.75rem; border: 1px solid var(--border); border-radius: 0.5rem; font-size: 0.95rem; font-family: var(--font); min-height: 100px; resize: vertical; }
.review-markdown { width: 100%; min-height: 420px; padding: 16px; border: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; line-height: 1.55; resize: vertical; background: var(--card); color: var(--text); }
.review-markdown:focus { outline: none; }
.doc-panel { border-top: 1px solid var(--border-light); }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--primary); color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 0.85rem; z-index: 3000; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
@media (max-width: 768px) {
  .toast {
    left: 16px;
    right: 16px;
    bottom: calc(96px + env(safe-area-inset-bottom, 0));
  }
  body.modal-open .toast {
    bottom: calc(16px + env(safe-area-inset-bottom, 0));
  }
}
.toast.error { background: #991b1b; }
.auth-loading-spinner { width: 48px; height: 48px; border: 4px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
