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

body {
  background: #f3f4f8;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, sans-serif;
  padding: 1rem;
  color: #1e293b;
}

body.drawer-open {
  overflow: hidden;
}

body.role-student .teacher-only {
  display: none !important;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
}

.page-layout {
  display: block;
}

.main-column {
  min-width: 0;
}

.card {
  background: #ffffff;
  border-radius: 28px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.02), 0 2px 6px rgba(0, 0, 0, 0.05);
  border: 1px solid #e9edf2;
  padding: 1.2rem;
  margin-bottom: 1.5rem;
  transition: all 0.2s ease;
}

@media (min-width: 768px) {
  .card {
    padding: 1.6rem 1.8rem;
    margin-bottom: 1.8rem;
  }
  body {
    padding: 2rem 1rem;
  }
}

@media (min-width: 1080px) {
  .page-layout.has-history {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1.2rem;
    align-items: start;
  }

  .page-layout {
    display: block;
  }

  .history-sidebar {
    position: sticky;
    top: 18px;
    margin-bottom: 0;
    max-height: calc(100vh - 36px);
    overflow: auto;
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: #1e2b3c;
}

@media (min-width: 768px) {
  .title {
    font-size: 1.35rem;
  }
}

.sub {
  font-size: 0.8rem;
  color: #5b6e8c;
  margin-top: 4px;
}

.role-badge {
  font-size: 0.72rem;
  color: #0f766e;
  background: #ecfeff;
  border: 1px solid #99f6e4;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 700;
}

.auth-row {
  margin-top: 0.4rem;
}

.auth-label {
  display: block;
  font-size: 0.75rem;
  color: #475569;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.auth-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  outline: none;
}

.auth-input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.upload-area {
  margin: 1rem 0;
  border: 2px dashed #cbd5e1;
  border-radius: 20px;
  background: #fafcff;
  padding: 1.5rem 1rem;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

@media (min-width: 768px) {
  .upload-area {
    margin: 1.2rem 0;
    border-radius: 24px;
    padding: 1.8rem 1rem;
  }
}

.upload-area.drag-over {
  border-color: #4f46e5;
  background: #f0f4ff;
}

.upload-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.upload-text {
  font-weight: 500;
  font-size: 0.9rem;
  color: #1f2a44;
}

.file-info {
  margin-top: 12px;
  background: #f8fafc;
  border-radius: 60px;
  padding: 0.4rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  border: 1px solid #e2e8f0;
  word-break: break-word;
  max-width: 100%;
}

.loader {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn {
  background: #4f46e5;
  color: white;
  border: none;
  padding: 0.7rem 1.2rem;
  border-radius: 44px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.2s;
  width: 100%;
  margin-top: 0.8rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn:active {
  transform: scale(0.98);
  background: #4338ca;
}

.btn:disabled {
  background: #b9c2d4;
  cursor: not-allowed;
  transform: none;
}

#generateBtn,
#generateBtn:hover,
#generateBtn:focus,
#generateBtn:active {
  background: #4f46e5;
  color: #ffffff;
}

#generateBtn.processing,
#generateBtn.processing:hover,
#generateBtn.processing:focus,
#generateBtn.processing:active,
#generateBtn.processing:disabled {
  background: #9ca3af;
  color: #ffffff;
  cursor: not-allowed;
  transform: none;
}

.action-group {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.action-outline {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 0.5rem 1rem;
  border-radius: 40px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  flex: 1;
  text-align: center;
}

.action-outline:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

@media (min-width: 1080px) {
  .history-trigger-mobile {
    display: none;
  }
}

.tabs-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
}

.tabs-row {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #edf2f7;
  padding-bottom: 0.5rem;
  min-width: min-content;
  align-items: center;
}

.tab-btn {
  background: none;
  border: none;
  font-size: 0.85rem;
  font-weight: 550;
  padding: 0.4rem 0.8rem;
  border-radius: 40px;
  color: #5b6e8c;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-btn.active {
  background: #eef2ff;
  color: #4f46e5;
}

.tab-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tab-loader {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #cbd5e1;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-left: 4px;
}

.content-pane {
  display: none;
  animation: fade 0.2s ease;
}

.content-pane.active-pane {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.transcript-line {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #f0f2f5;
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  word-break: break-word;
  min-width: 0;
}

.timestamp {
  font-family: monospace;
  font-size: 0.7rem;
  color: #6c86a3;
  min-width: 60px;
  flex-shrink: 0;
}

.line-text {
  color: #1e2a3e;
  line-height: 1.45;
  flex: 1;
  min-width: 0;
}

.transcript-line.is-highlighted {
  background: #fff8cc;
}

.transcript-highlight-mark {
  background: #fde68a;
  color: inherit;
  padding: 0 0.12rem;
  border-radius: 4px;
}

#transcriptContainer {
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  padding-bottom: 4rem;
}

#panelTranscript {
  position: relative;
}

.transcript-jump-btn {
  position: absolute;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #1e293b;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.transcript-jump-btn:hover {
  transform: translateX(-50%) translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

.transcript-jump-btn:active {
  transform: translateX(-50%) translateY(0);
}

.transcript-jump-btn[hidden] {
  display: none;
}

.global-popover {
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 120;
  max-width: 360px;
  background: #0f172a;
  color: #ffffff;
  font-size: 0.82rem;
  line-height: 1.35;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.32);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.global-popover.visible {
  opacity: 1;
  transform: translateY(0);
}

.summary-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

@media (min-width: 768px) {
  .summary-layout {
    flex-direction: row;
    gap: 2rem;
    align-items: flex-start;
  }
}

.summary-toc {
  flex-shrink: 0;
  background: #f8fafc;
  padding: 1rem;
  margin-bottom: 1rem;
  width: 100%;
}

@media (min-width: 768px) {
  .summary-toc {
    width: 240px;
    max-width: 240px;
    position: sticky;
    top: 20px;
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: transparent;
    padding: 0;
    margin-bottom: 0;
    scrollbar-width: thin;
  }
}

.summary-toc h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e2b3c;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #4f46e5;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toc-item {
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.8rem;
  color: #5b6e8c;
  transition: all 0.2s;
  border-left: 2px solid transparent;
  word-break: break-word;
}

.toc-item:hover {
  color: #4f46e5;
  border-left-color: #4f46e5;
  background-color: rgba(79, 70, 229, 0.05);
}

.toc-item.active {
  color: #3730a3;
  border-left-color: #4f46e5;
  background-color: rgba(79, 70, 229, 0.12);
  font-weight: 700;
}

.summary-content {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.summary-section {
  margin-bottom: 1.5rem;
  scroll-margin-top: 20px;
  padding: 1rem;
  border: 1px solid #eef2ff;
  border-radius: 16px;
  background: #ffffff;
}

.summary-section.is-active {
  border-color: #a5b4fc;
  background: #eef2ff;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.08), 0 10px 24px rgba(79, 70, 229, 0.08);
}

.summary-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e2b3c;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e9edf2;
}

.summary-section .content {
  line-height: 1.6;
  color: #334155;
}

.summary-section .content p {
  margin-bottom: 0.75rem;
}

.practice-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.practice-summary-card,
.practice-quiz-card {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  background: #ffffff;
  padding: 1rem;
}

.practice-summary-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.practice-summary-card h3,
.practice-quiz-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e2b3c;
  margin-bottom: 0.75rem;
}

