* {
  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;
}

.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.7rem 0;
  border-bottom: 1px solid #f0f2f5;
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  word-break: break-word;
}

.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;
}

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

.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);
}

.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 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;
}

.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-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;
}

.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;
}

.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;
}

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

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

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

.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;
}

.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;
}

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

.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;
  background: #ffffff;
  color: #334155;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

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

.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;
}

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

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

.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;
}

.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.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;
}

.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;
}

.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;
}

.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);
  }
}
