*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Helvetica, Arial, sans-serif;
  background: #eff6ff; color: #111; min-height: 100vh; line-height: 1.5;
}
body.files-body { display: flex; flex-direction: column; }
body.files-body .app-footer { margin-top: auto; }
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-view { display: none; width: 100%; max-width: 420px; }
.auth-view.active { display: block; }
.screen { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 1.5rem; flex-direction: column; }
.screen.active { display: flex; }
.auth-card {
  background: #fff; border-radius: 14px; padding: 2.25rem 2rem; width: 100%; max-width: 380px;
  box-shadow: 0 1px 4px rgba(37,99,235,.06), 0 6px 24px rgba(37,99,235,.08);
}
.brand { text-align: center; margin-bottom: 2rem; }
.brand-logo { display: inline-block; margin-bottom: .65rem; }
.brand-logo img { width: 44px; height: 44px; display: block; image-rendering: auto; }
.brand h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .2rem; }
.brand p  { font-size: .82rem; color: #6b6b70; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .78rem; font-weight: 600; color: #444; margin-bottom: .35rem; letter-spacing: .01em; }
.field input {
  width: 100%; padding: .72rem .9rem; border: 1.5px solid #e2e2e6; border-radius: 8px;
  font-size: .92rem; font-family: inherit; background: #fafafa; color: #111;
  outline: none; transition: border-color .15s, background .15s; -webkit-appearance: none;
}
.field input:focus { border-color: #2563eb; background: #fff; }
.field input.mono { font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace; font-size: .83rem; letter-spacing: .03em; }
.field-hint { font-size: .73rem; color: #7a7a80; margin-top: .3rem; line-height: 1.4; }
.field-hint a { color: #2563eb; font-weight: 600; text-decoration: underline; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  width: 100%; padding: .78rem 1.2rem; border: none; border-radius: 8px;
  font-family: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: opacity .15s; -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: .75; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-ghost   { background: #f0f0f2; color: #222; }
.btn-danger  { background: #fef0f0; color: #c0392b; }
.btn-sm      { width: auto; padding: .45rem .85rem; font-size: .78rem; border-radius: 6px; }
.form-error  { font-size: .78rem; color: #c0392b; min-height: 1.1em; margin-bottom: .5rem; }
.form-note   { font-size: .73rem; color: #7a7a80; text-align: center; margin-top: 1rem; }
.form-note a { color: #2563eb; font-weight: 600; text-decoration: none; border-bottom: 1px solid #bfdbfe; }
.lockout-msg { font-size: .78rem; color: #c07000; text-align: center; min-height: 1.1em; margin-bottom: .5rem; }
.step-indicator { display: flex; gap: .4rem; justify-content: center; margin-bottom: 1.75rem; }
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: #e0e0e4; transition: background .2s, width .2s; }
.step-dot.active { background: #2563eb; width: 18px; border-radius: 3px; }
.step-dot.done   { background: #34a853; }
.step { display: none; }
.step.active { display: block; }
.step-title { font-size: 1rem; font-weight: 700; margin-bottom: .25rem; letter-spacing: -.01em; }
.step-sub   { font-size: .8rem; color: #6b6b70; margin-bottom: 1.4rem; }
.verify-badge {
  display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem;
  background: #f0faf4; border: 1px solid #c3e6cd; border-radius: 8px;
  font-size: .82rem; color: #1e7e34; margin-bottom: 1rem;
}
.verify-badge .vb-icon {
  width: 16px; height: 16px; background: #34a853; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.verify-badge .vb-icon::after {
  content: ''; width: 5px; height: 3px;
  border-left: 1.5px solid #fff; border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}
.link-row {
  display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem;
  background: #f4f4f6; border-radius: 8px; font-size: .82rem; color: #333;
  margin-bottom: .7rem; text-decoration: none; border: 1px solid #e2e2e6; transition: background .1s;
}
.link-row:hover { background: #ebebef; }
.pw-strength { margin-top: .4rem; display: none; }
.pw-strength-bar   { height: 3px; background: #e8e8ec; border-radius: 2px; overflow: hidden; margin-bottom: .25rem; }
.pw-strength-fill  { height: 100%; border-radius: 2px; transition: width .2s, background .2s; width: 0; }
.pw-strength-label { font-size: .71rem; color: #888; }
#app-screen { display: none; flex-direction: column; min-height: 100vh; align-items: stretch; }
#app-screen.active { display: flex; }
.app-topbar {
  background: #fff; border-bottom: 1px solid #dbeafe; padding: 0 1.25rem; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20; gap: .5rem; min-width: 0;
}
.app-brand { display: flex; align-items: center; gap: .55rem; min-width: 0; flex: 1; overflow: hidden; }
.app-brand-logo { width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.app-brand-logo img { width: 26px; height: 26px; display: block; image-rendering: auto; }
.app-brand-text { min-width: 0; overflow: hidden; }
.app-brand-text h1 { font-size: .9rem; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-brand-text .repo-label { font-size: .68rem; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.topbar-user {
  font-size: .75rem; font-weight: 600; color: #374151; max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: #eff6ff; border-radius: 6px; padding: .2rem .55rem;
  border: 1px solid #dbeafe; display: none;
}
.topbar-user:not(:empty) { display: inline-block; }
.btn-signout { width: 32px; height: 32px; border-radius: 7px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; background: #eff6ff; color: #2563eb; transition: background .12s; flex-shrink: 0; -webkit-tap-highlight-color: transparent; }
.btn-signout:hover { background: #dbeafe; }
.btn-signout svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.app-body { flex: 1; max-width: 680px; width: 100%; margin: 0 auto; padding: 1.25rem 1rem 5rem; }
.card {
  background: #fff; border-radius: 14px; border: 1px solid #e0eafe;
  padding: 1.15rem 1.1rem; margin-bottom: .9rem;
  box-shadow: 0 1px 3px rgba(37,99,235,.04), 0 4px 12px rgba(37,99,235,.05);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .85rem; }
.card-title  { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #93c5fd; }
.drop-zone {
  border: 1.5px dashed #bfdbfe; border-radius: 10px; padding: 1.75rem 1rem;
  text-align: center; cursor: pointer; position: relative;
  transition: border-color .15s, background .15s;
  background: #f8fbff;
}
.drop-zone:hover { border-color: #93c5fd; background: #eff6ff; }
.drop-zone.drag-over { border-color: #2563eb; background: #eff6ff; }
.drop-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; z-index: 2; }
.drop-zone-icon  { width: 36px; height: 36px; margin: 0 auto .6rem; opacity: .35; color: #2563eb; position: relative; z-index: 1; pointer-events: none; }
.drop-zone-icon svg { width: 100%; height: 100%; }
.drop-zone-title { font-size: .88rem; font-weight: 600; margin-bottom: .2rem; color: #333; position: relative; z-index: 1; pointer-events: none; }
.drop-zone-sub   { font-size: .76rem; color: #999; position: relative; z-index: 1; pointer-events: none; }
.upload-queue { margin-top: .85rem; display: none; }
.queue-item { display: flex; align-items: center; gap: .65rem; padding: .65rem .8rem; background: #f8faff; border-radius: 8px; margin-bottom: .4rem; }
.queue-file-icon { width: 32px; height: 32px; background: #dbeafe; border-radius: 6px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .6rem; font-weight: 700; text-transform: uppercase; color: #2563eb; letter-spacing: .03em; }
.queue-info { flex: 1; min-width: 0; }
.queue-name { font-size: .82rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #111; }
.queue-size { font-size: .71rem; color: #999; margin-top: 1px; }
.queue-bar  { height: 3px; background: #dbeafe; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.queue-fill { height: 100%; background: #2563eb; border-radius: 2px; transition: width .2s ease; width: 0; }
@keyframes skeletonWave {
  0%   { background-position: -250% center; }
  100% { background-position: 250% center; }
}
.queue-fill.wave {
  background: linear-gradient(90deg, #1d4ed8 0%, #2563eb 30%, #3b82f6 48%, #2563eb 66%, #1d4ed8 100%);
  background-size: 250% 100%;
  animation: skeletonWave 1.6s ease-in-out infinite;
}
.queue-status      { font-size: .72rem; font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.queue-status.wait { color: #aaa; }
.queue-status.go   { color: #2563eb; }
.queue-status.ok   { color: #34a853; }
.queue-status.fail { color: #c0392b; }
.upload-actions { display: none; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }
.file-row {
  display: flex; align-items: center; gap: .7rem; padding: .75rem .5rem;
  border-bottom: 1px solid #f4f6ff; cursor: pointer;
  transition: background .12s; border-radius: 8px; margin: 0 -.5rem;
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: #f8fbff; }
.file-row:active { background: rgba(37,99,235,.06); }
.file-type-badge { width: 36px; height: 36px; background: #eff6ff; border-radius: 7px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #2563eb; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: .88rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #111; }
.file-meta { font-size: .73rem; color: #999; margin-top: 1px; }
.file-chevron { flex-shrink: 0; color: #bfdbfe; display: flex; align-items: center; }
.empty-state { text-align: center; padding: 3rem 1rem; color: #c0c8d8; }
.empty-state-icon { width: 44px; height: 44px; margin: 0 auto .85rem; opacity: .25; }
.empty-state-icon svg { width: 100%; height: 100%; }
.empty-state p { font-size: .84rem; color: #aab4c8; line-height: 1.6; }
.dl-progress-bar {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  width: calc(100% - 2rem); max-width: 440px;
  background: #fff; border: 1px solid #dbeafe; border-radius: 12px;
  padding: .9rem 1.1rem; box-shadow: 0 4px 20px rgba(37,99,235,.12); display: none; z-index: 100;
}
.dl-progress-bar.active { display: block; }
.dl-filename { font-size: .8rem; font-weight: 600; margin-bottom: .55rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-track { height: 4px; background: #dbeafe; border-radius: 2px; overflow: hidden; }
.dl-fill  { height: 100%; background: #2563eb; border-radius: 2px; transition: width .1s; width: 0; }
.dl-label { font-size: .71rem; color: #999; margin-top: .35rem; }
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(80px);
  padding: .6rem 1.1rem; border-radius: 20px; font-size: .82rem; font-weight: 500; color: #fff;
  background: #1e293b; white-space: nowrap; z-index: 400; transition: transform .22s ease;
  pointer-events: none; max-width: calc(100vw - 3rem); overflow: hidden; text-overflow: ellipsis;
}
.toast.show  { transform: translateX(-50%) translateY(0); }
.toast.ok    { background: #34a853; }
.toast.error { background: #c0392b; }
.app-footer { text-align: center; padding: 1.5rem; font-size: .72rem; color: #93c5fd; border-top: 1px solid #dbeafe; margin-top: auto; }
.spinner { width: 18px; height: 18px; border: 2px solid #dbeafe; border-top-color: #2563eb; border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 2rem 0; color: #bbb; font-size: .85rem; }

/* ── File detail sheet ── */
.fd-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 300; display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .28s;
}
.fd-overlay.open { opacity: 1; pointer-events: auto; }
.fd-sheet {
  background: #fff; border-radius: 20px 20px 0 0;
  width: 100%; max-width: 680px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.fd-overlay.open .fd-sheet { transform: translateY(0); }
.fd-handle { width: 36px; height: 4px; background: #dbeafe; border-radius: 2px; margin: .85rem auto .35rem; flex-shrink: 0; }
.fd-header { padding: .5rem 1.1rem .9rem; display: flex; align-items: flex-start; gap: .75rem; flex-shrink: 0; border-bottom: 1px solid #f0f0f2; }
.fd-header-icon { width: 44px; height: 44px; background: #eff6ff; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #2563eb; flex-shrink: 0; }
.fd-header-info { flex: 1; min-width: 0; padding-top: .15rem; }
.fd-header-name { font-size: .92rem; font-weight: 600; color: #111; word-break: break-all; line-height: 1.4; }
.fd-header-meta { font-size: .75rem; color: #999; margin-top: .2rem; }
.fd-close { width: 30px; height: 30px; border-radius: 50%; border: none; background: #eff6ff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: .15rem; -webkit-tap-highlight-color: transparent; }
.fd-close svg { width: 14px; height: 14px; stroke: #2563eb; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fd-preview { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; min-height: 80px; }
.fd-preview-img { max-width: 100%; max-height: 300px; object-fit: contain; border-radius: 10px; display: block; margin: 0 auto; border: 1px solid #dbeafe; }
.fd-preview-code { background: #f8faff; border-radius: 10px; padding: .85rem; margin: 0; font-family: 'SF Mono','Fira Code',ui-monospace,monospace; font-size: .73rem; line-height: 1.65; color: #2a2a2a; overflow-x: auto; white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow-y: auto; }
.fd-preview-audio { width: 100%; margin-top: .5rem; }
.fd-preview-video { width: 100%; border-radius: 10px; background: #000; display: block; }
.fd-preview-none { text-align: center; padding: 2rem .5rem; color: #bbb; font-size: .82rem; line-height: 1.7; }
.fd-preview-none-icon { width: 40px; height: 40px; margin: 0 auto .75rem; opacity: .4; color: #bbb; }
.fd-preview-none-icon svg { width: 100%; height: 100%; }
.fd-preview-loading { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 2.5rem 0; color: #93c5fd; font-size: .82rem; }
.fd-actions { display:flex; justify-content:center; align-items:center; gap:.6rem; padding:.9rem 1.1rem 1.4rem; flex-shrink:0; border-top:1px solid #f0f0f2; }
.fd-actions .btn { margin:0; flex:1 1 25%; display:flex; justify-content:center; align-items:center; }

/* Service-not-configured notice (replaces inline styles in app.js) */
.svc-unconfigured { text-align: center; padding: 2.5rem 2rem; }
.svc-unconfigured h2 { margin-bottom: .75rem; font-size: 1rem; }
.svc-unconfigured p  { font-size: .83rem; color: #666; line-height: 1.6; }

/* Back button in signup flow */
.btn-back { margin-top: .5rem; }

/* Logo: black on light, white on dark */
.brand-logo img,
.app-brand-logo img { filter: brightness(0); }

@media (prefers-color-scheme: dark) {
  .brand-logo img,
  .app-brand-logo img { filter: brightness(0) invert(1); }

  body { background: #0d0f1a; color: #f0f0f0; }

  .auth-card {
    background: #131929;
    box-shadow: 0 1px 4px rgba(0,0,0,.4), 0 6px 28px rgba(0,0,0,.5);
  }
  .brand p, .step-sub { color: #888; }
  .step-title { color: #f0f0f0; }

  .field label { color: #bbb; }
  .field input { border-color: #2a3550; background: #1a2035; color: #f0f0f0; }
  .field input:focus { border-color: #3b82f6; background: #1e2845; }
  .field-hint { color: #777; }
  .field-hint a { color: #60a5fa; }

  .btn-primary { background: #3b82f6; color: #fff; }
  .btn-ghost   { background: #1e2845; color: #ddd; }
  .btn-ghost:hover { background: #253058; }
  .btn-danger  { background: #2d1010; color: #ff6b6b; }

  .form-error  { color: #ff6b6b; }
  .form-note   { color: #888; }
  .form-note a { color: #60a5fa; border-bottom-color: #2563eb; }
  .lockout-msg { color: #f0a040; }

  .step-dot        { background: #2a3550; }
  .step-dot.active { background: #3b82f6; }
  .step-dot.done   { background: #34a853; }

  .verify-badge { background: #0f2218; border-color: #254d33; color: #5ecb7a; }

  .link-row { background: #1a2035; border-color: #2a3550; color: #ddd; }
  .link-row:hover { background: #1e2845; }

  .pw-strength-bar { background: #2a3550; }

  .app-topbar { background: #131929; border-bottom-color: #1e2e50; }
  .btn-signout { background: #1a2845; color: #60a5fa; }
  .btn-signout:hover { background: #1e3060; }
  .repo-label { color: #555 !important; }

  .card { background: #131929; border-color: #1e2e50; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
  .card-title { color: #3b5a8a; }

  .drop-zone { border-color: #2a3550; background: #1a2035; color: #888; }
  .drop-zone:hover { border-color: #3b82f6; background: #1e2845; }
  .drop-zone.drag-over { border-color: #3b82f6; background: #1e2845; }
  .drop-zone-title { color: #ddd; }
  .drop-zone-sub   { color: #666; }
  .drop-zone-icon  { color: #3b82f6; opacity: .7; }

  .queue-item { background: #1a2035; }
  .queue-name { color: #f0f0f0; }
  .queue-size { color: #777; }
  .queue-bar  { background: #2a3550; }
  .queue-fill { background: #3b82f6; }
  .queue-fill.wave {
    background: linear-gradient(90deg, #1d4ed8 0%, #2563eb 30%, #3b82f6 48%, #2563eb 66%, #1d4ed8 100%);
    background-size: 250% 100%;
  }
  .queue-status.wait { color: #555; }
  .queue-status.go   { color: #60a5fa; }
  .queue-file-icon   { background: #1a2845; color: #60a5fa; }

  .file-row { border-bottom-color: #1a2540; }
  .file-row:hover  { background: rgba(59,130,246,.06); }
  .file-row:active { background: rgba(59,130,246,.10); }
  .file-type-badge { background: #1a2845; color: #60a5fa; }
  .file-name { color: #f0f0f0; }
  .file-meta { color: #777; }
  .file-chevron { color: #2a3550; }
  .empty-state { color: #555; }

  .dl-progress-bar {
    background: #131929; border-color: #1e2e50;
    box-shadow: 0 4px 20px rgba(0,0,0,.5);
  }
  .topbar-user { background: #1a2845; border-color: #2a3550; color: #93c5fd; }
  .dl-filename { color: #f0f0f0; }
  .dl-track { background: #2a3550; }
  .dl-fill  { background: #3b82f6; }
  .dl-label { color: #777; }

  .toast       { background: #1e2845; color: #f0f0f0; }
  .toast.ok    { background: #34a853; color: #fff; }
  .toast.error { background: #c0392b; color: #fff; }

  .app-footer { color: #2a3a60; border-top-color: #1e2e50; }

  .spinner { border-color: #2a3550; border-top-color: #3b82f6; }
  .loading-row { color: #666; }

  /* Dark mode – file detail sheet */
  .fd-sheet        { background: #131929; }
  .fd-handle       { background: #2a3550; }
  .fd-header       { border-bottom-color: #1e2e50; }
  .fd-header-icon  { background: #1a2845; color: #60a5fa; }
  .fd-header-name  { color: #f0f0f0; }
  .fd-header-meta  { color: #666; }
  .fd-close        { background: #1a2845; }
  .fd-close svg    { stroke: #60a5fa; }
  .fd-preview-code { background: #1a2035; color: #e0e8ff; }
  .fd-preview-img  { border-color: #1e2e50; }
  .fd-preview-none { color: #555; }
  .fd-preview-none-icon { color: #555; opacity: .6; }
  .fd-preview-loading   { color: #3b5a8a; }
  .fd-actions      { border-top-color: #1e2e50; }
}
@media (max-width: 380px) { .auth-card { padding: 1.6rem 1.1rem; } .app-body { padding: 1rem .75rem 4rem; } .app-topbar { padding: 0 .85rem; } }
@media (min-width: 640px) { .app-topbar { padding: 0 2rem; height: 56px; } .app-brand-logo { width: 28px; height: 28px; } .app-brand-logo img { width: 28px; height: 28px; } .app-brand-text h1 { font-size: .95rem; } .btn-signout { width: 34px; height: 34px; } }
@media (min-width: 1024px) { .app-topbar { padding: 0 2.5rem; } .app-body { padding: 1.5rem 1rem 5rem; } }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 350; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: 14px; padding: 1.5rem 1.5rem 1.25rem;
  width: 100%; max-width: 320px;
  box-shadow: 0 8px 40px rgba(37,99,235,.14);
  transform: scale(.96); transition: transform .18s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-title { font-size: .95rem; font-weight: 700; color: #111; margin-bottom: .35rem; }
.modal-msg   { font-size: .83rem; color: #555; line-height: 1.5; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: .6rem; }
.modal-actions .btn { flex: 1; margin: 0; }
.queue-retry-btn {
  flex-shrink: 0; font-size: .7rem; font-weight: 600;
  padding: .25rem .6rem; border-radius: 5px; font-family: inherit;
  border: 1.5px solid #c0392b; background: transparent; color: #c0392b;
  cursor: pointer; transition: background .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}
.queue-retry-btn:hover { background: #c0392b; color: #fff; }
@media (prefers-color-scheme: dark) {
  .modal { background: #131929; box-shadow: 0 8px 40px rgba(0,0,0,.55); }
  .modal-title { color: #f0f0f0; }
  .modal-msg   { color: #888; }
  .modal-actions .btn-ghost  { background: #1e2845; color: #ddd; }
  .modal-actions .btn-danger { background: #2d1010; color: #ff6b6b; }
  .queue-retry-btn { border-color: #c0392b; color: #ff6b6b; }
  .queue-retry-btn:hover { background: #c0392b; color: #fff; }
}

/* ── Share modal ── */
.share-modal { max-width: 360px; }
.share-file-name { font-size: .82rem; font-weight: 600; color: #111; margin-bottom: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-ttl-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: .85rem; gap: .5rem; }
.share-ttl-label { font-size: .73rem; color: #666; white-space: nowrap; }
/* Segmented control for TTL options */
.share-ttl-opts {
  display: flex; background: #eff6ff; border: 1.5px solid #bfdbfe;
  border-radius: 8px; padding: 3px; gap: 2px;
}
.ttl-opt {
  font-size: .72rem; font-weight: 600; padding: .28rem .6rem; border-radius: 5px;
  border: none; background: transparent; color: #6b7280;
  cursor: pointer; font-family: inherit;
  transition: background .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}
.ttl-opt.active { background: #2563eb; color: #fff; box-shadow: 0 1px 3px rgba(37,99,235,.25); }
.share-link-row { display: flex; gap: .4rem; margin-bottom: .5rem; }
.share-link-input { flex: 1; min-width: 0; padding: .55rem .75rem; border: 1.5px solid #dbeafe; border-radius: 7px; font-size: .78rem; font-family: 'SF Mono','Fira Code',ui-monospace,monospace; color: #1e40af; background: #eff6ff; outline: none; -webkit-appearance: none; }
.share-copy-btn { flex-shrink: 0; padding: .55rem .9rem; border-radius: 7px; border: none; background: #2563eb; color: #fff; font-size: .78rem; font-weight: 600; font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: opacity .12s; }
.share-copy-btn:active { opacity: .75; }
.share-exp { font-size: .72rem; color: #999; margin-bottom: .5rem; }
.share-spinner { display: none; align-items: center; justify-content: center; padding: 1.5rem 0; }
.share-modal .modal-actions .btn-primary { background: #2563eb; color: #fff; }

/* ── Outline button (share) ── */
.btn-outline { background: transparent; border: 1.5px solid #dbeafe; color: #2563eb; }
.btn-outline:hover { background: #eff6ff; }

/* ── Repo switcher in modal ── */
.repo-switcher { display: flex; flex-direction: column; gap: .35rem; }
.repo-opt { padding: .65rem .8rem; border-radius: 8px; background: #f4f7ff; cursor: pointer; font-size: .83rem; font-weight: 500; color: #111; transition: background .1s; border: 1.5px solid transparent; }
.repo-opt.active { border-color: #2563eb; }
.repo-opt:hover { background: #eaefff; }
.repo-opt-sub { font-size: .7rem; color: #888; font-weight: 400; margin-top: 2px; }

/* ── Queue paused state ── */
.queue-status.paused { color: #888; }

/* ── Reset password screen ── */
#reset-screen .auth-card { max-width: 380px; }

/* ── fd-actions three-button layout ── */
.fd-actions { display: flex; gap: .5rem; }
.fd-actions .btn { flex:1 1 25%; margin:0; padding:.72rem .5rem; font-size:.82rem; display:flex; justify-content:center; align-items:center; }
.repo-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem 0; border-bottom: 1px solid #f0f4ff; }
.repo-item:last-child { border-bottom: none; }
.repo-item-info { flex: 1; min-width: 0; }
.repo-item-label { font-size: .83rem; font-weight: 600; color: #111; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.repo-item-sub { font-size: .72rem; color: #999; margin-top: 2px; }
.repo-item-acts { display: flex; gap: .35rem; flex-shrink: 0; }
.btn-xs { width: auto; padding: .3rem .6rem; font-size: .72rem; border-radius: 5px; }
.repo-active-tag { font-size: .65rem; font-weight: 700; background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; border-radius: 4px; padding: .1rem .35rem; letter-spacing: .02em; }
.repo-del-btn { color: #c0392b; }
.repo-del-btn:hover { background: #fef0f0 !important; }
.ar-form-actions { display: flex; gap: .5rem; margin-top: .5rem; }
@media (prefers-color-scheme: dark) {
  .share-file-name { color: #f0f0f0; }
  .share-ttl-label { color: #888; }
  .share-ttl-opts { background: #1a2035; border-color: #2a3550; }
  .ttl-opt { color: #888; }
  .ttl-opt.active { background: #3b82f6; color: #fff; box-shadow: 0 1px 4px rgba(59,130,246,.3); }
  .share-link-input { border-color: #2a3550; background: #1a2035; color: #93c5fd; }
  .share-copy-btn { background: #3b82f6; color: #fff; }
  .btn-outline { border-color: #2a3550; color: #60a5fa; }
  .btn-outline:hover { background: #1a2035; }
  .repo-opt { background: #1a2035; color: #f0f0f0; }
  .repo-opt:hover { background: #1e2845; }
  .repo-opt.active { border-color: #3b82f6; }
  .repo-opt-sub { color: #666; }
  .queue-status.paused { color: #666; }
  .share-exp { color: #666; }
  .repo-item { border-bottom-color: #1e2e50; }
  .repo-item-label { color: #f0f0f0; }
  .repo-item-sub { color: #666; }
  .repo-active-tag { background: #1a2845; color: #60a5fa; border-color: #1e3060; }
  .repo-del-btn { color: #ff6b6b; }
  .repo-del-btn:hover { background: #2d1010 !important; }
  .share-modal .modal-actions .btn-primary { background: #3b82f6; }
}

/* ── Repo card ── */
.repo-header-actions { display: flex; align-items: center; gap: .35rem; }
.repo-card-body { padding-top: .2rem; }

/* ── Repo sections in file list ── */
.repo-section { margin-bottom: .25rem; }
.repo-section-header {
  display: flex; flex-direction: column; gap: 1px;
  padding: .6rem 0 .4rem; border-bottom: 1px solid #e8f0ff; margin-bottom: .1rem;
}
.repo-section-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: #93c5fd;
}
.repo-section-sub { font-size: .68rem; color: #b0c4e8; }
.repo-section-empty {
  font-size: .78rem; color: #bbb; padding: .75rem .4rem; text-align: center;
}

/* ── Auto-routing note ── */
.repo-auto-note {
  font-size: .71rem; color: #93c5fd; padding: .3rem .1rem .65rem;
  display: flex; align-items: center; gap: .3rem;
}

/* ── Add repo form fields ── */
.ar-fields { display: flex; flex-direction: column; gap: 0; padding-top: .5rem; }
.ar-fields .field { margin-bottom: .75rem; }
.ar-form-actions {
  display: flex; gap: .5rem; margin-top: .65rem; padding-bottom: .15rem;
}
.ar-form-actions .btn { flex: 1; margin: 0; }

@media (prefers-color-scheme: dark) {
  .repo-section-header { border-bottom-color: #1e2e50; }
  .repo-section-label { color: #3b5a8a; }
  .repo-section-sub { color: #3a5070; }
  .repo-section-empty { color: #444; }
  .repo-auto-note { color: #3b5a8a; }
}

/* ══════════════════════════════════════════════════════════════════════════
   HAMBURGER BUTTON
   ══════════════════════════════════════════════════════════════════════════ */
.hamburger-btn {
  width: 34px; height: 34px; border-radius: 8px; border: none;
  background: transparent; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4.5px;
  padding: 0; transition: background .15s; -webkit-tap-highlight-color: transparent;
}
.hamburger-btn span {
  display: block; width: 18px; height: 1.8px; border-radius: 2px;
  background: #374151; transition: background .15s;
}
.hamburger-btn:hover { background: #eff6ff; }
.hamburger-btn:hover span { background: #2563eb; }
.hamburger-btn.is-open span:nth-child(1) { transform: translateY(6.3px) rotate(45deg); }
.hamburger-btn.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.is-open span:nth-child(3) { transform: translateY(-6.3px) rotate(-45deg); }
.hamburger-btn span { transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .15s, background .15s; }

/* ══════════════════════════════════════════════════════════════════════════
   DRAWER OVERLAY
   ══════════════════════════════════════════════════════════════════════════ */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.38);
  z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .25s cubic-bezier(.4,0,.2,1);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.drawer-overlay.is-open { opacity: 1; pointer-events: auto; }

/* ══════════════════════════════════════════════════════════════════════════
   DRAWER PANEL
   ══════════════════════════════════════════════════════════════════════════ */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(340px, 92vw);
  background: #fff; z-index: 201;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  box-shadow: -6px 0 32px rgba(0,0,0,.14);
  overflow: hidden;
}
.drawer.is-open { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem .9rem 1.25rem;
  border-bottom: 1px solid #e5eaf3; flex-shrink: 0;
  background: #f8faff;
}
.drawer-title { font-size: .88rem; font-weight: 700; color: #1e2a3a; letter-spacing: .01em; }
.drawer-close-btn {
  width: 30px; height: 30px; border-radius: 7px; border: none;
  background: transparent; cursor: pointer; display: flex; align-items: center;
  justify-content: center; color: #64748b; transition: background .14s, color .14s;
  -webkit-tap-highlight-color: transparent; padding: 0;
}
.drawer-close-btn svg { width: 16px; height: 16px; }
.drawer-close-btn:hover { background: #eff6ff; color: #2563eb; }

/* scrollable body */
.drawer > .drawer-section:first-of-type,
.drawer > .drawer-section { flex-shrink: 0; }
.drawer { overflow-y: auto; }

/* ══════════════════════════════════════════════════════════════════════════
   DRAWER SECTIONS
   ══════════════════════════════════════════════════════════════════════════ */
.drawer-section {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5eaf3;
}
.drawer-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .6rem;
}
.drawer-section-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: #374151;
}
.drawer-section-sub {
  font-size: .73rem; color: #64748b; line-height: 1.5;
  margin: 0 0 .7rem;
}

/* ── Repo list inside drawer ── */
.drawer-repo-list { display: flex; flex-direction: column; gap: .35rem; }
.drawer-repo-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem .7rem; border-radius: 8px;
  background: #f8faff; border: 1px solid #e5eaf3;
  cursor: pointer; transition: background .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
}
.drawer-repo-item:hover { background: #eff6ff; border-color: #bfdbfe; }
.drawer-repo-item-label { font-size: .8rem; font-weight: 600; color: #1e2a3a; }
.drawer-repo-item-slug  { font-size: .68rem; color: #64748b; }
.drawer-repo-remove-btn {
  width: 22px; height: 22px; border-radius: 5px; border: none;
  background: transparent; color: #94a3b8; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; transition: background .12s, color .12s; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent; padding: 0;
}
.drawer-repo-remove-btn svg { width: 13px; height: 13px; }
.drawer-repo-remove-btn:hover { background: #fee2e2; color: #dc2626; }
.drawer-repo-item-info { flex: 1; min-width: 0; }
.drawer-repo-storage { margin-top: .3rem; }
.drawer-repo-storage-label { font-size: .68rem; color: #94a3b8; }

/* ── Forms inside drawer ── */
.drawer-form { display: none; flex-direction: column; gap: 0; margin-top: .75rem; }
.drawer-form .field { margin-bottom: .65rem; }
.drawer-form textarea {
  width: 100%; box-sizing: border-box;
  padding: .45rem .6rem; border: 1px solid #d1d5db; border-radius: 7px;
  font-size: .78rem; font-family: 'SFMono-Regular', 'Consolas', monospace;
  line-height: 1.5; resize: vertical; color: #1e2a3a; background: #fff;
  transition: border-color .15s;
}
.drawer-form textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.drawer-form-actions {
  display: flex; gap: .45rem; margin-top: .15rem;
}
.drawer-form-actions .btn { flex: 1; }

/* ── API key list ── */
.apikey-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.apikey-item {
  padding: .6rem .75rem; border-radius: 8px; border: 1px solid #e5eaf3;
  background: #f8faff;
}
.apikey-item-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .25rem; }
.apikey-item-label { font-size: .79rem; font-weight: 600; color: #1e2a3a; flex: 1; }
.apikey-revoke-btn {
  font-size: .7rem; color: #dc2626; border: none; background: transparent;
  cursor: pointer; padding: .15rem .35rem; border-radius: 5px;
  transition: background .12s; font-family: inherit; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.apikey-revoke-btn:hover { background: #fee2e2; }
.apikey-item-preview {
  font-size: .7rem; font-family: 'SFMono-Regular','Consolas',monospace;
  color: #64748b; margin-bottom: .2rem;
}
.apikey-item-origins { font-size: .68rem; color: #64748b; }
.apikey-item-origins span { color: #059669; font-weight: 600; }
.apikey-item-origins.any span { color: #d97706; }
.apikey-empty { font-size: .77rem; color: #94a3b8; padding: .4rem 0; }

/* ── Reveal box (one-time key display) ── */
.apikey-reveal-box {
  margin: .6rem 0; padding: .75rem; border-radius: 8px;
  background: #f0fdf4; border: 1px solid #86efac;
}
.apikey-reveal-label { font-size: .72rem; color: #166534; margin-bottom: .45rem; font-weight: 500; }
.apikey-reveal-row { display: flex; align-items: center; gap: .5rem; }
.apikey-reveal-code {
  font-size: .68rem; font-family: 'SFMono-Regular','Consolas',monospace;
  color: #14532d; background: #dcfce7; border-radius: 5px;
  padding: .3rem .5rem; flex: 1; word-break: break-all; line-height: 1.4;
  border: 1px solid #86efac;
}

/* ── API docs ── */
.drawer-api-docs { border-bottom: none; }
.api-doc-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }
.api-doc-row { display: flex; align-items: center; gap: .55rem; }
.api-badge {
  font-size: .6rem; font-weight: 700; border-radius: 4px; padding: .15rem .4rem;
  flex-shrink: 0; font-family: 'SFMono-Regular','Consolas',monospace; letter-spacing: .04em;
}
.api-get  { background: #dbeafe; color: #1d4ed8; }
.api-post { background: #dcfce7; color: #166534; }
.api-del  { background: #fee2e2; color: #991b1b; }
.api-doc-row .ic { font-size: .7rem; color: #374151; flex: 1; }
.api-doc-desc { font-size: .68rem; color: #94a3b8; }
.ic { font-family: 'SFMono-Regular','Consolas',monospace; }

/* ══════════════════════════════════════════════════════════════════════════
   DARK MODE — DRAWER
   ══════════════════════════════════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  .hamburger-btn span { background: #94a3b8; }
  .hamburger-btn:hover { background: #1a2845; }
  .hamburger-btn:hover span { background: #60a5fa; }

  .drawer-overlay { background: rgba(0,0,0,.55); }
  .drawer { background: #0f1929; box-shadow: -6px 0 32px rgba(0,0,0,.45); }
  .drawer-header { background: #0d1623; border-bottom-color: #1e2e50; }
  .drawer-title { color: #e2e8f0; }
  .drawer-close-btn { color: #64748b; }
  .drawer-close-btn:hover { background: #1a2845; color: #60a5fa; }
  .drawer-section { border-bottom-color: #1e2e50; }
  .drawer-section-title { color: #94a3b8; }
  .drawer-section-sub { color: #475569; }

  .drawer-repo-item { background: #111e30; border-color: #1e2e50; }
  .drawer-repo-item:hover { background: #1a2845; border-color: #2563eb; }
  .drawer-repo-item-label { color: #e2e8f0; }
  .drawer-repo-item-slug  { color: #475569; }
  .drawer-repo-remove-btn { color: #475569; }
  .drawer-repo-remove-btn:hover { background: #3f1515; color: #f87171; }
  .drawer-repo-storage-label { color: #334155; }

  .drawer-form textarea { background: #111e30; border-color: #1e2e50; color: #e2e8f0; }
  .drawer-form textarea:focus { border-color: #2563eb; }

  .apikey-item { background: #111e30; border-color: #1e2e50; }
  .apikey-item-label { color: #e2e8f0; }
  .apikey-item-preview { color: #475569; }
  .apikey-item-origins { color: #475569; }
  .apikey-reveal-box { background: #052e16; border-color: #166534; }
  .apikey-reveal-label { color: #86efac; }
  .apikey-reveal-code { background: #14532d; color: #bbf7d0; border-color: #166534; }
  .apikey-revoke-btn:hover { background: #3f1515; }
  .apikey-empty { color: #334155; }

  .api-get  { background: #1e3a6e; color: #93c5fd; }
  .api-post { background: #052e16; color: #86efac; }
  .api-del  { background: #3f1515; color: #fca5a5; }
  .api-doc-row .ic { color: #94a3b8; }
  .api-doc-desc { color: #334155; }
}

/* ── Text editor overlay ───────────────────────────────────────────── */
.edit-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 300;
  background: #fff;
  flex-direction: column;
}
.edit-overlay.open { display: flex; }
.edit-sheet { display: flex; flex-direction: column; height: 100%; }
.edit-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #e2e8f0;
  background: #f8fafc; flex-shrink: 0;
}
.edit-filename { font-weight: 600; font-size: .9rem; color: #1e293b; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.edit-status { font-size: .78rem; color: #64748b; }
.edit-close-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px; border: none;
  background: transparent; color: #64748b; cursor: pointer;
}
.edit-close-btn:hover { background: #f1f5f9; color: #1e293b; }
.edit-textarea {
  flex: 1; resize: none; border: none; outline: none;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: .84rem; line-height: 1.6; padding: 16px;
  color: #1e293b; background: #fff;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.fd-tap-load { margin: auto; display: block; }

@media (prefers-color-scheme: dark) {
  .edit-overlay { background: #0f172a; }
  .edit-header { background: #0d1b2e; border-color: #1e2e50; }
  .edit-filename { color: #e2e8f0; }
  .edit-status { color: #475569; }
  .edit-close-btn { color: #475569; }
  .edit-close-btn:hover { background: #1e2e50; color: #e2e8f0; }
  .edit-textarea { background: #0f172a; color: #e2e8f0; }
}