.practice-divider {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 0.9rem 0;
}

.practice-section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.practice-section h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e2b3c;
}

.practice-action-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.9rem;
  gap: 8px;
  flex-wrap: wrap;
}

.practice-note {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: #64748b;
}

.practice-status {
  border: 1px solid #dbeafe;
  border-radius: 16px;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.edit-control {
  margin-bottom: 1rem;
  text-align: right;
}

.edit-btn {
  background: none;
  border: none;
  color: #6c86a3;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  transition: all 0.2s;
}

.edit-btn:hover {
  background: #f1f5f9;
  color: #4f46e5;
}

.edit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.markdown-editor-container {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
}

.markdown-editor-toolbar {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-btn {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
  color: #475569;
}

.toolbar-btn:hover {
  background: #eef2ff;
  border-color: #4f46e5;
  color: #4f46e5;
}

.markdown-editor {
  width: 100%;
  min-height: 400px;
  padding: 0.75rem;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  border: none;
  resize: vertical;
  background: white;
}

.markdown-editor:focus {
  outline: none;
}

.rich-editor {
  overflow-y: auto;
}

.rich-editor h2 {
  font-size: 1.05rem;
  margin: 0.8rem 0 0.45rem;
  color: #1e2b3c;
}

.rich-editor p {
  margin: 0 0 0.65rem;
  line-height: 1.6;
}

.rich-editor ul {
  margin: 0 0 0.75rem 1.1rem;
}

.quiz-item {
  background: #ffffff;
  border: 1px solid #eef2ff;
  border-radius: 20px;
  padding: 1rem;
  margin-bottom: 1rem;
}

@media (min-width: 768px) {
  .quiz-item {
    border-radius: 24px;
    padding: 1.5rem;
  }
}

.quiz-question {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: #1e2b3c;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin: 6px 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-option:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.quiz-item.is-answered .quiz-option {
  cursor: default;
  pointer-events: none;
}

.quiz-option.is-selected {
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}

.quiz-option label {
  cursor: pointer;
  flex: 1;
  color: #334155;
  font-size: 0.85rem;
  line-height: 1.4;
}

.quiz-option.correct-highlight {
  background: #e6f7e6;
  border-color: #22c55e;
}

.quiz-option.wrong-highlight {
  background: #fee2e2;
  border-color: #ef4444;
}

.quiz-feedback[hidden] {
  display: none;
}

.open-ended-area {
  margin: 1rem 0;
}

.quiz-editor {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.quiz-edit-item {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.9rem;
  background: #fcfdff;
}

.quiz-edit-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0.65rem;
}

.quiz-edit-number {
  font-size: 0.83rem;
  font-weight: 600;
  color: #1e2b3c;
}

.quiz-edit-type {
  font-size: 0.72rem;
  color: #475569;
  background: #eef2ff;
  padding: 2px 8px;
  border-radius: 999px;
}

.quiz-edit-label {
  font-size: 0.74rem;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.quiz-edit-textarea,
.quiz-edit-input,
.quiz-edit-select {
  width: 100%;
  border: 1px solid #d8e0eb;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.82rem;
  color: #1e293b;
  background: #ffffff;
}

.quiz-edit-textarea {
  resize: vertical;
  margin-bottom: 0.6rem;
}

.quiz-edit-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.45rem;
}

.quiz-edit-option-label {
  width: 18px;
  font-size: 0.76rem;
  color: #64748b;
}

.quiz-edit-correct-row {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #475569;
}

.quiz-edit-correct-row .quiz-edit-select {
  width: 80px;
  padding: 6px 8px;
}

.quiz-edit-actions,
.quiz-edit-global-actions {
  margin-top: 0.65rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.quiz-edit-global-add {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.quiz-edit-action-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.quiz-edit-action-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.quiz-edit-action-btn.danger {
  color: #b42318;
  border-color: #fecaca;
}

.quiz-edit-action-btn.danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
}

.open-ended-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
  margin-bottom: 0.75rem;
}

.open-ended-input:disabled {
  background: #f8fafc;
  color: #64748b;
}

.check-answer-btn,
.next-question-btn {
  background: #4f46e5;
  color: white;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 40px;
  font-weight: 500;
  font-size: 0.8rem;
  cursor: pointer;
}

.explanation-box {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #fef9e3;
  border-left: 4px solid #f59e0b;
  border-radius: 12px;
  font-size: 0.8rem;
  color: #92400e;
}

.next-btn-container {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

.error-action-row {
  margin-top: 0.75rem;
}

.quiz-complete {
  text-align: center;
  padding: 1.5rem;
  background: #f0fdf4;
  border-radius: 20px;
  color: #166534;
}

.quiz-final-loader {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  padding: 1.2rem;
  text-align: center;
}

.quiz-spinner {
  width: 30px;
  height: 30px;
  margin: 0 auto 0.65rem;
  border: 3px solid #dbeafe;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.quiz-final-loader-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
}

.quiz-final-loader-subtitle {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: #64748b;
}

.quiz-results-card {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  padding: 1rem;
}

.quiz-results-card h3 {
  font-size: 0.9rem;
  color: #1e293b;
  margin-bottom: 0.7rem;
}

.quiz-results-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .quiz-results-card {
    padding: 0.85rem;
    border-radius: 14px;
  }

  .quiz-results-card h3 {
    font-size: 0.84rem;
    margin-bottom: 0.6rem;
  }

  .quiz-results-grid {
    gap: 0.45rem;
  }
}

.quiz-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52% 48px;
  align-items: center;
  gap: 10px;
}

@media (max-width: 768px) {
  .quiz-result-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "subtopic subtopic"
      "progress percent";
    gap: 5px 8px;
  }
}

