:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  --topbar-offset: calc(max(8px, env(safe-area-inset-top)) + 52px);
  background: #0b1220;
  color: #f8fafc;
}

* { box-sizing: border-box; }

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: manipulation;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: manipulation;
  background: radial-gradient(circle at top, #1b3154, #0b1220 55%);
}

button { font: inherit; }

.app-topbar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  width: 100%;
  padding: max(8px, env(safe-area-inset-top)) 14px 8px;
  border-bottom: 1px solid rgba(96, 165, 250, .22);
  background: rgba(2, 6, 23, .96);
  box-shadow: 0 14px 30px rgba(2, 6, 23, .28);
  backdrop-filter: blur(14px);
}

.app-topbar-inner {
  width: min(1180px, 100%);
  min-height: 44px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.app-brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(147, 197, 253, .18);
}

.app-title {
  overflow: hidden;
  color: #f8fafc;
  font-size: 1.08rem;
  font-weight: 950;
  letter-spacing: .02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-layout {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: var(--topbar-offset) auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
}

.course-sidebar {
  min-width: 0;
  max-width: 100%;
  padding: 16px;
  border: 1px solid #334155;
  border-radius: 12px;
  background: rgba(15, 23, 42, .72);
}

.course-sidebar[data-collapsed="true"] {
  padding: 10px 12px;
}

.course-sidebar[data-collapsed="true"] .sidebar-header,
.course-sidebar[data-collapsed="true"] .course-tree {
  display: none;
}

.course-panel-summary {
  display: none;
  width: 100%;
  min-height: 36px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #111c2f;
  color: #dbeafe;
  font-size: .9rem;
  font-weight: 800;
  text-align: left;
}

.course-sidebar[data-collapsed="true"] .course-panel-summary {
  display: flex;
}

#course-panel-current {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding: 0;
  flex-wrap: wrap;
}

.sidebar-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: #f8fafc;
  font-size: 1.08rem;
  font-weight: 950;
  letter-spacing: .02em;
}

.panel-toggle-button {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  background: #1e293b;
  color: #bfdbfe;
  font-size: .9rem;
  font-weight: 900;
}

.small-button {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #334155;
  color: #dbeafe;
  font-size: .78rem;
  font-weight: 700;
}

.language-switch {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.language-button {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 7px;
  background: #1e293b;
  font-size: .86rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.language-button[data-active="true"] {
  outline: 2px solid #60a5fa;
  background: #2563eb;
}

.modal-language-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 14px;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 10px;
  background: rgba(2, 6, 23, .26);
}

.modal-language-label {
  color: #cbd5e1;
  font-size: .82rem;
  font-weight: 800;
}

.course-tree {
  display: grid;
  gap: 0;
  margin-bottom: 14px;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  min-width: 0;
}

.workspace-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(147, 197, 253, .16);
}

.workspace-title {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: #111c2f;
  color: #dbeafe;
  font-size: .9rem;
  font-weight: 900;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-search-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  padding-inline: 0;
}

.button-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.subject-block {
  margin: 0 0 10px 14px;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 10px;
  background: rgba(2, 6, 23, .2);
}

.subject-block:last-of-type {
  margin-bottom: 0;
}

.subject-title {
  min-width: 0;
  min-height: 34px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  margin: 0;
  color: #dbeafe;
  font-size: .9rem;
  font-weight: 900;
  text-align: left;
  text-transform: none;
}

.subject-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 8px;
}

.session-list {
  position: relative;
  display: grid;
  gap: 0;
  min-width: 0;
  margin-left: 12px;
  padding-left: 18px;
}

.session-list::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 12px;
  left: 0;
  border-left: 1px dashed rgba(147, 197, 253, .35);
}

.subject-row .subject-title {
  flex: 1;
}

.subject-toggle {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 6px;
  background: #1e293b;
  color: #dbeafe;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.session-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  min-width: 0;
  height: 30px;
  min-height: 30px;
  margin: 0;
  padding: 0 10px;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  font-size: .82rem;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin: 0 0 6px;
}

