:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --text: #e8eaed;
  --muted: #9aa0b0;
  --primary: #4f8cff;
  --primary-hover: #3a7aef;
  --success: #34c759;
  --warning: #f5a623;
  --danger: #ff453a;
  --radius: 12px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  overflow: hidden;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow: hidden;
}

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem;
}
.container-wide {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.25rem;
}
@media (min-width: 1400px) {
  .container-wide { max-width: 1360px; }
}

/* Header */
.header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.header .container-wide { max-width: 1280px; }
@media (min-width: 1400px) { .header .container-wide { max-width: 1360px; } }
.logo {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.logo small { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.logo-icon { color: var(--primary); }
.nav { display: flex; align-items: center; gap: 0.75rem; }
.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.avatar {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-grid;
  place-items: center;
  background: var(--surface2);
  flex: none;
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-initial {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
}

/* Main */
.main {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.main > .container-wide {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-top: 1.25rem;
  padding-bottom: 1rem;
  overflow: hidden;
}
.footer {
  flex-shrink: 0;
}


.hero { text-align: center; margin-bottom: 2rem; }
.hero h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; }
.subtitle { color: var(--muted); font-size: 1rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.login-prompt {
  text-align: center;
  padding: 2.5rem 1.75rem;
}
.login-prompt p { color: var(--muted); margin-bottom: 1.25rem; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.tab {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.tab:hover { color: var(--text); border-color: var(--primary); }
.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Form */
.analyze-form label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
.analyze-form input[type="url"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 0.5rem;
  outline: none;
  transition: border-color 0.15s;
}
.analyze-form input[type="url"]:focus { border-color: var(--primary); }
.hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.25rem; }

.file-drop {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem 1rem;
  text-align: center;
  margin-bottom: 0.5rem;
  transition: border-color 0.15s;
}
.file-drop:hover { border-color: var(--primary); }
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-label { color: var(--muted); pointer-events: none; }
.file-name { color: var(--primary); font-weight: 500; margin-top: 0.4rem; font-size: 0.9rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.btn-lg { padding: 0.85rem 1.5rem; font-size: 1rem; width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-outline:hover { border-color: var(--text); color: var(--text); }
.btn-google {
  background: #fff;
  color: #333;
  border: 1px solid #dadce0;
}
.btn-google:hover { background: #f7f8f8; }
.btn-facebook {
  background: #1877f2;
  color: #fff;
  border: 1px solid #1877f2;
}
.btn-facebook:hover { background: #166fe5; }

.login-card {
  max-width: 420px;
  margin: 0 auto;
  padding: 2.5rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-card h1 { font-size: 1.5rem; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 0.95rem; }
.login-card .btn { width: 100%; }

/* Alerts */
.flashes { margin-bottom: 1.25rem; }
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.alert-success { background: rgba(52,199,89,0.15); color: var(--success); border: 1px solid rgba(52,199,89,0.3); }
.alert-warning { background: rgba(245,166,35,0.15); color: var(--warning); border: 1px solid rgba(245,166,35,0.3); }
.alert-danger  { background: rgba(255,69,58,0.15);  color: var(--danger);  border: 1px solid rgba(255,69,58,0.3); }
.alert-info    { background: rgba(79,140,255,0.15); color: var(--primary); border: 1px solid rgba(79,140,255,0.3); }

/* Result */
.result-card {
  text-align: center;
  padding: 2.5rem 1.75rem;
}
.result-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.result-filename {
  font-weight: 600;
  margin-bottom: 1.5rem;
  word-break: break-all;
  color: var(--muted);
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---- Progressive progress overlay (v1.2) ---- */
.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.25rem;
}
.progress-overlay[hidden] { display: none !important; }

.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 1.25rem;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.progress-bar-wrap {
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7eb0ff);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-percent {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary);
  margin-bottom: 0.35rem;
}
.progress-msg {
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.4em;
  margin-bottom: 1.25rem;
}

.progress-steps {
  list-style: none;
  text-align: left;
  margin: 0 0 1rem;
  padding: 0;
}
.progress-steps li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: 0.88rem;
  color: var(--muted);
  transition: color 0.2s;
}
.progress-steps li.step-active {
  color: var(--primary);
  font-weight: 600;
}
.progress-steps li.step-done {
  color: var(--success);
}
.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}
.step-active .step-dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,140,255,0.25);
}
.step-done .step-dot {
  background: var(--success);
}

.progress-actions { margin-top: 0.5rem; }
.progress-error { margin-top: 0.5rem; }

/* Busy / disabled state */
body.is-busy .tab,
body.is-busy .btn-primary,
body.is-busy input,
body.is-busy .file-drop {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}
body.is-busy .tab.disabled,
.tab.disabled,
.btn-primary:disabled,
input:disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

/* ---- Disclaimer (v1.3) ---- */
.disclaimer {
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.35);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
}
.disclaimer strong {
  color: var(--warning);
}
.disclaimer p {
  margin-top: 0.45rem;
}
.disclaimer p:first-of-type {
  margin-top: 0.35rem;
}


/* ---- Disclaimer variants (v2.1) ---- */
.disclaimer-tip {
  background: rgba(79, 140, 255, 0.08);
  border-color: rgba(79, 140, 255, 0.35);
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}
.disclaimer-tip strong {
  color: var(--primary);
}



/* ========== v2.7.1 Home layout + sidebar + modal (dark-aware) ========== */

/* Mobile view tabs — hidden on desktop */
.view-tabs {
  display: none;
  grid-column: 1 / -1;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.view-tab {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.view-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 1.5rem;
  align-items: stretch;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 1100px) {
  .home-layout {
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 1.75rem;
  }
}

.home-main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.home-sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.sidebar-head h2 {
  font-size: 0.95rem;
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.sidebar-search {
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
}
.sidebar-search input::placeholder { color: var(--muted); }
.search-hint {
  margin: -0.45rem 0 0.6rem;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
}
.sidebar-search input:focus {
  outline: none;
  border-color: var(--primary);
}

.output-list {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-right: 0.2rem;
  -webkit-overflow-scrolling: touch;
}

.output-list::-webkit-scrollbar { width: 6px; }
.output-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1.5rem 0.5rem;
  margin: 0;
}

.out-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: var(--surface2);
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.out-item:hover {
  border-color: rgba(79, 140, 255, 0.45);
}

.btn:disabled,
.btn.is-locked {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-outline.is-locked:hover,
.btn.is-locked:hover {
  border-color: var(--border);
  color: var(--text);
  background: transparent;
}

.out-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.out-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.out-badge {
  background: rgba(79, 140, 255, 0.15);
  color: var(--primary);
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.7rem;
}

.out-badge-share {
  background: rgba(52, 199, 89, 0.18);
  color: var(--success);
}

.out-owner {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: italic;
}

.credit-wrap { position: relative; display: inline-flex; }

.credit-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(79, 140, 255, 0.15);
  color: var(--primary);
  padding: 0.18rem 0.22rem 0.18rem 0.7rem;
  border: 0;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.credit-chip:hover { background: rgba(79, 140, 255, 0.24); }
.credit-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.credit-chip-text { display: inline-flex; align-items: center; gap: 0.3rem; }

.credit-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(79, 140, 255, 0.28);
  color: var(--primary);
  font-size: 0.95rem;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}
.credit-plus:hover { background: rgba(79, 140, 255, 0.45); }
.credit-plus:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.credit-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(300px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
  z-index: 80;
}
.credit-pop[hidden] { display: none; }

.credit-pop-title { font-size: 0.95rem; font-weight: 700; color: var(--text); margin-bottom: 10px; }

.credit-total {
  border-radius: 12px;
  padding: 12px 14px 14px;
  background: linear-gradient(135deg, #6ea8ff 0%, #4f8cff 45%, #3a7aef 100%);
  color: #ffffff;
  margin-bottom: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.credit-total-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  opacity: 0.85;
}
.credit-total-value { font-size: 1.7rem; font-weight: 800; line-height: 1.15; margin-top: 2px; }

.credit-breakdown-label {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.credit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface2);
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.credit-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.credit-dot-free { background: #8ab4ff; }
.credit-dot-bonus { background: #34c759; }
.credit-dot-paid { background: #2f6fe0; }
.credit-row-name { flex: 1; color: var(--text); }
.credit-row-val { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.credit-expire {
  font-size: 0.68rem;
  color: var(--warning);
  margin: -2px 0 6px 18px;
  line-height: 1.35;
}

.credit-note { font-size: 0.72rem; color: var(--muted); line-height: 1.45; margin: 8px 0 10px; }
.credit-buy-btn { width: 100%; }

.user-code {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
}
.user-code:hover { color: var(--text); border-color: var(--text); }

.modal-shares { max-width: 520px; }
.shares-body { padding: 0.5rem 1rem; }
.share-add { display: flex; gap: 0.5rem; margin-bottom: 0.4rem; }
.share-add input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.7rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.share-count { color: var(--muted); font-size: 0.78rem; margin-bottom: 0.4rem; }
.share-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.share-row:last-child { border-bottom: none; }
.share-name { font-weight: 600; font-size: 0.85rem; }
.share-email {
  color: var(--muted);
  font-size: 0.78rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-purchase { max-width: 460px; }
.purchase-body { padding: 1rem 1.35rem 1.2rem; }
.purchase-bal { font-size: 0.9rem; color: var(--text); margin-bottom: 0.4rem; }
.purchase-rate { color: var(--muted); font-size: 0.82rem; margin-bottom: 0.75rem; }
.purchase-packages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
.purchase-pkg { flex: 1 1 40%; white-space: nowrap; }
.purchase-custom label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.4rem; }
.purchase-custom-row { display: flex; gap: 0.5rem; }
.purchase-custom-row input {
  flex: 1;
  padding: 0.45rem 0.7rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.purchase-receipt { text-align: left; padding: 0.15rem 0.1rem 0.25rem; }
.purchase-receipt h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.pr-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.pr-row span { color: var(--muted); }
.pr-code { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--primary); }
.pr-note { color: var(--muted); font-size: 0.78rem; margin: 0.75rem 0; line-height: 1.5; }
.purchase-receipt-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.pr-qr { text-align: center; margin-bottom: 0.4rem; }
.pr-qr img { width: 180px; height: 180px; background: #fff; border-radius: 10px; padding: 0.4rem; }
.pr-qr-hint { color: var(--muted); font-size: 0.76rem; text-align: center; margin-bottom: 0.6rem; }
.pr-value-copy { display: flex; align-items: center; gap: 0.4rem; }
.copy-mini {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--primary);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.copy-mini:hover { border-color: var(--primary); }

.out-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.out-actions .btn-sm {
  padding: 0.28rem 0.55rem;
  font-size: 0.75rem;
}

.out-yt {
  font-size: 0.75rem;
  color: #ff6b6b;
  text-decoration: none;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
}
.out-yt:hover { text-decoration: underline; color: #ff8787; }

/* Modal — dark theme */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.modal-overlay[hidden] { display: none !important; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(900px, 100%);
  max-height: min(90vh, 920px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  color: var(--text);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  padding-right: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-close {
  border: none;
  background: var(--surface2);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem 0.55rem;
  border-radius: 8px;
}
.modal-close:hover { color: var(--text); }

/* Confirm modal — credit + duplicate warning */
.modal-confirm { width: min(480px, 100%); }
.confirm-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
}
.confirm-source {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
  line-height: 1.45;
}
.confirm-source .confirm-id {
  display: block;
  margin-top: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
}
.confirm-note {
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.6rem 0.75rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
}
.confirm-note[hidden] { display: none !important; }
.confirm-note.is-warn {
  border-color: rgba(245, 166, 35, 0.45);
  background: rgba(245, 166, 35, 0.12);
  color: #ffd18a;
}
.confirm-note.is-info {
  border-color: rgba(79, 140, 255, 0.4);
  background: rgba(79, 140, 255, 0.12);
  color: #bfd3ff;
}
.confirm-cost {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.confirm-amount { font-weight: 700; color: var(--text); }
.confirm-balance { font-size: 0.82rem; }
.confirm-short { font-size: 0.82rem; color: var(--danger); }

/* Inline duplicate hint under the YouTube link input */
.dup-hint {
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #bfd3ff;
}
.dup-hint[hidden] { display: none !important; }
.dup-hint.dup-warn { color: #ffd18a; }
.dup-hint.dup-info { color: #bfd3ff; }

.modal-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  padding: 0.65rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.modal-toolbar input[type="search"] {
  flex: 1;
  min-width: 140px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
.modal-toolbar input[type="search"]::placeholder { color: var(--muted); }
.modal-toolbar input[type="search"]:focus {
  outline: none;
  border-color: var(--primary);
}
.wrap-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.modal-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: auto;
}
.modal-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
  min-height: 180px;
  background: var(--bg);
}
.transcript-pre {
  margin: 0;
  padding: 1rem 1.15rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.transcript-pre.wrap {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.transcript-pre.nowrap {
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  overflow-x: auto;
}
.transcript-pre.paras {
  white-space: normal;
}
.transcript-pre.paras p,
.transcript-pre .t-para {
  margin: 0 0 1.05em;
  line-height: 1.65;
}
.t-time {
  display: inline-block;
  margin-bottom: 0.28em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--primary);
  text-decoration: none;
}
a.t-time:hover { text-decoration: underline; }
.t-para .t-body { display: block; }
.transcript-pre.paras.wrap p {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.transcript-pre.paras.nowrap p {
  white-space: pre;
  overflow-x: auto;
}
.transcript-pre mark {
  background: rgba(245, 166, 35, 0.45);
  color: var(--text);
  padding: 0 0.12em;
  border-radius: 2px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.15rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

body.is-busy .home-sidebar {
  opacity: 0.65;
  pointer-events: none;
}

/* ---- Mobile: tabbed Analyze | Library ---- */
@media (max-width: 900px) {
  .view-tabs {
    display: flex;
  }
  .home-layout {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  /* default: show analyze only */
  .home-layout .home-sidebar {
    display: none;
  }
  .home-layout.show-library .home-main {
    display: none;
  }
  .home-layout.show-library .home-sidebar {
    display: flex;
    flex: 1;
    min-height: 0;
  }
  .home-layout.show-analyze .home-main {
    display: block;
  }
  .sidebar-card {
    max-height: none;
    flex: 1;
  }
  .hero h1 { font-size: 1.35rem; }
  .subtitle { font-size: 0.9rem; }
  .card { padding: 1.15rem; }
  .tabs { flex-direction: column; }
  .tab { width: 100%; }
  .modal-card { max-height: 94vh; border-radius: 12px; }
  .modal-toolbar { flex-direction: column; align-items: stretch; }
  .modal-meta { margin-left: 0; }
  .out-actions .btn-sm { flex: 1; text-align: center; }
}

@media (max-width: 400px) {
  .header-inner { height: 54px; }
  .logo { font-size: 1rem; }
}

/* Footer compact when shell locks overflow */
.footer {
  border-top: 1px solid var(--border);
  padding: 0.65rem 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--bg);
}