.quiz-result-subtopic {
  font-size: 0.78rem;
  color: #334155;
  line-height: 1.35;
}

@media (max-width: 768px) {
  .quiz-result-subtopic {
    grid-area: subtopic;
    font-size: 0.74rem;
  }
}

.quiz-result-progress-line {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

@media (max-width: 768px) {
  .quiz-result-progress-line {
    grid-area: progress;
    height: 8px;
  }
}

.quiz-result-progress-fill {
  height: 100%;
  border-radius: 999px;
}

.quiz-result-progress-fill.good {
  background: #22c55e;
}

.quiz-result-progress-fill.medium {
  background: #f59e0b;
}

.quiz-result-progress-fill.low {
  background: #ef4444;
}

.quiz-result-percent {
  text-align: right;
  font-size: 0.77rem;
  font-weight: 700;
  color: #334155;
}

@media (max-width: 768px) {
  .quiz-result-percent {
    grid-area: percent;
    align-self: center;
    font-size: 0.73rem;
  }
}

@media (max-width: 768px) {
  .quiz-result-recommendation {
    padding: 9px 10px;
    font-size: 0.76rem;
    line-height: 1.35;
    margin-top: 0.65rem;
  }
}

.quiz-result-recommendation {
  margin-top: 0.8rem;
  border-radius: 12px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 10px 12px;
}

.quiz-recommendation-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.quiz-recommendation-block {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 12px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.quiz-recommendation-block.high {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.quiz-recommendation-block.medium {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.analytics-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.speech-analysis-card {
  background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
}

.speech-format-card {
  border: 1px solid #dbeafe;
  background: #eff6ff;
  border-radius: 16px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
}

.speech-format-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #1d4ed8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.speech-format-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.35rem;
}

.speech-format-comment {
  font-size: 0.8rem;
  line-height: 1.45;
  color: #334155;
}

.speech-analysis-loader {
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: 16px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
  justify-content: center;
  padding: 1.3rem;
  text-align: center;
}

.speech-analysis-loader .spinner-small {
  width: 22px;
  height: 22px;
}

.speech-analysis-loader-text {
  font-size: 0.86rem;
  line-height: 1.5;
  color: #475569;
  max-width: 34rem;
}

.speech-analysis-action {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.9rem;
}

.speech-accordion {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.speech-accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.9rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e2b3c;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.speech-accordion > summary::-webkit-details-marker {
  display: none;
}

.speech-accordion > summary::after {
  content: '▾';
  color: #64748b;
  transition: transform 0.18s ease;
}

.speech-accordion[open] > summary {
  border-bottom: 1px solid #eef2f7;
  background: #f8fbff;
}

.speech-accordion[open] > summary::after {
  transform: rotate(180deg);
}

.speech-accordion-body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.speech-subcard {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
  padding: 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.speech-subcard-recommendation {
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  border-color: #dbeafe;
}

.speech-subcard-comment {
  background: #f8fafc;
}

.speech-subcard-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #1e293b;
}

.speech-subcard-text {
  font-size: 0.8rem;
  line-height: 1.55;
  color: #334155;
}

.speech-fragment-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.speech-fragment-list {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  color: #475569;
  font-size: 0.8rem;
  line-height: 1.6;
  word-break: break-word;
}

.speech-fragment-more {
  font-size: 0.8rem;
  line-height: 1.6;
  color: #475569;
}

.speech-fragment-line {
  min-width: 0;
}

.speech-fragment-link,
.speech-fragment-text {
  display: inline;
  font: inherit;
  text-align: left;
  padding: 0;
  margin: 0;
  border-radius: 0;
  word-break: break-word;
}

.speech-fragment-text {
  color: #334155;
}

.speech-fragment-type {
  color: #64748b;
  font-size: 0.9em;
  white-space: nowrap;
}

.speech-question-type {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(29, 78, 216, 0.08);
  color: #1d4ed8;
  font-size: 0.78em;
  white-space: nowrap;
  vertical-align: middle;
}

.speech-fragment-link {
  color: #1d4ed8;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  border: 0;
  background: transparent;
  line-height: inherit;
  transition: color 0.15s ease, opacity 0.15s ease, text-decoration-color 0.15s ease;
}

.speech-fragment-link:hover {
  color: #1d4ed8;
  opacity: 0.8;
  text-decoration-color: currentColor;
}

.speech-fragment-link:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 4px;
}

.speech-fragment-more-btn {
  list-style: none;
  align-self: flex-start;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 0.42rem 0.8rem;
  font-size: inherit;
  line-height: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.speech-fragment-more-btn::-webkit-details-marker {
  display: none;
}

.speech-fragment-more-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.08);
}

.speech-fragment-more-btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.speech-fragment-more[open] > .speech-fragment-more-btn {
  display: none;
}

.speech-fragment-hidden {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.4rem;
  font-size: inherit;
  line-height: inherit;
}

.speech-check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0.5rem;
  flex-wrap: nowrap;
}

.speech-check-label {
  min-width: 0;
  flex: 1;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #1e293b;
  font-weight: 700;
}

.speech-check {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 800;
}

.speech-check.yes {
  background: #dcfce7;
  color: #166534;
}

.speech-check.no {
  background: #fee2e2;
  color: #b91c1c;
}

.speech-check-comment-inline {
  display: inline;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #475569;
}

.speech-goal-row {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
  margin-bottom: 0.55rem;
  background: #ffffff;
}

.speech-goal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.speech-goal-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e293b;
}

