/* ==========================================
   TabKeeper Mobile Web App Styling
   (Eye-Care Warm Light Theme & Mobile Optimized)
   ========================================== */

:root {
  /* 눈이 편안한 웜 라이트 테마 기본 (Soft Slate & Paper Cream) */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --accent-primary: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.08);

  --highlight-box: #f8faff;
  --highlight-border: #c7d2fe;

  --badge-bg: rgba(79, 70, 229, 0.1);
  --badge-text: #4338ca;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.09);

  --font-base: -apple-system, BlinkMacSystemFont, "Pretendard Variable", Pretendard, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

[data-theme="dark"] {
  --bg-page: #0b0f19;
  --bg-card: #151d2f;
  --bg-subtle: #1e293b;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  --text-main: #f8fafc;
  --text-body: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #818cf8;
  --accent-hover: #6366f1;
  --accent-soft: rgba(129, 140, 248, 0.12);

  --highlight-box: rgba(99, 102, 241, 0.08);
  --highlight-border: rgba(99, 102, 241, 0.35);

  --badge-bg: rgba(129, 140, 248, 0.15);
  --badge-text: #a5b4fc;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-page);
  color: var(--text-body);
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.2px;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
}

.mobile-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: calc(40px + var(--safe-bottom));
}

/* ==========================================
   Header Navbar
   ========================================== */
.mobile-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: calc(12px + var(--safe-top)) 16px 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, #3b82f6 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.brand-titles h1 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-install-app {
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, #3b82f6 100%);
  border: none;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
  animation: pulseButton 2s infinite ease-in-out;
}

@keyframes pulseButton {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.mobile-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mobile-icon-btn:hover {
  background: var(--border-strong);
  transform: translateY(-1px);
}

.guide-step {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 12px 14px;
  border-radius: 10px;
}

.guide-step strong {
  display: block;
  font-size: 13.5px;
  color: var(--text-main);
  margin-bottom: 4px;
}

.guide-step p {
  font-size: 13px;
  color: var(--text-body);
  line-height: 1.6;
}

/* ==========================================
   Main Content & Cards
   ========================================== */
.mobile-main {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mobile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-md);
}

.card-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
  display: block;
  margin-bottom: 16px;
}

/* URL Input Box */
.url-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.url-input-wrap input {
  width: 100%;
  height: 48px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0 95px 0 14px;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease;
}

.url-input-wrap input:focus {
  border-color: var(--accent-primary);
  background: var(--bg-card);
}

.btn-input-clear {
  position: absolute;
  right: 85px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}

.btn-paste {
  position: absolute;
  right: 6px;
  height: 36px;
  padding: 0 10px;
  background: var(--accent-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s ease;
}

.btn-paste:active {
  background: var(--border-strong);
}

/* Video Preview Card */
.video-preview-card {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  margin-bottom: 14px;
  animation: fadeIn 0.2s ease;
}

.preview-thumb {
  width: 90px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #000000;
}

.preview-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  gap: 2px;
}