.session-button[data-active="true"] {
  background: #2563eb;
  color: #fff;
  font-weight: 800;
}

.session-record-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  height: 30px;
  min-height: 30px;
  padding: 0 9px;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
}

.session-record-button:hover:not(:disabled) {
  filter: brightness(1.1);
}

.session-add-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  height: 30px;
  min-height: 30px;
  margin: 0;
  padding: 0 10px;
  border-radius: 8px;
  background: #1e293b;
  color: #93c5fd;
  font-size: .74rem;
  font-weight: 800;
  text-align: center;
}

.session-add-row {
  margin: 4px 0 0;
}

.session-record-spacer {
  flex: 0 0 44px;
}

.session-order-spacer {
  flex: 0 0 48px;
}

.session-delete-spacer {
  flex: 0 0 22px;
}

.course-add-button {
  width: auto;
  justify-self: start;
  min-height: 30px;
  margin: 4px 0 10px;
  padding: 0 14px;
  border-radius: 8px;
  background: #172554;
  color: #dbeafe;
  font-size: .76rem;
  font-weight: 800;
  text-align: center;
}

.order-controls {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity .15s ease;
}

.row-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s ease;
}

.subject-row:hover .order-controls,
.subject-row:focus-within .order-controls,
.session-row:hover .order-controls,
.session-row:focus-within .order-controls,
.subject-row:hover .row-actions,
.subject-row:focus-within .row-actions {
  opacity: 1;
}

.order-button {
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #94a3b8;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
}

.order-button:hover:not(:disabled) {
  background: #1e293b;
  color: #dbeafe;
}

.order-button:disabled {
  color: #475569;
  background: transparent;
  cursor: not-allowed;
  opacity: .7;
}

.delete-button {
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #94a3b8;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.session-row .delete-button {
  opacity: 0;
  transition: opacity .15s ease;
}

.session-row:hover .delete-button,
.session-row:focus-within .delete-button {
  opacity: 1;
}

.delete-button:hover:not(:disabled) {
  background: rgba(220, 38, 38, .18);
  color: #fecaca;
}

.delete-button:disabled {
  background: transparent;
  color: #475569;
  cursor: not-allowed;
  opacity: .6;
}

.inline-edit {
  min-height: 32px;
  border: 1px solid #60a5fa;
  border-radius: 8px;
  background: #020617;
  color: #f8fafc;
  font: inherit;
  outline: 0;
}

.subject-edit {
  width: 100%;
  padding: 3px 8px;
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace-edit {
  width: 100%;
  padding: 4px 8px;
  font-size: .9rem;
  font-weight: 900;
}

.workspace-modal {
  max-width: 460px;
}

.workspace-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 6px;
}

.workspace-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 8px;
  background: #0f172a;
}

.workspace-option[data-active="true"] {
  border-color: #60a5fa;
  background: #172554;
}

.workspace-option-button {
  flex: 1;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  background: transparent;
  color: #dbeafe;
  font-size: .9rem;
  font-weight: 800;
  text-align: left;
}

.workspace-option .delete-button {
  opacity: 1;
}

.session-edit {
  width: 100%;
  margin-bottom: 6px;
  padding: 7px 10px;
  font-size: .9rem;
}

.app-shell {
  min-width: 0;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; min-width: 0; }