.speech-goal-badge {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.76rem;
  font-weight: 800;
}

.speech-goal-badge.yes {
  background: #dcfce7;
  color: #166534;
}

.speech-goal-badge.no {
  background: #fee2e2;
  color: #b91c1c;
}

.speech-goal-comment {
  margin-top: 0.5rem;
  font-size: 0.77rem;
  line-height: 1.45;
  color: #475569;
}

.speech-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.speech-timeline-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
}

.speech-timeline-time {
  font-size: 0.75rem;
  font-weight: 700;
  color: #1d4ed8;
  background: #eff6ff;
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  text-align: center;
}

.speech-timeline-body {
  border-left: 2px solid #dbeafe;
  padding-left: 0.75rem;
}

.speech-timeline-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e293b;
}

.speech-timeline-comment {
  margin-top: 0.25rem;
  font-size: 0.76rem;
  line-height: 1.45;
  color: #475569;
}

.speech-analysis-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.speech-export-btn {
  border: 1px solid #c4b5fd;
  background: linear-gradient(180deg, #8b5cf6 0%, #7c3aed 100%);
  color: #ffffff;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(124, 58, 237, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.speech-export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(124, 58, 237, 0.22);
}

.speech-export-btn:active {
  transform: translateY(0);
}

.speech-export-btn:disabled,
.speech-export-btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.58;
  filter: saturate(0.75);
  box-shadow: none;
  transform: none;
}

.speech-export-btn:disabled:hover,
.speech-export-btn[aria-disabled="true"]:hover {
  transform: none;
  box-shadow: none;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 0.75rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
}

.markdown-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.82rem;
}

.markdown-table th,
.markdown-table td {
  min-width: 100px;
  max-width: 240px;
  width: clamp(100px, 18vw, 240px);
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  vertical-align: top;
  text-align: left;
  line-height: 1.45;
  word-break: break-word;
}

.markdown-table th:last-child,
.markdown-table td:last-child {
  border-right: 0;
}

.markdown-table thead th {
  background: #eff6ff;
  font-weight: 700;
  color: #1e293b;
}

.markdown-table tbody tr:last-child td {
  border-bottom: 0;
}

.inline-code {
  display: inline-block;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  background: #f3e8ff;
  color: #7c3aed;
  font-weight: 600;
  white-space: normal;
}

.analytics-card {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  padding: 0.9rem;
}

.analytics-card.analytics-card-disabled {
  opacity: 0.55;
  filter: grayscale(0.2);
}

.analytics-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e2b3c;
  margin-bottom: 0.6rem;
}

.analytics-link {
  font-size: 0.82rem;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 8px 10px;
  word-break: break-all;
}

.analytics-link-actions {
  display: flex;
  gap: 8px;
  margin-top: 0.55rem;
  flex-wrap: wrap;
}

.analytics-btn {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
  min-width: 0;
  flex: 1 1 0;
}

.analytics-btn:hover {
  background: #f8fafc;
}

.analytics-btn.outline {
  background: #ffffff;
  color: #334155;
}

.analytics-btn.outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.analytics-btn.filled {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.analytics-btn.filled:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.analytics-btn.copied,
.analytics-btn.copied:hover {
  background: #059669;
  border-color: #059669;
  color: #ffffff;
}

.analytics-meta {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.6rem;
}

.analytics-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48% 46px;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.55rem;
}

@media (max-width: 768px) {
  .analytics-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "subtopic subtopic"
      "progress percent";
    gap: 6px 10px;
  }
}

.analytics-subtopic {
  font-size: 0.78rem;
  color: #334155;
  line-height: 1.35;
}

@media (max-width: 768px) {
  .analytics-subtopic {
    grid-area: subtopic;
    font-size: 0.75rem;
  }
}

.analytics-progress-line {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

@media (max-width: 768px) {
  .analytics-progress-line {
    grid-area: progress;
    height: 8px;
  }
}

.analytics-progress-fill {
  height: 100%;
  border-radius: 999px;
}

.analytics-progress-fill.good {
  background: #22c55e;
}

.analytics-progress-fill.medium {
  background: #f59e0b;
}

.analytics-progress-fill.low {
  background: #ef4444;
}

.analytics-percent {
  font-size: 0.77rem;
  font-weight: 700;
  color: #334155;
  text-align: right;
}

@media (max-width: 768px) {
  .analytics-percent {
    grid-area: percent;
    align-self: center;
    font-size: 0.74rem;
  }
}

.analytics-reco-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.analytics-reco {
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
}

.analytics-reco-topic {
  font-weight: 400;
  color: #1e293b;
}

.analytics-reco-action {
  margin-top: 2px;
}

.math-scroll-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.code-block {
  background: #f6f8fa;
  border-radius: 12px;
  padding: 1rem;
  margin: 0.75rem 0;
  overflow-x: auto;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  border: 1px solid #d0d7de;
}

.code-block code {
  background: transparent;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: #24292f;
  white-space: pre;
}

.math-scroll-wrap > .katex-display {
  display: inline-block;
  margin: 0.2rem 0;
  min-width: 100%;
}

.analytics-reco.high {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.analytics-reco.medium {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.analytics-reco.muted {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
}

.analytics-card.analytics-card-disabled .analytics-progress-fill {
  background: #cbd5e1 !important;
}

.analytics-card.analytics-card-disabled .analytics-reco {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #64748b;
}

@media (max-width: 768px) {
  .speech-accordion > summary {
    padding: 0.82rem 0.9rem;
    font-size: 0.86rem;
  }

  .speech-accordion-body {
    padding: 0.85rem 0.9rem 0.9rem;
  }

  .speech-timeline-item {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .speech-timeline-body {
    border-left: 0;
    padding-left: 0;
  }

  .speech-analysis-footer {
    justify-content: stretch;
  }

  .speech-export-btn {
    width: 100%;
  }
}

.analytics-disabled-note {
  margin-top: 0.55rem;
  font-size: 0.72rem;
  color: #64748b;
}

.question-type-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.question-type-btn {
  width: 100%;
  border: 1px solid #dbe4ef;
  background: #ffffff;
  color: #1e2b3c;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.question-type-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.status-message {
  font-size: 0.78rem;
  color: #6c86a3;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-message-error {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.status-message-error .next-btn-container {
  width: 100%;
  justify-content: flex-start;
  margin-top: 0;
}

.spinner-small {
  width: 14px;
  height: 14px;
  border: 2px solid #e2e8f0;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

.progress-fixed {
  display: inline-block;
  min-width: 2.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.history-header {
  margin-bottom: 0.9rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.history-empty {
  padding: 1rem;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  color: #6c86a3;
  font-size: 0.83rem;
  text-align: center;
}

.history-item {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 0.75rem;
  background: #fcfdff;
  transition: border-color 0.2s, background 0.2s;
}

.history-item.active {
  border-color: #4f46e5;
  background: #f7f8ff;
}

.history-item-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: #1e2b3c;
  margin-bottom: 0.45rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-row {
  margin-bottom: 0.45rem;
}

.history-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}

.status-completed {
  background: #e8fbe8;
  color: #137333;
}

.status-processing {
  background: #edf2f7;
  color: #465468;
}

.status-failed {
  background: #fee2e2;
  color: #b42318;
}

.status-expired {
  background: #f1f5f9;
  color: #64748b;
}

.spinner-dot {
  width: 11px;
  height: 11px;
  border: 2px solid #cbd5e1;
  border-top-color: #64748b;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.history-meta {
  font-size: 0.73rem;
  color: #64748b;
  line-height: 1.35;
  margin-bottom: 0.55rem;
  word-break: break-word;
}

.history-actions {
  display: flex;
  gap: 8px;
}

.history-btn {
  background: white;
  border: 1px solid #dbe4ef;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.74rem;
  cursor: pointer;
  color: #334155;
}

.history-btn:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.history-btn.danger {
  color: #b42318;
}

.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 90;
}

.history-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.16);
  max-height: 72vh;
  padding: 0.7rem 1rem 1rem;
  z-index: 91;
  transform: translateY(100%);
  transition: transform 0.22s ease;
  overflow: auto;
}

.history-drawer.open {
  transform: translateY(0);
}

.question-type-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 120;
  display: none;
}

.question-type-overlay:not([hidden]) {
  display: block;
}

.question-type-drawer {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px));
  max-height: min(70vh, 560px);
  overflow: auto;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(2, 6, 23, 0.2);
  padding: 1rem;
  z-index: 121;
  display: none;
}

.question-type-drawer.open {
  display: block;
}

.question-type-drawer-handle {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: #cbd5e1;
  margin: 0 auto 0.75rem;
}

.question-type-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.history-drawer-handle {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: #cbd5e1;
  margin: 0 auto 0.75rem;
}

.history-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.drawer-close {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

@media (min-width: 1080px) {
  .history-drawer,
  .history-overlay {
    display: none;
  }
}

@media (max-width: 1079px) {
  .history-sidebar {
    display: none;
  }

  .question-type-drawer {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    max-height: 72vh;
    border-radius: 18px 18px 0 0;
    padding: 0.7rem 1rem 1rem;
    transform: translateY(100%);
    transition: transform 0.22s ease;
  }

  .question-type-drawer.open {
    display: block;
    transform: translateY(0);
  }

  .analytics-link-actions {
    flex-direction: column;
  }

  .analytics-btn {
    width: 100%;
    flex: 1 1 auto;
    padding: 0.7rem 0.9rem;
    font-size: 0.78rem;
  }
}

.text-truncate {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