.preview-badge {
  font-size: 9.5px;
  font-weight: 700;
  color: #dc2626;
  background: rgba(239, 68, 68, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
  align-self: flex-start;
}

.preview-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.preview-author {
  font-size: 11px;
  color: var(--text-muted);
}

/* Buttons */
.action-btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-primary-gradient {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 50%, #4f46e5 100%);
  border: none;
  border-radius: 12px;
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-primary-gradient:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.sub-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ==========================================
   Source Mode Tabs (YouTube / File / Text)
   ========================================== */
.source-tab-bar {
  display: flex;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
  margin-bottom: 16px;
}

.source-tab-btn {
  flex: 1;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.source-tab-btn.active {
  background: var(--bg-card);
  color: var(--accent-primary);
  font-weight: 750;
  box-shadow: var(--shadow-sm);
}

.source-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* File Drop Zone */
.file-drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: 14px;
  padding: 24px 16px;
  text-align: center;
  background: var(--bg-subtle);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.file-drop-zone.dragover {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.file-input-hidden {
  display: none;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.drop-icon {
  font-size: 32px;
  margin-bottom: 4px;
}

.drop-title {
  font-size: 14.5px;
  color: var(--text-main);
}

.drop-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.btn-browse {
  padding: 0 16px;
}

/* Selected File Card */
.selected-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--highlight-box);
  border: 1px solid var(--highlight-border);
  padding: 12px 14px;
  border-radius: 12px;
  margin-top: 4px;
}

.file-info-icon {
  font-size: 24px;
}

.file-info-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.selected-file-name {
  font-size: 13.5px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selected-file-size {
  font-size: 11.5px;
  color: var(--text-muted);
}

.btn-remove-file {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* Raw Text Input Wrap */
.text-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.text-input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.btn-paste-sm {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
}

.text-input-wrap textarea {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-main);
  resize: vertical;
  outline: none;
  font-family: inherit;
  min-height: 120px;
}

.text-input-wrap textarea:focus {
  border-color: var(--accent-primary);
  background: var(--bg-card);
}

.btn-secondary-action {
  height: 42px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-secondary-action:active {
  background: var(--border-strong);
}

/* Multi-video box */
.multi-video-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.multi-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.multi-video-box textarea {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  color: var(--text-main);
  resize: vertical;
  outline: none;
  font-family: inherit;
}

/* ==========================================
   Loading View
   ========================================== */
.loading-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 20px;
  gap: 14px;
}

.mobile-spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-view h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.loading-view p {
  font-size: 13px;
  color: var(--text-muted);
}

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

/* ==========================================
   Report Viewer Section & Typography
   ========================================== */
.report-view-section {
  padding: 24px 20px;
}

.report-top-bar {
  margin-bottom: 16px;
}

.report-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--badge-text);
  background: var(--badge-bg);
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 6px;
}

.report-display-title {
  font-size: 16px;
  font-weight: 750;
  color: var(--text-main);
  line-height: 1.4;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* Mobile Action Bar */
.mobile-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 16px 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.dropdown-wrap {
  position: relative;
}

.action-btn {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  border: 1px solid var(--border-subtle);
}

.action-btn.primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.action-btn.secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.dropdown-content {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 200;
  animation: fadeIn 0.15s ease;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.menu-item:active {
  background: var(--bg-subtle);
}

.menu-icon { font-size: 16px; }
.menu-text strong { font-size: 13px; color: var(--text-main); display: block; }
.menu-text small { font-size: 10.5px; color: var(--text-muted); display: block; }

/* Report Typography (모바일 화면에 알맞은 균형잡힌 헤딩 크기) */
.report-render-area {
  font-size: 16px;
  line-height: 1.85;
  color: var(--text-body);
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* 영상 메인 제목 H1 - 과도하게 크지 않은 적당하고 세련된 크기 */
.report-render-area h1,
.report-render-area .md-h1 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.45;
  margin: 10px 0 12px 0;
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--border-subtle);
}

/* 섹션 대제목 H2 - 1. 개요, 2. 타임라인 요약 등 */
.report-render-area h2,
.report-render-area .md-h2 {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--accent-primary);
  margin-top: 24px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
  border-left: 3px solid var(--accent-primary);
  padding-left: 8px;
}

/* 챕터 소제목 H3 */
.report-render-area h3,
.report-render-area .md-h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 18px;
  margin-bottom: 8px;
  line-height: 1.4;
}

.report-render-area h4,
.report-render-area .md-h4 {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-body);
  margin-top: 14px;
  margin-bottom: 6px;
}

.report-render-area hr,
.report-render-area .md-divider {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: 18px 0;
}