.app-header > div:first-child { min-width: 0; }
.eyebrow { margin: 0 0 4px; color: #93c5fd; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; }
h1 { margin: 0; font-size: 1.8rem; overflow-wrap: anywhere; }
.header-side {
  min-width: 0;
  display: grid;
  justify-items: end;
  gap: 10px;
}
.account-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
  max-width: min(360px, 48vw);
}
.account-bar span {
  min-width: 0;
  overflow: hidden;
  color: #94a3b8;
  font-size: .76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-button {
  width: auto;
  max-width: min(280px, 45vw);
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: rgba(30, 41, 59, .92);
  color: #dbeafe;
  font-size: .8rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-button:hover {
  background: #334155;
}
.status { color: #bfdbfe; font-size: .9rem; }
.status::before { content: "•"; color: #64748b; margin-right: 6px; }
.status[data-state="connecting"]::before {
  content: "◌";
  color: #60a5fa;
  display: inline-block;
  animation: status-spin 1s linear infinite;
}
.status[data-state="listening"]::before { color: #f87171; }

@keyframes status-spin {
  to { transform: rotate(360deg); }
}
.top-actions {
  display: flex;
  min-width: 0;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.text-size-control {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid rgba(96, 165, 250, .2);
  border-radius: 8px;
  background: #111827;
}
.text-size-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  background: transparent;
  color: #cbd5e1;
  font-size: .76rem;
  font-weight: 900;
}
.text-size-button + .text-size-button {
  border-left: 1px solid rgba(96, 165, 250, .16);
}
.text-size-button[data-active="true"] {
  background: #2563eb;
  color: #fff;
}
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.action-icon {
  min-width: 1em;
  text-align: center;
}
.primary-action {
  background: #2563eb;
  color: #fff;
}
.primary-action.is-stop {
  background: #dc2626;
}
.secondary-action {
  background: #1e293b;
  color: #cbd5e1;
}
.secondary-action:hover:not(:disabled),
.primary-action:hover:not(:disabled) {
  filter: brightness(1.1);
}

.transcript-card {
  position: relative;
  min-width: 0;
  max-width: 100%;
  flex: 1;
  min-height: 55vh;
  overflow: auto;
  border: 1px solid #334155;
  border-radius: 18px;
  background: rgba(15, 23, 42, .78);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.transcript-card[data-folded="true"] {
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}

.transcript-toolbar {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 12px 0;
}
.transcript-toolbar::after {
  content: "";
  position: absolute;
  top: 12px;
  right: 82px;
  width: 24px;
  height: 30px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, .95));
}
.transcript-tabs {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.transcript-tab {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #1e293b;
  color: #dbeafe;
  font-size: .74rem;
  font-weight: 800;
  white-space: nowrap;
}
.transcript-tab[data-active="true"] {
  background: #2563eb;
  color: #fff;
}
.transcript-tab[data-ready="false"] {
  border: 1px solid rgba(147, 197, 253, .2);
}
.fold-button {
  flex: 0 0 auto;
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  background: #1e293b;
  color: #bfdbfe;
  font-size: .8rem;
  font-weight: 900;
}

#speak-transcript {
  width: 44px;
  min-width: 44px;
  min-height: 32px;
  overflow: hidden;
  line-height: 1;
  font-size: .95rem;
}
.fold-summary {
  margin: 0;
  padding: 12px 20px 16px;
  color: #94a3b8;
  font-size: .85rem;
  font-weight: 700;
}
.transcript-card[data-folded="true"] .fold-summary,
.bookmarks-panel[data-folded="true"] .fold-summary,
.notes-panel[data-folded="true"] .fold-summary,
.summary-panel[data-folded="true"] .fold-summary {
  padding-top: 8px;
  padding-bottom: 2px;
}

.transcript { padding: 20px; }
.transcript-segment {
  margin: 0 0 14px;
  font-size: 1rem;
  line-height: 1.48;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
body[data-text-size="small"] .transcript-segment,
body[data-text-size="small"] .transcript-edit,
body[data-text-size="small"] .interim-inline,
body[data-text-size="small"] .summary-input,
body[data-text-size="small"] .summary-preview,
body[data-text-size="small"] .translation-text {
  font-size: .9rem;
}
body[data-text-size="medium"] .transcript-segment,
body[data-text-size="medium"] .transcript-edit,
body[data-text-size="medium"] .interim-inline,
body[data-text-size="medium"] .summary-input,
body[data-text-size="medium"] .summary-preview,
body[data-text-size="medium"] .translation-text {
  font-size: 1rem;
}
body[data-text-size="large"] .transcript-segment,
body[data-text-size="large"] .transcript-edit,
body[data-text-size="large"] .interim-inline,
body[data-text-size="large"] .summary-input,
body[data-text-size="large"] .summary-preview,
body[data-text-size="large"] .translation-text {
  font-size: 1.15rem;
}
.transcript-edit {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  resize: vertical;
  overflow: auto;
  background: transparent;
  color: #f8fafc;
  font: inherit;
  font-size: 1rem;
  line-height: 1.48;
  outline: 0;
}
.transcript-edit-all {
  min-height: 45vh;
}

.activity-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(96, 165, 250, .42);
  border-radius: 10px;
  background: rgba(29, 78, 216, .18);
  color: #dbeafe;
  font-size: .86rem;
  font-weight: 800;
}

.activity-banner[hidden] {
  display: none;
}

.activity-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(147, 197, 253, .35);
  border-top-color: #93c5fd;
  border-radius: 999px;
  animation: status-spin 1s linear infinite;
}
.transcript-edit:hover,
.transcript-edit:focus {
  border-color: rgba(96, 165, 250, .45);
  background: rgba(2, 6, 23, .42);
}

.search-highlight {
  border-radius: 4px;
  background: rgba(250, 204, 21, .85);
  color: #111827;
  padding: 0 .08em;
}
.bookmarks-panel,
.notes-panel,
.summary-panel {
  min-width: 0;
  max-width: 100%;
  padding: 12px 14px 14px;
  border: 1px solid #334155;
  border-radius: 12px;
  background: rgba(15, 23, 42, .72);
}
.bookmarks-panel[data-folded="true"],
.notes-panel[data-folded="true"],
.summary-panel[data-folded="true"] {
  padding-bottom: 12px;
}
.bookmarks-header,
.notes-header,
.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.bookmarks-header > div,
.notes-header > div,
.summary-header > div {
  min-width: 0;
}
.bookmarks-panel[data-folded="true"] .bookmarks-header,
.notes-panel[data-folded="true"] .notes-header,
.summary-panel[data-folded="true"] .summary-header {
  margin-bottom: 0;
}

.bookmarks-panel[data-folded="true"] #bookmarks-hint,
.notes-panel[data-folded="true"] #notes-hint,
.summary-panel[data-folded="true"] #summary-hint {
  display: none;
}
.bookmarks-header h2,
.notes-header h2,
.summary-header h2 {
  margin: 0;
  color: #bfdbfe;
  font-size: .9rem;
}
.bookmarks-header span,
.notes-header span,
.summary-header span {
  color: #64748b;
  font-size: .75rem;
}
.summary-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, auto));
  flex: 0 0 auto;
  gap: 8px;
}
.summary-header-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}
.transcript-jump-fold {
  color: #bfdbfe;
}
.transcript-jump-fold[hidden] {
  display: none;
}
.summary-language-button {
  min-height: 30px;
  min-width: 58px;
  padding: 7px 8px;
  border-radius: 8px;
  background: #1e293b;
  color: #dbeafe;
  font-size: .74rem;
  font-weight: 800;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.summary-language-button[data-active="true"] {
  background: #2563eb;
  color: #fff;
}
.compact-button {
  min-height: 30px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: .74rem;
  font-weight: 800;
}
.transcript-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.flag {
  width: 15px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .22);
  object-fit: cover;
}
.bookmarks-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.bookmark-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 8px;
  background: rgba(2, 6, 23, .45);
}
.bookmark-text {
  display: grid;
  min-width: 0;
  gap: 2px;
}
.bookmark-text strong {
  color: #93c5fd;
  font-size: .76rem;
}
.bookmark-text span {
  overflow: hidden;
  color: #dbeafe;
  font-size: .84rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bookmarks-empty {
  margin: 0;
  color: #94a3b8;
  font-size: .84rem;
}
.bookmark-delete {
  flex: 0 0 auto;
  width: 28px;
  min-height: 28px;
  border-radius: 8px;
  background: rgba(30, 41, 59, .9);
  color: #fecaca;
  font-weight: 900;
}
.notes-input,
.summary-input {
  width: 100%;
  min-height: 92px;
  max-height: 32vh;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, .3);
  border-radius: 8px;
  resize: vertical;
  background: #020617;
  color: #f8fafc;
  font: inherit;
  font-size: .95rem;
  line-height: 1.45;
  outline: 0;
}
.notes-input[hidden],
.summary-input[hidden],
.transcript[hidden] {
  display: none;
}
.summary-input {
  min-height: 220px;
  max-height: 48vh;
  white-space: pre-wrap;
}
.summary-preview {
  min-height: 220px;
  max-height: 48vh;
  overflow: auto;
  padding: 14px 16px;
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 8px;
  background: #020617;
  color: #e5edf8;
  font-size: .95rem;
  line-height: 1.55;
  cursor: text;
}
.summary-preview[hidden] {
  display: none;
}
.summary-preview h3,
.summary-preview h4,
.summary-preview h5 {
  margin: 16px 0 8px;
  color: #bfdbfe;
  font-size: 1em;
}
.summary-preview h3:first-child,
.summary-preview h4:first-child,
.summary-preview h5:first-child,
.summary-preview p:first-child {
  margin-top: 0;
}
.summary-preview p {
  margin: 0 0 10px;
}
.summary-preview ul,
.summary-preview ol {
  margin: 0 0 12px;
  padding-left: 22px;
}
.summary-preview li {
  margin: 5px 0;
}
.summary-preview strong {
  color: #f8fafc;
}
.summary-preview code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(30, 41, 59, .95);
  color: #dbeafe;
}
.notes-input:focus,
.summary-input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, .15);
}
.notes-input:disabled,
.summary-input:disabled {
  color: #64748b;
  cursor: not-allowed;
}
.copy-button {
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #334155;
  color: #dbeafe;
  font-size: .7rem;
  font-weight: 700;
}
.copy-button:disabled {
  color: #64748b;
  background: #111827;
  cursor: not-allowed;
}
.copy-button.is-copied,
.secondary-button.is-copied,
.action-button.is-copied {
  background: #15803d;
  color: #dcfce7;
}
.empty-state { color: #94a3b8; line-height: 1.5; }
.interim { margin: 0; padding: 0 20px 20px; color: #94a3b8; font-size: 1.25rem; line-height: 1.55; font-style: italic; }
.interim-inline {
  margin: 0 0 14px;
  padding: 0;
  font-size: 1rem;
  line-height: 1.48;
}
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .65; }
.primary-button,
.secondary-button,
.danger-button {
  border-radius: 13px;
  padding: 14px 16px;
}
.primary-button { background: #2563eb; color: white; font-weight: 700; }
.primary-button.is-stop { background: #dc2626; }
.secondary-button { background: #1e293b; color: #cbd5e1; }
.danger-button { background: #dc2626; color: white; font-weight: 700; }
.error { margin: 0; color: #fca5a5; line-height: 1.4; }
.diagnostics { color: #bfdbfe; font-size: .8rem; }
.diagnostics summary { cursor: pointer; color: #94a3b8; }
.diagnostics pre {
  overflow: auto;
  max-height: 160px;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #020617;
  color: #cbd5e1;
  white-space: pre-wrap;
}
.disclaimer { margin: 0; color: #94a3b8; text-align: center; font-size: .8rem; line-height: 1.4; }

.modal {
  width: min(420px, calc(100% - 32px));
  max-width: calc(100% - 32px);
  max-height: calc(100vh - 24px);
  max-height: min(760px, calc(100dvh - 24px));
  overflow: hidden;
  padding: 0;
  border: 1px solid #334155;
  border-radius: 14px;
  background: #0f172a;
  color: #f8fafc;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
}

.auth-modal {
  width: min(520px, calc(100% - 32px));
}

.admin-modal {
  width: min(860px, calc(100% - 24px));
}

#summary-profile-dialog {
  width: min(520px, calc(100% - 24px));
}

.modal::backdrop {
  background: rgba(2, 6, 23, .72);
  backdrop-filter: blur(4px);
}

.modal-card {
  display: grid;
  max-height: inherit;
  min-width: 0;
  gap: 12px;
  overflow: auto;
  padding: 18px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-card h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-card label {
  color: #bfdbfe;
  font-size: .85rem;
  font-weight: 700;
}

.modal-message {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.45;
}

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

.profile-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 10px;
  background: rgba(15, 23, 42, .78);
  cursor: pointer;
}

.profile-option:has(input:checked) {
  border-color: rgba(96, 165, 250, .75);
  background: rgba(37, 99, 235, .18);
}

.profile-option input {
  margin-top: 3px;
}

.profile-option span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.profile-option strong {
  color: #dbeafe;
  font-size: .9rem;
}

.profile-option small {
  color: #94a3b8;
  font-size: .76rem;
  line-height: 1.35;
}
.profile-delete {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 8px;
  background: rgba(30, 41, 59, .85);
  color: #fecaca;
  font-weight: 900;
}
.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 10px;
  background: rgba(2, 6, 23, .35);
}
.toggle-row input {
  margin-top: 3px;
}
.custom-profile-form {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, .16);
}
.custom-profile-form h3 {
  margin: 0;
  color: #dbeafe;
  font-size: .95rem;
}
.modal-textarea {
  min-height: 96px;
  resize: vertical;
}

.modal-error {
  margin: 0;
  color: #fca5a5;
  font-size: .85rem;
  line-height: 1.4;
}

.link-button {
  min-height: 34px;
  padding: 7px 0;
  background: transparent;
  color: #93c5fd;
  font-size: .82rem;
  font-weight: 800;
}

.link-button:hover {
  color: #dbeafe;
}

.modal-input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #475569;
  border-radius: 9px;
  background: #020617;
  color: #f8fafc;
  font: inherit;
}

.modal-input:focus {
  border-color: #60a5fa;
  outline: 2px solid rgba(96, 165, 250, .24);
}

.modal-actions {
  position: sticky;
  bottom: -18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 4px -18px -18px;
  padding: 12px 18px 18px;
  border-top: 1px solid rgba(148, 163, 184, .14);
  background: linear-gradient(180deg, rgba(15, 23, 42, .86), #0f172a 32%);
  flex-wrap: wrap;
}

.modal-actions button {
  min-width: 96px;
}

.auth-modal .modal-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  align-items: stretch;
}

.auth-modal .modal-actions button {
  min-width: 0;
}

.auth-modal .link-button {
  padding-inline: 6px;
  line-height: 1.15;
}

.auth-modal #auth-cancel,
.auth-modal #auth-submit {
  min-height: 44px;
}

.export-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.export-actions button {
  min-height: 42px;
  border-radius: 10px;
  font-weight: 800;
}

.search-modal {
  width: min(680px, calc(100% - 24px));
}

.search-results {
  display: grid;
  gap: 8px;
  max-height: min(52vh, 420px);
  overflow: auto;
}

.search-scope-row {
  margin: 8px 0 12px;
}

.admin-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.admin-users {
  display: grid;
  gap: 10px;
  max-height: min(56vh, 520px);
  overflow: auto;
}

.admin-user-card {
  display: grid;
  grid-template-columns: minmax(180px, 1.15fr) minmax(0, 2fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 12px;
  background: rgba(15, 23, 42, .78);
}

.admin-user-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.admin-user-main strong,
.admin-user-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-main strong {
  color: #dbeafe;
  font-size: .9rem;
}

.admin-user-main small {
  color: #94a3b8;
  font-size: .72rem;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.admin-stat {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 9px;
  background: rgba(2, 6, 23, .4);
}

.admin-stat strong {
  color: #f8fafc;
  font-size: .9rem;
}

.admin-stat small {
  overflow: hidden;
  color: #93c5fd;
  font-size: .66rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-delete-button {
  min-width: 92px;
  min-height: 38px;
}

.search-result {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 10px;
  background: rgba(15, 23, 42, .78);
  color: #e5edf8;
  text-align: left;
}

.search-result:hover {
  border-color: rgba(96, 165, 250, .55);
  background: rgba(30, 41, 59, .9);
}

.search-result strong {
  overflow: hidden;
  color: #dbeafe;
  font-size: .88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result span {
  color: #93c5fd;
  font-size: .72rem;
  font-weight: 800;
}

.search-result small {
  color: #cbd5e1;
  font-size: .78rem;
  line-height: 1.35;
}

.search-empty {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, .72);
  color: #94a3b8;
  font-size: .86rem;
}

@media (max-width: 460px) {
  .export-actions {
    grid-template-columns: 1fr;
  }

  .translation-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-search,
  .admin-user-card,
  .admin-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-topbar {
    padding-inline: 10px;
  }

  .app-topbar-inner {
    min-height: 40px;
  }

  .app-logo {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .app-title {
    font-size: 1rem;
  }

  .app-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100svw;
    overflow-x: clip;
    padding: max(14px, env(safe-area-inset-top)) 10px max(14px, env(safe-area-inset-bottom));
  }

  .course-sidebar {
    min-height: auto;
    padding: 12px;
  }

  .app-header {
    position: relative;
    flex-direction: column;
    gap: 12px;
    padding-inline: 10px;
    overflow: hidden;
  }

  .header-side {
    width: 100%;
    min-width: 0;
    justify-items: stretch;
  }

  .auth-button {
    max-width: 100%;
    min-width: 0;
  }

  .status {
    text-align: right;
  }

  .top-actions {
    justify-content: stretch;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
  }

  .text-size-control {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .action-button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .modal-input,
  .notes-input,
  .summary-input,
  .transcript-edit {
    font-size: 16px;
  }

  body[data-text-size="small"] .transcript-edit,
  body[data-text-size="medium"] .transcript-edit,
  body[data-text-size="large"] .transcript-edit {
    max-width: 100%;
    font-size: 16px;
  }

  .transcript-edit {
    transform: translateZ(0);
  }

  .course-tree {
    max-height: 210px;
    overflow: auto;
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-bar {
    min-width: 0;
  }

  .subject-row,
  .session-row {
    gap: 5px;
  }

  .session-row {
    margin-left: 0;
    margin-right: 0;
  }

  .session-record-button {
    padding-inline: 8px;
  }

  .order-controls,
  .row-actions,
  .session-row .delete-button {
    opacity: 1;
  }

  .transcript-card {
    min-height: 38vh;
  }

  .notes-input {
    min-height: 84px;
    max-height: 28vh;
  }

  .summary-header {
    align-items: center;
    flex-direction: row;
  }

  .summary-actions {
    width: 100%;
    max-width: 100%;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .summary-actions .compact-button,
  .summary-language-button {
    width: auto;
    flex: 0 0 auto;
  }

  .summary-input {
    min-height: 180px;
  }

  body[data-recording="true"] {
    overflow-x: hidden;
  }

  body[data-recording="true"] .app-layout {
    min-height: 100svh;
    gap: 10px;
    max-width: 100svw;
    overflow-x: clip;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }

  body[data-recording="true"] .course-sidebar {
    position: sticky;
    top: max(6px, env(safe-area-inset-top));
    z-index: 4;
    padding: 10px;
    border-radius: 10px;
    background: rgba(15, 23, 42, .94);
    backdrop-filter: blur(10px);
  }

  body[data-recording="true"] .course-sidebar .course-panel-summary {
    display: flex;
  }

  body[data-recording="true"] .course-sidebar .sidebar-header,
  body[data-recording="true"] .course-tree {
    display: none;
  }

  body[data-recording="true"] .app-shell {
    min-height: auto;
    gap: 10px;
  }

  body[data-recording="true"] .app-header {
    position: sticky;
    top: 74px;
    z-index: 3;
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(51, 65, 85, .8);
    border-radius: 12px;
    background: rgba(11, 18, 32, .94);
    backdrop-filter: blur(10px);
  }

  body[data-recording="true"] .app-header > div:first-child {
    padding-right: 0;
  }

  body[data-recording="true"] .app-header h1 {
    font-size: 1.15rem;
  }

  body[data-recording="true"] .eyebrow {
    margin-bottom: 2px;
    font-size: .68rem;
  }

  body[data-recording="true"] .summary-panel,
  body[data-recording="true"] .diagnostics,
  body[data-recording="true"] .disclaimer {
    display: none;
  }

  body[data-recording="true"] .header-side {
    gap: 7px;
  }

  body[data-recording="true"] .status {
    text-align: left;
    font-size: .78rem;
  }

  body[data-recording="true"] .top-actions {
    gap: 6px;
    grid-template-columns: auto 1fr;
    align-items: stretch;
  }

  body[data-recording="true"] .secondary-action:not(#bookmark-current) {
    display: none;
  }

  body[data-recording="true"] .text-size-control {
    grid-column: auto;
  }

  body[data-recording="true"] .action-button {
    min-height: 32px;
    padding: 6px 8px;
    font-size: .74rem;
  }

  body[data-recording="true"] .transcript-card {
    flex: none;
    min-height: 39svh;
    max-height: 46svh;
    border-radius: 12px;
  }

  body[data-recording="true"] .transcript {
    padding: 14px;
  }

  body[data-recording="true"] .transcript-segment {
    margin-bottom: 12px;
    font-size: .95rem;
    line-height: 1.46;
  }

  body[data-recording="true"] .activity-banner {
    position: sticky;
    top: 148px;
    z-index: 3;
  }

  body[data-recording="true"] .interim {
    padding: 0 14px 14px;
    font-size: .95rem;
    line-height: 1.45;
  }

  body[data-recording="true"] .interim-inline {
    padding: 0;
  }

  body[data-recording="true"] .notes-panel {
    position: sticky;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 3;
    padding: 10px;
    border-radius: 12px;
    background: rgba(15, 23, 42, .96);
    backdrop-filter: blur(10px);
  }

  body[data-recording="true"] .notes-header {
    margin-bottom: 6px;
  }

  body[data-recording="true"] .notes-input {
    min-height: 24svh;
    max-height: 30svh;
    resize: none;
    font-size: 1rem;
  }
}

@media (max-width: 520px) {
  .app-topbar-inner {
    gap: 8px;
  }

  .app-title {
    max-width: 44vw;
  }

  .account-bar {
    max-width: 48vw;
  }

  .sidebar-header h2 {
    font-size: .95rem;
  }

  .language-button {
    width: 26px;
    height: 26px;
    min-height: 26px;
    font-size: .82rem;
  }

  .workspace-bar {
    gap: 6px;
  }

  .small-button,
  .workspace-title {
    min-height: 32px;
  }

  .subject-block {
    padding-block: 9px;
  }

  .subject-row {
    gap: 4px;
  }

  .subject-title {
    font-size: .9rem;
  }

  .session-row {
    margin-left: 0;
    margin-right: 0;
  }

  .session-button {
    padding-inline: 8px;
    font-size: .78rem;
    height: 28px;
    min-height: 28px;
  }

  .session-record-button {
    height: 28px;
    min-height: 28px;
    padding: 0 7px;
    font-size: .68rem;
  }

  .session-add-button {
    height: 28px;
    min-height: 28px;
  }

  .session-record-spacer {
    flex-basis: 38px;
  }

  .session-order-spacer {
    flex-basis: 46px;
  }

  .order-controls {
    gap: 2px;
  }

  .order-button,
  .delete-button {
    width: 20px;
    height: 20px;
    min-height: 20px;
  }

  .app-header h1 {
    font-size: 1.55rem;
  }

  .auth-button {
    padding-inline: 6px;
    font-size: .72rem;
  }

  .transcript {
    padding-inline: 14px;
  }
}