.report-render-area blockquote,
.report-render-area .md-quote {
  background: var(--highlight-box);
  border-left: 3.5px solid var(--accent-primary);
  padding: 10px 14px;
  margin: 12px 0;
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.report-render-area .md-numbered-block {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 0;
  background: var(--bg-subtle);
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.report-render-area .num-badge {
  background: var(--accent-primary);
  color: #ffffff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 3px;
}

.report-render-area .num-content {
  flex: 1;
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--text-body);
}

.report-render-area .md-bullet-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0;
  font-size: 15.5px;
  line-height: 1.75;
}

.report-render-area .bullet-dot {
  color: var(--accent-primary);
  font-weight: bold;
  font-size: 15px;
  flex-shrink: 0;
}

.report-render-area .bullet-content {
  flex: 1;
}

.report-render-area .md-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0;
  font-size: 15.5px;
  line-height: 1.75;
}

.report-render-area .chk-box {
  color: var(--accent-primary);
  font-size: 15px;
  flex-shrink: 0;
}

.report-render-area .md-p {
  margin: 8px 0;
  font-size: 15.5px;
  line-height: 1.8;
}

.report-render-area .md-code-block {
  background: #1e293b;
  color: #f8fafc;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  overflow-x: auto;
  margin: 12px 0;
}

.report-render-area .md-inline-code {
  background: var(--bg-subtle);
  color: var(--accent-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13.5px;
  font-family: monospace;
}

.numbered-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0 16px 0;
  font-size: 16.5px;
  line-height: 1.85;
  color: var(--text-body);
}

.numbered-item .item-num {
  font-weight: 700;
  color: var(--accent-primary);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 13.5px;
  flex-shrink: 0;
  margin-top: 3px;
}

.numbered-item .item-text {
  flex: 1;
}

.bullet-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 0 14px 0;
  font-size: 16.5px;
  line-height: 1.85;
  color: var(--text-body);
}

.bullet-item .bullet-dot {
  color: var(--accent-primary);
  font-weight: bold;
  font-size: 16px;
  line-height: 1.5;
  flex-shrink: 0;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 14px 0;
  font-size: 16.5px;
  line-height: 1.85;
}

.spacer-block {
  height: 14px;
}

.report-render-area table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 14px;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.report-render-area th {
  background: var(--highlight-box);
  color: var(--text-main);
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border-subtle);
}

.report-render-area td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  line-height: 1.6;
}

.report-render-area hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 28px 0;
}

.report-render-area strong {
  color: var(--text-main);
  font-weight: 700;
}

.report-render-area a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 600;
}

/* ==========================================
   History Section
   ========================================== */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-title-wrap h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.btn-text-danger {
  background: transparent;
  border: none;
  color: #ef4444;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.history-search-wrap input {
  width: 100%;
  height: 38px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.history-card-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 8px;
}

.history-card-item:active {
  background: var(--border-strong);
}

.history-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  flex: 1;
}

.history-item-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-del-history {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  padding: 4px;
  cursor: pointer;
}

.empty-history {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 24px 12px;
  line-height: 1.5;
}

/* ==========================================
   Settings Modal (Bottom Sheet)
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-sheet {
  width: 100%;
  max-width: 640px;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + var(--safe-bottom)) 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sheet-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
}

.btn-close-modal {
  background: var(--bg-subtle);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
}

.sheet-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.key-input-row {
  display: flex;
  gap: 6px;
}

.key-input-row input {
  flex: 1;
  height: 42px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
}

.btn-icon-key {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.link-get-key {
  font-size: 11.5px;
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 600;
  align-self: flex-start;
  margin-top: 2px;
}

.api-status-msg {
  font-size: 11.5px;
  color: var(--text-muted);
  min-height: 16px;
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

/* ==========================================
   Toast Notification
   ========================================== */
.toast-container {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  max-width: 608px;
  margin: 0 auto;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--text-main);
  color: var(--bg-card);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideUpToast 0.2s ease;
  pointer-events: auto;
}

@keyframes slideUpToast {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }
