@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;0,14..32,900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================================
   RESET & BASE (STRICT DARK THEME FOR ALL DEVICES)
   ============================================================ */
:root {
  color-scheme: dark;

  /* Core Palette */
  --bg:         #07090f;
  --bg-2:       #0d1117;
  --bg-3:       #111827;
  --surface:    #161d2e;
  --surface-2:  #1c2539;
  --card:       rgba(255,255,255,0.03);
  --card-2:     rgba(255,255,255,0.055);
  --border:     rgba(255,255,255,0.07);
  --border-2:   rgba(255,255,255,0.13);
  --border-3:   rgba(255,255,255,0.22);

  /* Brand */
  --purple:     #7c3aed;
  --purple-l:   #9d5fff;
  --purple-d:   #5b21b6;
  --indigo:     #4f46e5;
  --violet:     #a78bfa;
  --violet-d:   #c4b5fd;

  /* Semantics */
  --success:    #22c98a;
  --warning:    #f59e0b;
  --danger:     #f36c6c;
  --info:       #38bdf8;

  /* Text */
  --txt:        #eef2ff;
  --txt-2:      #a8b8cc;
  --txt-3:      #7a8fa8;
  --txt-4:      #5a6b82;

  /* Gradients */
  --g-brand:    linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  --g-brand-r:  linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --g-soft:     linear-gradient(135deg, rgba(124,58,237,.14), rgba(79,70,229,.14));
  --g-card:     linear-gradient(135deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  --g-bg:       radial-gradient(ellipse 900px 700px at 50% -10%, rgba(124,58,237,.11) 0%, transparent 65%);
  --g-footer:   radial-gradient(ellipse 600px 300px at 50% 110%, rgba(79,70,229,.07) 0%, transparent 70%);

  /* Radius */
  --r-xs:  5px; --r-sm:  8px; --r-md:  12px;
  --r-lg:  16px; --r-xl:  20px; --r-2xl: 28px; --r-full: 9999px;

  /* Shadows */
  --sh-sm:    0 2px 8px rgba(0,0,0,.45);
  --sh-md:    0 8px 32px rgba(0,0,0,.5);
  --sh-lg:    0 24px 72px rgba(0,0,0,.65);
  --sh-brand: 0 8px 32px rgba(124,58,237,.28);
  --sh-glow:  0 0 80px rgba(124,58,237,.1);
  --sh-inset: inset 0 1px 0 rgba(255,255,255,.07);

  /* Timing */
  --t-fast:   .12s cubic-bezier(.4,0,.2,1);
  --t-base:   .22s cubic-bezier(.4,0,.2,1);
  --t-slow:   .38s cubic-bezier(.4,0,.2,1);
  --t-spring: .5s  cubic-bezier(.34,1.56,.64,1);
  --t-ease:   .25s ease;
}

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

html {
  color-scheme: dark !important;
  background-color: #07090f !important;
  color: #eef2ff !important;
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

button, input, select, textarea {
  font-family: inherit;
  color-scheme: dark !important;
  -webkit-appearance: none;
  appearance: none;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color-scheme: dark !important;
  background-color: #07090f !important;
  color: #eef2ff !important;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  touch-action: manipulation;
}

main, #main-content {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
}

/* Ambient glow background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 900px 700px at 50% -10%, rgba(124,58,237,.11) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--txt-3); }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4 { letter-spacing: -0.03em; font-weight: 700; }
a { color: inherit; }
code, pre { font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace; }

/* ============================================================
   STRICT STEP / PANEL VISIBILITY MANAGEMENT
   ============================================================ */
.hidden,
[hidden],
#feedback-modal.hidden,
#auth-modal.hidden,
#error-modal.hidden,
#admin-login-modal.hidden,
#hero-panel.hidden,
#app-section.hidden,
#crop-select-panel.hidden,
#auto-crop-panel.hidden,
#manual-crop-panel.hidden,
#processing-panel.hidden,
#result-panel.hidden,
#history-section.hidden,
#original-compare.hidden,
#ambig-section.hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }

.fade-in  { animation: fadeIn .3s ease both; }
.slide-up { animation: slideUp .35s cubic-bezier(.34,1.56,.64,1) both; }

@keyframes fadeIn   { from{opacity:0}          to{opacity:1} }
@keyframes slideUp  { from{opacity:0;transform:translateY(22px) scale(.98)} to{opacity:1;transform:none} }
@keyframes fadeDown { from{opacity:0;transform:translateY(-12px)} to{opacity:1;transform:none} }
@keyframes spin     { to{transform:rotate(360deg)} }
@keyframes pulse    { 0%,100%{opacity:1} 50%{opacity:.4} }
@keyframes shimmer  { 0%{background-position:-200% 0} 100%{background-position:200% 0} }
@keyframes glowPulse{ 0%,100%{box-shadow:var(--sh-brand)} 50%{box-shadow:0 8px 40px rgba(124,58,237,.45)} }
@keyframes dotBounce{ 0%,80%,100%{transform:scale(0)}  40%{transform:scale(1)} }

/* ============================================================
   LAYOUT
   ============================================================ */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ============================================================
   HEADER / NAV
   ============================================================ */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: 60px;
  background: rgba(7,9,15,.75);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--sh-inset);
}

.header-inner {
  display: flex; align-items: center; gap: 20px;
  height: 100%;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--txt); flex-shrink: 0;
}

/* logo-img styles defined below in LOGO VISIBILITY section */

.logo-wordmark {
  font-size: 17px; font-weight: 800; letter-spacing: -.5px;
  background: var(--g-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }

.nav-link {
  padding: 6px 14px;
  border-radius: var(--r-md);
  color: var(--txt-2); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: all var(--t-base);
  white-space: nowrap;
}
.nav-link:hover { color: var(--txt); background: var(--card-2); }
.nav-link.active { color: var(--violet-d); font-weight: 600; }

.nav-cta {
  margin-left: 8px;
  padding: 7px 16px;
  border-radius: var(--r-md);
  background: var(--g-brand);
  color: #fff; text-decoration: none;
  font-size: 14px; font-weight: 600;
  transition: all var(--t-base);
  box-shadow: var(--sh-brand);
}
.nav-cta:hover { transform: translateY(-1px); box-shadow: 0 12px 36px rgba(124,58,237,.38); }

.nav-key-btn {
  padding: 7px 16px;
  border-radius: var(--r-md);
  background: var(--card-2); border: 1px solid var(--border-2);
  color: var(--txt-2); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--t-base);
  display: flex; align-items: center; gap: 6px;
  font-family: inherit;
}
.nav-key-btn:hover { background: var(--card); color: var(--txt); border-color: var(--border-3); }
.nav-key-btn svg { width: 14px; height: 14px; }

/* Mobile menu toggle */
.menu-toggle {
  display: none; padding: 8px; cursor: pointer;
  background: none; border: none; color: var(--txt-2);
  margin-left: auto;
}
.menu-toggle svg { width: 20px; height: 20px; }
.menu-toggle.open svg { color: var(--txt); }
.menu-toggle.open { color: var(--txt); }
.menu-toggle.open svg { color: var(--txt); }

/* ============================================================
   HERO
   ============================================================ */
#hero-panel {
  min-height: calc(100vh - 60px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 80px 24px 60px;
  text-align: center;
  position: relative; z-index: 1;
}

.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 16px;
  border-radius: var(--r-full);
  background: rgba(124,58,237,.18);
  border: 1px solid rgba(167,139,250,.45);
  color: #f1f5f9;
  font-size: 12px; font-weight: 700;
  letter-spacing: .6px; text-transform: uppercase;
  margin-bottom: 24px;
  box-shadow: 0 4px 16px rgba(124,58,237,.22);
  animation: fadeDown .5s ease both;
  position: relative; z-index: 1;
}

.badge-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 10px #34d399;
  animation: pulse 2s ease-in-out infinite;
}

.hero-title {
  font-size: clamp(38px, 6.5vw, 74px);
  font-weight: 900; line-height: 1.05;
  letter-spacing: -.04em;
  margin-bottom: 20px;
  animation: slideUp .55s .08s ease both;
  position: relative; z-index: 1;
}

.hero-title .grad {
  background: var(--g-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: clamp(15px, 2vw, 19px);
  color: var(--txt-2); font-weight: 500;
  max-width: 540px; margin: 0 auto 48px;
  line-height: 1.65;
  animation: slideUp .55s .16s ease both;
  position: relative; z-index: 1;
}

/* ============================================================
   UPLOAD ZONE
   ============================================================ */
#upload-zone {
  width: 100%; max-width: 660px;
  animation: slideUp .55s .24s ease both;
  position: relative; z-index: 1;
}

.upload-area {
  border: 2px dashed var(--border-2);
  border-radius: var(--r-2xl);
  padding: 52px 36px;
  background: var(--card);
  cursor: pointer;
  transition: all var(--t-base);
  position: relative; overflow: hidden;
}

.upload-area::before {
  content: ''; position: absolute; inset: 0;
  background: var(--g-soft); opacity: 0;
  transition: opacity var(--t-base);
}

.upload-area:hover, .upload-area.drag-over {
  border-color: var(--purple);
  transform: translateY(-2px);
  box-shadow: var(--sh-brand), var(--sh-glow);
}
.upload-area:hover::before, .upload-area.drag-over::before { opacity: 1; }
.upload-area.drag-over {
  border-style: solid;
  background: rgba(124,58,237,.06);
}

/* Upload Icon Floating Animation (Pure CSS) */
@keyframes gentleFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-6px);
  }
}

.upload-icon-wrap {
  width: 64px; height: 64px; margin: 0 auto 20px;
  border-radius: var(--r-xl);
  background: var(--g-soft);
  border: 1px solid rgba(124,58,237,.2);
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
  animation: gentleFloat 3s ease-in-out infinite;
  will-change: transform;
  transition: transform var(--t-spring);
}
.upload-area:hover .upload-icon-wrap {
  animation-play-state: paused;
  transform: scale(1.08) rotate(-3deg);
}
.upload-icon-wrap svg { width: 26px; height: 26px; color: var(--violet); }

.upload-title {
  font-size: 17px; font-weight: 700;
  margin-bottom: 6px; position: relative; z-index: 1;
}

.upload-desc {
  color: var(--txt-2); font-size: 14px; font-weight: 500;
  position: relative; z-index: 1;
}

.upload-divider {
  display: flex; align-items: center; gap: 16px;
  margin: 22px 0; position: relative; z-index: 1;
}
.upload-divider::before, .upload-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border-2);
}
.upload-divider span { font-size: 11px; color: var(--txt-3); font-weight: 700; text-transform: uppercase; letter-spacing: .8px; }

.upload-shortcuts {
  display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap;
  position: relative; z-index: 1;
}

.kbd-tag {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: 12px; color: var(--txt-2); font-weight: 500;
}
.kbd-tag kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  background: rgba(167,139,250,.15); padding: 1px 6px;
  border-radius: 4px; color: var(--violet-d); font-weight: 700;
}

/* Tap to browse fallback button (especially on mobile) */
.tap-to-browse-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 8px 18px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--r-md);
  position: relative;
  z-index: 2;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  transition: all var(--t-base);
}
.tap-to-browse-btn:hover {
  transform: translateY(-1px);
  border-color: var(--violet);
  background: var(--card-2);
}

/* Server status banner (cold-start / connectivity check) */
.server-status-banner {
  background: rgba(239, 68, 68, 0.12);
  border-bottom: 1px solid rgba(239, 68, 68, 0.28);
  color: #fca5a5;
  font-size: 13.5px;
  padding: 10px 16px;
  position: sticky;
  top: 60px;
  z-index: 180;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: slideDown .2s ease both;
}
.server-status-banner.warming {
  background: rgba(245, 158, 11, 0.14);
  border-bottom: 1px solid rgba(245, 158, 11, 0.32);
  color: #fcd34d;
}
.server-status-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.server-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
}
.server-status-banner.warming .server-status-dot {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse 1.5s infinite;
}
.server-status-msg {
  font-weight: 500;
}
.server-status-retry {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
  margin-left: 6px;
  transition: all var(--t-base);
}
.server-status-retry:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* ============================================================
   PROMINENT CAMERA ACTION CARD
   ============================================================ */
.camera-action-card {
  margin-top: 14px;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(124,58,237,.20) 0%, rgba(99,102,241,.14) 100%);
  border: 1.5px solid rgba(167,139,250,.45);
  border-radius: var(--r-xl);
  cursor: pointer;
  transition: all var(--t-base);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,.28), 0 0 24px rgba(124,58,237,.14);
  text-align: left;
}

.camera-action-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(124,58,237,.32) 0%, rgba(99,102,241,.24) 100%);
  opacity: 0;
  transition: opacity var(--t-base);
}

.camera-action-card:hover {
  border-color: var(--violet);
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(124,58,237,.38), 0 0 32px rgba(124,58,237,.22);
}
.camera-action-card:hover::before {
  opacity: 1;
}

.camera-action-icon-wrap {
  width: 46px;
  height: 46px;
  border-radius: var(--r-lg);
  background: var(--g-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 12px rgba(124,58,237,.45);
  transition: transform var(--t-spring);
}
.camera-action-card:hover .camera-action-icon-wrap {
  transform: scale(1.08) rotate(-4deg);
}
.camera-action-icon-wrap svg {
  width: 22px;
  height: 22px;
  color: #ffffff;
}

.camera-action-content {
  flex: 1;
  position: relative;
  z-index: 1;
  min-width: 0;
}
.camera-action-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.camera-action-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}
.camera-action-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: rgba(34,201,138,.16);
  border: 1px solid rgba(34,201,138,.45);
  color: #34d399;
}
.camera-action-sub {
  font-size: 13px;
  color: #cbd5e1;
  font-weight: 500;
  line-height: 1.4;
  margin: 0;
}

.camera-action-arrow {
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--t-spring), background var(--t-base);
}
.camera-action-arrow svg {
  width: 16px;
  height: 16px;
  color: var(--violet-d);
  transition: color var(--t-base);
}
.camera-action-card:hover .camera-action-arrow {
  transform: translateX(3px);
  background: rgba(124,58,237,.35);
}
.camera-action-card:hover .camera-action-arrow svg {
  color: #ffffff;
}

.upload-meta {
  display: flex; justify-content: center; align-items: center;
  flex-wrap: wrap; gap: 10px 14px; margin-top: 20px;
  width: 100%; box-sizing: border-box;
}
.trust-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px;
  border-radius: var(--r-full);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.14);
  color: #f1f5f9;
  font-size: 12.5px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  white-space: nowrap;
  transition: all var(--t-base);
}
.trust-badge:hover {
  border-color: rgba(124,58,237,.45);
  background: rgba(255,255,255,.08);
}
.trust-badge svg { width: 14px; height: 14px; color: var(--violet-d); flex-shrink: 0; }
.trust-badge-highlight {
  background: rgba(34,201,138,.12);
  border: 1px solid rgba(34,201,138,.4);
  color: #34d399;
}
.trust-badge-highlight svg { color: #34d399; }

.usage-bar-wrap { margin-top: 16px; text-align: center; }

.usage-text {
  font-size: 12px; color: var(--txt-3); margin-bottom: 8px; font-weight: 500;
}
.usage-text .count { color: var(--violet); font-weight: 700; }

.usage-bar {
  height: 3px; background: var(--border);
  border-radius: var(--r-full); overflow: hidden;
  max-width: 200px; margin: 0 auto;
}
.usage-bar-fill {
  height: 100%; background: var(--g-brand);
  border-radius: var(--r-full);
  transition: width .5s ease;
}

/* ============================================================
   APP SECTION (workflow states)
   ============================================================ */
#app-section {
  padding: 84px 24px 80px;
  max-width: 860px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  width: 100%;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.state-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  animation: slideUp .35s ease both;
  box-sizing: border-box;
}

/* ============================================================
   SECTION HEADER
   ============================================================ */
.sec-header { margin-bottom: 28px; }
.sec-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--violet-d); margin-bottom: 6px;
}
.sec-title {
  font-size: 24px; font-weight: 800; letter-spacing: -.04em;
}
.sec-sub { color: var(--txt-2); font-size: 14px; margin-top: 4px; font-weight: 500; }

/* ============================================================
   IMAGE PREVIEW CARD
   ============================================================ */
.img-preview-card {
  border-radius: var(--r-xl); overflow: hidden;
  border: 1px solid var(--border); background: var(--bg-3);
  position: relative; margin-bottom: 24px;
}
.img-preview-card img {
  width: 100%; max-height: 320px;
  object-fit: contain; display: block;
}
.img-preview-overlay {
  position: absolute; top: 12px; right: 12px;
  display: flex; gap: 8px;
}

/* ============================================================
   CROP OPTION CARDS
   ============================================================ */
.crop-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.crop-card {
  border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 24px; background: var(--card);
  cursor: pointer; transition: all var(--t-base);
  text-align: left; position: relative; overflow: hidden;
}
.crop-card::before {
  content: ''; position: absolute; inset: 0;
  background: var(--g-soft); opacity: 0;
  transition: opacity var(--t-base);
}
.crop-card:hover {
  border-color: var(--purple);
  transform: translateY(-2px);
  box-shadow: var(--sh-brand);
}
.crop-card:hover::before { opacity: 1; }

.crop-card-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  background: var(--g-soft); border: 1px solid rgba(124,58,237,.2);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px; position: relative; z-index: 1;
}
.crop-card-icon svg { width: 20px; height: 20px; color: var(--violet); }

.crop-card-badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600;
  margin-bottom: 10px; position: relative; z-index: 1;
}
.badge-rec {
  background: rgba(124,58,237,.15); color: var(--violet-d);
  border: 1px solid rgba(167,139,250,.38);
}
.badge-prec {
  background: rgba(34,201,138,.1); color: var(--success);
  border: 1px solid rgba(34,201,138,.3);
}

.crop-card-title {
  font-size: 16px; font-weight: 700; margin-bottom: 6px;
  position: relative; z-index: 1;
}
.crop-card-desc {
  font-size: 13px; color: var(--txt-2); line-height: 1.55;
  position: relative; z-index: 1; font-weight: 500;
}

/* ============================================================
   BATCH UPLOAD & PREVIEW GRID
   ============================================================ */
#batch-preview-panel:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.batch-limit-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--r-xl);
  padding: 14px 18px;
  margin-bottom: 8px;
  color: #fbbf24;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.5;
}
.batch-limit-banner svg {
  width: 20px;
  height: 20px;
  color: #f59e0b;
  flex-shrink: 0;
}

.batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

.batch-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transition: all var(--t-base);
}
.batch-card:hover {
  border-color: rgba(167, 139, 250, 0.45);
  transform: translateY(-2px);
}

.batch-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.batch-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.batch-card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(167, 139, 250, 0.4);
  color: var(--violet-d);
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 7px;
  border-radius: var(--r-full);
  backdrop-filter: blur(8px);
}
.batch-card-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all var(--t-base);
}
.batch-card-remove:hover {
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  border-color: #ef4444;
  transform: scale(1.1);
}
.batch-card-remove svg {
  width: 13px;
  height: 13px;
}

.batch-card-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--card-2);
  border-top: 1px solid var(--border-2);
}
.batch-card-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.batch-card-meta {
  font-size: 11px;
  color: var(--txt-3);
  font-family: 'JetBrains Mono', monospace;
}

/* ============================================================
   MODERN BATCH PROGRESS IN PROCESSING PANEL
   ============================================================ */
.batch-progress-wrap {
  width: 100%;
  max-width: 480px;
  margin: 10px auto 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.batch-proc-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  box-shadow: 0 8px 24px rgba(0,0,0,.35), 0 0 20px rgba(124,58,237,.12);
  text-align: left;
}

.batch-proc-thumb-wrap {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1.5px solid rgba(167,139,250,.4);
  background: #000;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0,0,0,.4);
}
.batch-proc-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.batch-proc-spinner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.batch-proc-spin-icon {
  width: 22px;
  height: 22px;
  color: #a78bfa;
  animation: spin 1s linear infinite;
}

.batch-proc-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.batch-proc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.batch-proc-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: rgba(124,58,237,.18);
  border: 1px solid rgba(167,139,250,.35);
  color: var(--violet-d);
}
.batch-proc-pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--violet-d);
}
.batch-proc-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--txt);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.batch-proc-phase {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--txt-2);
  font-weight: 500;
}
.batch-phase-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
  animation: pulse 1.5s infinite;
}

.batch-progress-bar-wrap {
  width: 100%;
}
.batch-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--card-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-full);
  overflow: hidden;
}
.batch-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #6366f1, #34d399);
  border-radius: var(--r-full);
  transition: width 0.35s ease;
  box-shadow: 0 0 10px rgba(124,58,237,.5);
}

/* ============================================================
   BATCH RESULTS TABS & ERROR CARDS
   ============================================================ */
.batch-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: 8px 12px;
  margin-bottom: 6px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.batch-tabs-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  display: flex;
  align-items: center;
  scrollbar-width: thin;
}
.batch-tabs-list {
  display: flex;
  gap: 6px;
  align-items: center;
}
.batch-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-lg);
  background: transparent;
  border: 1px solid transparent;
  color: var(--txt-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-base);
  user-select: none;
}
.batch-tab:hover {
  background: var(--card-2);
  color: var(--txt);
}
.batch-tab.active {
  background: rgba(124, 58, 237, 0.18);
  border-color: rgba(167, 139, 250, 0.4);
  color: #fff;
}
.batch-tab-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  font-weight: 700;
}
.batch-tab-badge.ok {
  background: rgba(34, 201, 138, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 201, 138, 0.3);
}
.batch-tab-badge.err {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.batch-error-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--r-xl);
  padding: 16px 20px;
  margin-bottom: 12px;
}
.batch-error-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ============================================================
   CROP CANVAS AREA (Drag-to-select)
   ============================================================ */
.crop-canvas-wrap {
  border-radius: var(--r-xl); overflow: hidden;
  border: 1px solid var(--border-2); background: #07090f;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  width: 100%;
  box-sizing: border-box;
}

#auto-crop-canvas, #manual-crop-canvas {
  display: block; width: 100%;
  cursor: crosshair;
  touch-action: none !important;
  user-select: none;
  -webkit-user-select: none;
}

/* Crop footer controls */
.crop-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 16px; flex-wrap: wrap;
  width: 100%; box-sizing: border-box;
}
.crop-hint {
  font-size: 13.5px; color: #cbd5e1; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.crop-hint svg { width: 15px; height: 15px; color: var(--violet-d); flex-shrink: 0; }
.crop-actions { display: flex; gap: 10px; align-items: center; }

/* ============================================================
   PROCESSING
   ============================================================ */
#processing-panel:not(.hidden) {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: calc(100vh - 240px);
  min-height: calc(100dvh - 240px);
  padding: 36px 16px 48px;
  gap: 30px; text-align: center;
  width: 100%; box-sizing: border-box;
}

.processing-orb {
  position: relative; width: 110px; height: 110px;
}
.orb-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--border);
}
.orb-ring::after {
  content: ''; position: absolute;
  inset: -2px; border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--purple);
  border-right-color: var(--indigo);
  animation: spin 1.1s linear infinite;
}
.orb-ring-2 {
  position: absolute; inset: 14px; border-radius: 50%;
  border: 2px solid var(--border);
}
.orb-ring-2::after {
  content: ''; position: absolute;
  inset: -2px; border-radius: 50%;
  border: 2px solid transparent;
  border-bottom-color: var(--violet);
  animation: spin .75s linear infinite reverse;
}
.orb-center {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.orb-center svg { width: 26px; height: 26px; color: var(--violet); }

.processing-title { font-size: 22px; font-weight: 800; letter-spacing: -.03em; }
.processing-sub { color: var(--txt-2); font-size: 14px; font-weight: 500; }

.proc-steps { display: flex; flex-direction: column; gap: 10px; max-width: 300px; }
.proc-step {
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; color: var(--txt-3); font-weight: 500;
  transition: color var(--t-base);
}
.proc-step.active { color: var(--txt); }
.proc-step.done  { color: var(--success); }
.step-pip {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-2); flex-shrink: 0;
  transition: all var(--t-base);
}
.proc-step.active .step-pip {
  background: var(--purple);
  box-shadow: 0 0 10px var(--purple);
  animation: pulse 1s ease infinite;
}
.proc-step.done .step-pip { background: var(--success); }

/* ============================================================
   RESULT PANEL
   ============================================================ */
#result-panel:not(.hidden) {
  display: flex; flex-direction: column; gap: 20px;
  width: 100%;
  min-height: calc(100vh - 220px);
  min-height: calc(100dvh - 220px);
  overflow-y: visible;
  box-sizing: border-box;
}

/* Sticky topbar: stays visible while scrolling through long code */
.result-topbar {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 12px;
  position: sticky; top: 72px; z-index: 20;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: 12px 16px;
  margin-bottom: 4px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
.result-meta { display: flex; align-items: center; gap: 10px; }

.lang-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-sm);
  background: rgba(124,58,237,.16);
  border: 1px solid rgba(167,139,250,.4);
  color: var(--violet-d); font-size: 12px; font-weight: 700;
  font-family: 'JetBrains Mono', monospace; letter-spacing: .3px;
}
.lang-chip svg { width: 12px; height: 12px; }

.result-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Code block */
.code-window {
  border-radius: var(--r-xl);
  border: 1px solid var(--border-2); background: #0d1117;
  box-shadow: var(--sh-md);
  width: 100%; box-sizing: border-box;
}
.code-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.win-dots { display: flex; gap: 6px; }
.win-dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-r { background: #ff5f57; } .dot-y { background: #ffbd2e; } .dot-g { background: #28ca41; }
.code-filename { font-size: 12px; color: var(--txt-2); font-family: 'JetBrains Mono', monospace; font-weight: 500; }

/* Code scroll area — Horizontal scroll for long code lines */
.code-scroll {
  position: relative;
  overflow-x: auto !important;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  width: 100%;
  box-sizing: border-box;
}
.code-scroll pre {
  margin: 0 !important; border-radius: 0 !important;
  background: transparent !important;
  padding: 20px 24px !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 13px !important; line-height: 1.75 !important;
  tab-size: 2;
  white-space: pre !important;
  word-break: normal !important;
  word-wrap: normal !important;
  overflow-wrap: normal !important;
  width: max-content;
  min-width: 100%;
}
.code-scroll pre code {
  font-size: 13px !important;
  white-space: pre !important;
  word-break: normal !important;
  word-wrap: normal !important;
  overflow-wrap: normal !important;
}

/* Ambiguity warnings */
.ambig-box {
  border-radius: var(--r-lg);
  border: 1px solid rgba(245,158,11,.38);
  background: rgba(245,158,11,.06);
  padding: 16px 20px;
}
.ambig-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--warning);
  margin-bottom: 12px;
}
.ambig-header svg { width: 15px; height: 15px; }
.ambig-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ambig-item {
  font-size: 12px; color: var(--txt-2); font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  padding: 6px 10px;
  background: rgba(245,158,11,.06);
  border-radius: var(--r-sm);
  border-left: 2px solid rgba(245,158,11,.6);
}

/* Reverify notice */
.reverify-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: rgba(79,70,229,.09);
  border: 1px solid rgba(79,70,229,.28);
}
.reverify-card svg { width: 15px; height: 15px; color: var(--violet); flex-shrink: 0; margin-top: 2px; }
.reverify-text { font-size: 13px; color: var(--txt-2); line-height: 1.55; font-weight: 500; }
.reverify-text strong { color: var(--txt); font-weight: 700; }

/* Tip Callout */
.tip-callout {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.08) 0%, rgba(79, 70, 229, 0.04) 100%);
  border: 1px solid rgba(124, 58, 237, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.tip-callout-icon {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: var(--r-sm);
  background: rgba(124, 58, 237, 0.16);
  color: var(--violet-d);
  flex-shrink: 0;
  margin-top: 1px;
}
.tip-callout-icon svg { width: 15px; height: 15px; }
.tip-callout-text { font-size: 13px; color: var(--txt-2); line-height: 1.55; font-weight: 500; }
.tip-callout-text strong { color: var(--txt); font-weight: 700; }

.result-cta {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 20px 0 44px;
  margin-bottom: 24px;
  width: 100%;
  box-sizing: border-box;
}

/* ============================================================
   MOBILE NAV DRAWER
   ============================================================ */
.mobile-nav {
  position: fixed; top: 60px; left: 0; right: 0; z-index: 190;
  background: rgba(7,9,15,.97);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-2);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  animation: slideDown .22s ease both;
}
@keyframes slideDown { from{opacity:0;transform:translateY(-10px)} to{opacity:1;transform:none} }
.mobile-nav-inner {
  display: flex; flex-direction: column;
  padding: 16px 20px 20px;
  gap: 4px;
}
.mobile-nav-link {
  display: block; padding: 12px 14px;
  border-radius: var(--r-md);
  color: var(--txt-2); text-decoration: none;
  font-size: 15px; font-weight: 500;
  transition: all var(--t-base);
}
.mobile-nav-link:hover,
.mobile-nav-link.active { color: var(--txt); background: var(--card-2); }
.mobile-nav-link.active { color: var(--violet-d); font-weight: 600; }
.mobile-nav-divider {
  height: 1px; background: var(--border-2);
  margin: 8px 0;
}
.mobile-nav-auth {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 4px;
}
.mobile-nav-auth .btn { justify-content: center; width: 100%; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--t-base);
  text-decoration: none; font-family: inherit;
  white-space: nowrap; line-height: 1;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: var(--g-brand); color: #fff;
  box-shadow: var(--sh-brand);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 36px rgba(124,58,237,.38); }
.btn-primary:active { transform: none; }

.btn-secondary {
  background: var(--card-2); color: var(--txt);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--card); border-color: var(--border-3); }

.btn-ghost {
  background: transparent; color: var(--txt-2); font-weight: 500;
}
.btn-ghost:hover { background: var(--card-2); color: var(--txt); }

.btn-success {
  background: linear-gradient(135deg, #059669, #22c98a);
  color: #fff;
  box-shadow: 0 8px 24px rgba(34,201,138,.25);
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 12px 32px rgba(34,201,138,.35); }

/* Disabled state — explicit contrast, not just opacity */
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 1;
  color: var(--txt-3);
  background: var(--surface);
  border-color: var(--border-2);
  box-shadow: none;
  cursor: not-allowed;
  transform: none !important;
}
.btn-primary:disabled, .btn-primary[aria-disabled="true"] {
  background: rgba(124,58,237,.2);
  color: rgba(196,181,253,.7);  /* ~4.5:1 on rgba(124,58,237,.2) over --bg */
  border-color: rgba(124,58,237,.35);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
}

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; border-radius: var(--r-lg); }
.btn-xl { padding: 16px 40px; font-size: 17px; border-radius: var(--r-xl); }

.btn-icon {
  padding: 8px; width: 34px; height: 34px;
  justify-content: center; border-radius: var(--r-md);
}
.btn-icon svg { width: 15px; height: 15px; }

.btn-icon-lg {
  padding: 9px; width: 38px; height: 38px;
  justify-content: center; border-radius: var(--r-lg);
}
.btn-icon-lg svg { width: 18px; height: 18px; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2xl);
  padding: 36px;
  max-width: 460px; width: 100%;
  box-shadow: var(--sh-lg);
  animation: slideUp .3s cubic-bezier(.34,1.56,.64,1);
  position: relative;
}
.modal-sm { max-width: 380px; }

.modal-close-btn {
  position: absolute; top: 16px; right: 16px;
}

.modal-icon-wrap {
  width: 52px; height: 52px; border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}
.modal-icon-brand { background: var(--g-soft); }
.modal-icon-brand svg { color: var(--violet); width: 22px; height: 22px; }
.modal-icon-warn { background: rgba(245,158,11,.1); }
.modal-icon-warn svg { color: var(--warning); width: 22px; height: 22px; }
.modal-icon-success { background: rgba(16,185,129,.1); }
.modal-icon-success svg { color: var(--success); width: 22px; height: 22px; }

.modal-title { font-size: 20px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 8px; }
.modal-desc { font-size: 14px; color: var(--txt-2); line-height: 1.6; margin-bottom: 24px; font-weight: 500; }
.modal-desc a { color: var(--violet-d); text-decoration: none; }
.modal-desc a:hover { text-decoration: underline; }

.modal-actions { display: flex; flex-direction: column; gap: 10px; }
.modal-actions .btn { justify-content: center; }

/* Input */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--txt-2); }
.field-hint { font-size: 12px; color: var(--txt-3); font-weight: 500; }
.field-hint a { color: var(--violet); text-decoration: none; }
.field-hint a:hover { text-decoration: underline; }

.input {
  padding: 10px 14px; border-radius: var(--r-md);
  border: 1px solid var(--border-2);
  background: var(--bg-2); color: var(--txt);
  font-size: 14px; font-family: inherit;
  transition: all var(--t-base); outline: none;
  width: 100%;
}
.input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124,58,237,.16); }
.input::placeholder { color: var(--txt-3); opacity: 1; }  /* explicit: avoids 50% browser default opacity */
.input-mono { font-family: 'JetBrains Mono', monospace; font-size: 13px; letter-spacing: -.01em; }

/* Show/hide password */
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 44px; }
.input-eye {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--txt-2); cursor: pointer; padding: 4px;
  transition: color var(--t-base);
}
.input-eye:hover { color: var(--txt); }
.input-eye svg { width: 15px; height: 15px; display: block; }

/* ============================================================
   CAMERA LENS MODAL & LIVE VIEWFINDER
   ============================================================ */
.camera-modal-content {
  background: #0d1117;
  border: 1px solid var(--border-2);
  border-radius: var(--r-2xl);
  padding: 24px;
  max-width: 660px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(124, 58, 237, 0.15);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
}

.camera-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.camera-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.camera-live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
  animation: pulse 1.5s infinite;
}
.camera-modal-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.camera-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: rgba(124, 58, 237, 0.16);
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: var(--violet-d);
}
.camera-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Viewport */
.camera-viewport-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 420px;
  background: #000;
  border-radius: var(--r-xl);
  overflow: hidden;
  border: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

#camera-video, #camera-canvas, #camera-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Framing Guide */
.camera-framing-guide {
  position: absolute;
  inset: 24px;
  border: 1.5px dashed rgba(167, 139, 250, 0.5);
  border-radius: var(--r-lg);
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 14px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}

.camera-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: #a78bfa;
  border-style: solid;
}
.camera-corner.top-left     { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-top-left-radius: 6px; }
.camera-corner.top-right    { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-top-right-radius: 6px; }
.camera-corner.bottom-left  { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-bottom-left-radius: 6px; }
.camera-corner.bottom-right { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-bottom-right-radius: 6px; }

.camera-scan-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #a78bfa, transparent);
  box-shadow: 0 0 10px #a78bfa;
  animation: cameraScan 2.5s ease-in-out infinite alternate;
}
@keyframes cameraScan {
  from { top: 4px; opacity: 0.3; }
  to { top: calc(100% - 6px); opacity: 0.9; }
}

.camera-guide-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f1f5f9;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* Error view */
.camera-error-view {
  position: absolute;
  inset: 0;
  background: #0d1117;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 12px;
  z-index: 5;
}
.camera-error-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-error-icon svg {
  width: 26px;
  height: 26px;
}
.camera-error-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}
.camera-error-msg {
  font-size: 13.5px;
  color: var(--txt-2);
  max-width: 380px;
  line-height: 1.55;
  margin: 0;
}
.camera-error-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* Tips */
.camera-tips-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.camera-tip-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--txt-2);
  font-weight: 500;
}
.camera-tip-item svg {
  width: 14px;
  height: 14px;
  color: var(--violet-d);
  flex-shrink: 0;
}

/* Controls */
.camera-controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 4px 0;
}
.camera-shutter-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}
.camera-shutter-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.2);
  border: 3px solid var(--violet);
  padding: 4px;
  cursor: pointer;
  transition: all var(--t-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.4);
}
.camera-shutter-btn:hover {
  transform: scale(1.06);
  border-color: #ffffff;
  box-shadow: 0 0 28px rgba(124, 58, 237, 0.6);
}
.camera-shutter-btn:active {
  transform: scale(0.94);
}
.camera-shutter-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #ffffff;
  transition: all var(--t-fast);
}
.camera-shutter-btn:hover .camera-shutter-inner {
  background: var(--violet-d);
}

.camera-review-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
}
.camera-review-controls .btn {
  flex: 1;
  max-width: 200px;
  justify-content: center;
}

/* ============================================================
   TOAST / COPY FEEDBACK
   ============================================================ */
#toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--success);
  color: #fff; padding: 10px 20px;
  border-radius: var(--r-lg);
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 28px rgba(16,185,129,.4);
  opacity: 0; pointer-events: none;
  transition: all var(--t-spring);
  z-index: 2000;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast svg { width: 16px; height: 16px; }

/* ============================================================
   ABOUT PAGE
   ============================================================ */
.about-wrap {
  max-width: 780px; margin: 0 auto;
  padding: 100px 24px 80px;
  position: relative; z-index: 1;
}

.about-hero {
  text-align: center; padding-bottom: 64px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 64px;
}
.about-hero .hero-badge { animation: none; }
.about-title {
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 900; letter-spacing: -.04em;
  margin: 16px 0 18px;
}
.about-lead {
  font-size: 17px; color: var(--txt-2); line-height: 1.7;
  max-width: 580px; margin: 0 auto; font-weight: 500;
}

.about-section { margin-bottom: 56px; }
.about-sec-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--violet-d); margin-bottom: 12px;
}
.about-sec-title { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 16px; }
.about-body {
  color: var(--txt-2); font-size: 15.5px; line-height: 1.8;
}
.about-body p { margin-bottom: 16px; }
.about-body p:last-child { margin-bottom: 0; }

/* Steps */
.flow-steps { display: flex; flex-direction: column; gap: 16px; margin: 24px 0; }
.flow-step {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 18px 20px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: all var(--t-base);
}
.flow-step:hover { border-color: rgba(124,58,237,.3); background: var(--card-2); }

.step-num {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--g-brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; flex-shrink: 0;
  box-shadow: var(--sh-brand);
}
.step-body { flex: 1; }
.step-heading { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.step-detail { font-size: 13.5px; color: var(--txt-2); line-height: 1.55; font-weight: 500; }

/* Caution box */
.caution-box {
  border: 1px solid rgba(245,158,11,.38);
  background: rgba(245,158,11,.07);
  border-radius: var(--r-xl); padding: 24px;
  margin: 32px 0;
}
.caution-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.caution-head svg { width: 20px; height: 20px; color: var(--warning); }
.caution-head strong { font-size: 16px; font-weight: 700; color: var(--warning); }
.caution-body { font-size: 14px; color: var(--txt-2); line-height: 1.7; font-weight: 500; }

/* Privacy grid */
.privacy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 24px 0; }
.priv-card {
  padding: 20px; border-radius: var(--r-lg);
  background: var(--card); border: 1px solid var(--border);
}
.priv-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--g-soft); display: flex; align-items: center;
  justify-content: center; margin-bottom: 12px;
}
.priv-icon svg { width: 16px; height: 16px; color: var(--violet); }
.priv-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.priv-desc { font-size: 13px; color: var(--txt-2); line-height: 1.5; font-weight: 500; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  margin-top: auto !important;
  border-top: 1px solid var(--border);
  background: var(--g-footer);
  padding: 32px 24px 28px;
  position: relative; z-index: 1;
  width: 100%; box-sizing: border-box;
  flex-shrink: 0;
}
.footer-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; flex-direction: column;
  gap: 18px;
  width: 100%; box-sizing: border-box;
}
.footer-top {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 16px;
  width: 100%;
}
.footer-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.footer-brand-name {
  font-size: 15px; font-weight: 700;
  background: var(--g-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.footer-copy {
  font-size: 13px; color: #cbd5e1; font-weight: 500; line-height: 1.6;
  text-align: right; margin: 0;
}
.footer-divider {
  height: 1px; width: 100%;
  background: var(--border-2);
}
.footer-links {
  display: flex; justify-content: center; align-items: center;
  flex-wrap: wrap; gap: 12px 18px;
  width: 100%; text-align: center;
}
.footer-link {
  font-size: 13.5px; color: #cbd5e1; text-decoration: none;
  transition: color var(--t-base); font-weight: 600;
}
.footer-link:hover { color: #ffffff; text-decoration: underline; }
.footer-btn-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.footer-sep { color: var(--txt-3); font-size: 14px; user-select: none; }


/* ============================================================
   RESPONSIVE — Tablet (1024px)
   ============================================================ */
@media (max-width: 1024px) {
  .container { padding: 0 20px; }
  #app-section { max-width: 100%; padding: 24px 20px 80px; }
  .about-wrap { padding: 90px 20px 60px; }
}

/* ============================================================
   RESPONSIVE — Mobile (768px & smaller) GROUND-UP OVERHAUL
   ============================================================ */
@media (max-width: 768px) {
  /* Global Layout Protection */
  html, body {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .container, .about-wrap, .history-section {
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
  }
  #app-section {
    max-width: 100% !important;
    padding: 80px 16px 80px !important;
    box-sizing: border-box !important;
  }

  /* Form Inputs — 16px min font size to prevent iOS Safari auto-zoom */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  .input {
    font-size: 16px !important;
    min-height: 46px;
    padding: 10px 14px;
    box-sizing: border-box;
  }

  /* Header & Navigation Drawer */
  .header {
    height: 60px;
    z-index: 200;
  }
  .header-inner {
    padding: 0 16px;
    justify-content: space-between;
  }
  .nav-link, .nav-cta, .nav-signin-btn, .nav-key-btn {
    display: none !important;
  }
  .menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    flex-shrink: 0;
  }
  .mobile-nav {
    top: 60px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    box-sizing: border-box;
  }
  .mobile-nav-link {
    padding: 14px 16px;
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: 16px;
  }

  /* Hero Section — clearance for fixed 60px navbar */
  #hero-panel {
    padding: 84px 0 28px !important;
    scroll-margin-top: 72px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
  }
  .hero-title {
    font-size: clamp(26px, 7vw, 36px);
    line-height: 1.25;
    letter-spacing: -.03em;
  }
  .hero-subtitle {
    font-size: 15px;
    line-height: 1.6;
    margin: 12px auto 20px;
  }
  #upload-zone {
    width: 100%;
    box-sizing: border-box;
  }
  .upload-area {
    padding: 28px 16px;
    min-height: 180px;
    width: 100%;
    box-sizing: border-box;
  }
  .upload-title {
    font-size: 16px;
  }
  .upload-desc {
    font-size: 13.5px;
  }
  .upload-shortcuts {
    display: none; /* keyboard shortcuts hidden on mobile touch devices */
  }
  .upload-meta {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    text-align: center !important;
  }
  .upload-meta .trust-badge,
  .upload-meta span {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    padding: 5px 11px !important;
    font-size: 11.5px !important;
    white-space: nowrap !important;
  }
  .hero-auth-callout {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    font-size: 13.5px;
  }
  .hero-auth-btn {
    font-size: 14px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Workflow Step Header */
  .sec-header {
    margin-bottom: 20px;
  }
  .sec-title {
    font-size: 22px;
  }
  .sec-sub {
    font-size: 14px;
  }

  /* Batch Thumbnail Grid on Mobile: 2 columns max */
  .batch-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }
  .batch-card-info {
    padding: 8px 10px;
  }
  .batch-card-name {
    font-size: 11.5px;
  }
  .batch-tabs-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .batch-tabs-scroll {
    width: 100%;
    padding-bottom: 2px;
  }
  .batch-tabs-bar #batch-copy-all-btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  /* Crop Selection Panel */
  .crop-options {
    grid-template-columns: 1fr;
    gap: 14px;
    width: 100%;
  }
  .crop-card {
    width: 100%;
    box-sizing: border-box;
    padding: 20px;
  }
  .crop-card-title {
    font-size: 16.5px;
  }
  .crop-card-desc {
    font-size: 14px;
    line-height: 1.5;
  }

  /* Manual Crop Panel & Canvas */
  #manual-crop-canvas {
    max-height: 45vh !important;
    width: 100% !important;
    object-fit: contain;
  }
  .manual-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
  }
  .manual-toolbar .btn-icon {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
  .crop-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-top: 16px;
    width: 100%;
    box-sizing: border-box;
  }
  .crop-actions {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }
  .crop-actions .btn {
    width: 100%;
    min-height: 48px;
    font-size: 15px;
    justify-content: center;
    box-sizing: border-box;
  }

  /* Processing Panel — Vertically centered with generous top clearance */
  #processing-panel:not(.hidden) {
    min-height: calc(100vh - 220px);
    min-height: calc(100dvh - 220px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 24px;
    padding: 24px 0 48px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
  }
  .processing-title {
    font-size: 20px;
  }
  .processing-sub {
    font-size: 14px;
  }

  /* Result Panel & Sticky Topbar */
  #result-panel:not(.hidden) {
    gap: 16px;
    width: 100%;
    min-height: calc(100vh - 200px);
    min-height: calc(100dvh - 200px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: visible;
  }
  .result-topbar {
    position: sticky;
    top: 68px;
    z-index: 20;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    background: rgba(13,17,23,.96);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-2);
    border-radius: var(--r-xl);
  }
  .result-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
  .result-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  .result-actions .btn {
    width: 100%;
    min-height: 48px;
    font-size: 14.5px;
    justify-content: center;
    box-sizing: border-box;
  }
  .result-cta {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 12px;
    padding: 16px 0 44px;
    margin-bottom: 24px;
    box-sizing: border-box;
  }
  .result-cta .btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
    font-size: 15px;
  }
  #copy-btn {
    width: 100%;
    min-height: 48px;
    font-size: 15.5px;
    font-weight: 700;
  }

  /* Code Block & Viewer */
  .code-window {
    width: 100%;
    box-sizing: border-box;
    border-radius: var(--r-xl);
    overflow: visible !important;
  }
  .code-titlebar {
    padding: 10px 14px;
    border-top-left-radius: var(--r-xl);
    border-top-right-radius: var(--r-xl);
  }
  .code-scroll {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    border-bottom-left-radius: var(--r-xl);
    border-bottom-right-radius: var(--r-xl);
  }
  .code-scroll pre {
    font-size: 12.5px !important;
    padding: 16px 14px !important;
    line-height: 1.65 !important;
    white-space: pre !important;
    word-break: normal !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    width: max-content;
    min-width: 100%;
  }
  .code-scroll pre code {
    white-space: pre !important;
    word-break: normal !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
  }

  /* Ambiguity Warnings, Reverify & Tip Callouts */
  .ambig-box, .reverify-card, .tip-callout {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px;
  }
  .ambig-item {
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
  }
  .reverify-text, .tip-callout-text {
    font-size: 13.5px;
    line-height: 1.55;
  }

  /* Modals (Auth & Error) */
  .modal-backdrop {
    padding: 16px;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }
  .modal {
    width: 100%;
    max-width: 440px;
    padding: 24px 20px;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--r-xl);
    box-sizing: border-box;
  }
  .modal-title {
    font-size: 19px;
  }
  .modal-desc {
    font-size: 14px;
    line-height: 1.55;
  }
  .modal-actions {
    width: 100%;
    gap: 10px;
  }
  .modal-actions .btn {
    width: 100%;
    min-height: 48px;
    font-size: 15.5px;
    justify-content: center;
    box-sizing: border-box;
  }

  /* Camera Mobile Styles */
  .camera-action-card {
    margin-top: 14px;
    padding: 16px 14px;
    gap: 12px;
    border-width: 2px;
    background: linear-gradient(135deg, rgba(124,58,237,.25) 0%, rgba(99,102,241,.18) 100%);
    box-shadow: 0 4px 20px rgba(0,0,0,.35), 0 0 28px rgba(124,58,237,.25);
  }
  .camera-action-icon-wrap {
    width: 44px;
    height: 44px;
  }
  .camera-action-icon-wrap svg {
    width: 22px;
    height: 22px;
  }
  .camera-action-title {
    font-size: 15.5px;
  }
  .camera-action-sub {
    font-size: 12.5px;
  }
  .camera-modal-content {
    padding: 16px;
    max-height: 94vh;
    border-radius: var(--r-xl);
  }
  .camera-viewport-wrap {
    aspect-ratio: 3 / 4;
    max-height: 52vh;
  }
  .camera-shutter-btn {
    width: 72px;
    height: 72px;
  }
  .camera-review-controls {
    flex-direction: row;
    gap: 10px;
  }
  .camera-review-controls .btn {
    min-height: 48px;
    font-size: 15px;
    flex: 1;
    max-width: none;
  }

  /* Recent Extractions History */
  .history-section {
    width: 100%;
    box-sizing: border-box;
    margin-top: 20px;
  }
  .history-card {
    padding: 16px;
  }
  .history-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }
  .history-item-left {
    width: 100%;
  }
  .history-item-right {
    width: 100%;
    justify-content: space-between;
  }
  .history-restore-btn {
    min-height: 40px;
    font-size: 13px;
    padding: 6px 16px;
  }

  /* About Page */
  .about-wrap {
    padding: 80px 16px 60px !important;
    width: 100%;
    box-sizing: border-box;
  }
  .about-title {
    font-size: clamp(26px, 6vw, 38px);
  }
  .about-lead {
    font-size: 15px;
  }
  .about-sec-title {
    font-size: 22px;
  }
  .about-body p {
    font-size: 14.5px;
    line-height: 1.65;
  }
  .privacy-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
  }
  .priv-card, .flow-step, .caution-box {
    width: 100%;
    box-sizing: border-box;
    padding: 16px;
  }
  .footer {
    padding: 28px 16px 24px;
  }
  .footer-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
  }
  .footer-top {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
  }
  .footer-copy {
    text-align: center;
    font-size: 12px;
  }
  .footer-links {
    gap: 10px 14px;
  }
  .footer-sep {
    display: inline;
  }
}

@media (max-width: 480px) {
  /* Extra adjustments for 375px - 414px small screens */
  .container, #app-section, .about-wrap {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .header-inner {
    padding: 0 12px;
  }
  #hero-panel {
    padding: 36px 0 24px;
  }
  .code-scroll pre {
    font-size: 11.5px !important;
    padding: 14px 10px !important;
  }
  .upload-area {
    padding: 24px 12px;
    min-height: 160px;
  }
  .user-pill {
    display: none !important;
  }
}

/* ============================================================
   HLJS THEME OVERRIDES
   ============================================================ */
.hljs { background: transparent !important; }

/* ============================================================
   LOGO VISIBILITY
   ============================================================ */
.logo-img {
  width: 30px; height: 30px;
  border-radius: 8px; overflow: hidden;
  border: 1.5px solid rgba(124,58,237,.55);
  box-shadow: 0 0 0 2px rgba(124,58,237,.18), 0 2px 8px rgba(0,0,0,.5);
  background: #0d1117;
  flex-shrink: 0;
}
.logo-img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  /* boost brightness/contrast so the icon pops on dark backgrounds */
  filter: brightness(1.15) contrast(1.1) saturate(1.2);
}

/* ============================================================
   AUTH MODAL
   ============================================================ */
.auth-modal { max-width: 420px; }

/* Tabs */
.auth-tabs {
  display: flex; gap: 4px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1; padding: 8px 12px;
  border-radius: var(--r-md); border: none;
  background: transparent; color: var(--txt-3);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all var(--t-base);
  line-height: 1;
}
.auth-tab:hover { color: var(--txt-2); background: var(--card); }
.auth-tab.active {
  background: var(--g-brand); color: #fff;
  box-shadow: var(--sh-brand);
}

/* Inline error */
.auth-error {
  font-size: 13px; color: var(--danger);
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--r-sm); padding: 8px 12px;
  margin-bottom: 12px; line-height: 1.4;
}

/* Password strength bar */
.pw-strength-wrap {
  display: flex; align-items: center; gap: 10px;
  margin: -4px 0 14px;
}
.pw-strength-bar {
  flex: 1; height: 3px;
  background: var(--border);
  border-radius: var(--r-full); overflow: hidden;
}
.pw-strength-fill {
  height: 100%; width: 0%;
  border-radius: var(--r-full);
  transition: width .35s ease, background .35s ease;
}
.pw-strength-lbl { font-size: 11px; font-weight: 700; min-width: 48px; }

/* ============================================================
   USER PILL (header — signed-in state)
   ============================================================ */
.user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px 5px 12px;
  background: rgba(124,58,237,.1); border: 1px solid rgba(124,58,237,.25);
  border-radius: var(--r-full);
  font-size: 13px; color: var(--txt-2);
  max-width: 280px;
}
.user-pill-email {
  font-weight: 600; color: var(--txt);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 130px;
}
.user-pill-sep { color: var(--txt-3); font-weight: 700; }
.user-pill-remaining { font-size: 12px; white-space: nowrap; font-weight: 500; }
.user-signout-btn {
  padding: 3px 8px; font-size: 12px; height: auto;
  color: var(--txt-2); flex-shrink: 0; font-weight: 500;
}
.user-signout-btn:hover { color: var(--danger); background: rgba(243,108,108,.08); }

/* Nav sign-in button */
.nav-signin-btn {
  font-size: 13px; padding: 6px 12px;
  border: 1px solid var(--border-2);
}

/* ============================================================
   RESPONSIVE — auth additions
   ============================================================ */
@media (max-width: 768px) {
  .user-pill { max-width: 180px; gap: 6px; padding: 4px 6px 4px 10px; }
  .user-pill-email { max-width: 80px; }
  .user-pill-remaining { display: none; }  /* too cramped; shown in mobile drawer instead */
  /* .nav-signin-btn stays hidden (defined in main 768px block) — auth is in mobile drawer */
}

@media (max-width: 480px) {
  .user-pill { font-size: 12px; }
  .auth-modal { margin: 16px; }
}

/* ============================================================
   RECENT EXTRACTIONS HISTORY & AMBIGUITIES ENHANCEMENTS
   ============================================================ */
.history-section {
  max-width: 860px; margin: 24px auto 0;
  position: relative; z-index: 1; padding: 0 24px;
}
.history-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 20px 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.history-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.history-title-wrap { display: flex; align-items: center; gap: 8px; }
.history-title { font-size: 16px; font-weight: 700; color: var(--txt); }
.history-badge {
  font-size: 11px; font-weight: 700; color: var(--violet-d);
  background: rgba(124,58,237,.12); border: 1px solid rgba(124,58,237,.25);
  padding: 2px 8px; border-radius: 12px; text-transform: uppercase;
}
.history-sub { font-size: 12px; color: var(--txt-3); font-weight: 500; }

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 16px;
  background: var(--card-2); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); transition: all var(--t-base);
}
.history-item:hover {
  border-color: rgba(124,58,237,.4);
  background: rgba(124,58,237,.06);
}
.history-item-left {
  display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1;
}
.history-lang-badge {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(124,58,237,.2); color: var(--violet-d);
  text-transform: uppercase; flex-shrink: 0;
}
.history-code-snippet {
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px;
  color: var(--txt-2); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; flex: 1;
}
.history-item-right {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.history-time { font-size: 11.5px; color: var(--txt-3); font-weight: 500; }
.history-restore-btn {
  font-size: 12px; padding: 5px 12px; border-radius: var(--r-md);
}

.ambig-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; border-radius: var(--r-md);
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.2);
  font-size: 13px; color: var(--txt-2); font-weight: 500;
}
.ambig-line-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: 4px;
  background: rgba(245,158,11,.2); color: var(--warning);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; flex-shrink: 0;
}
.ambig-code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255,255,255,.1); color: var(--txt);
  padding: 1px 6px; border-radius: 4px; font-weight: 600;
}

/* Hero Auth Promo Callout */
.hero-auth-callout {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; margin-top: 14px; padding: 8px 16px;
  background: var(--card-2); border: 1px solid var(--border-2);
  border-radius: var(--r-xl); font-size: 13px; color: var(--txt-2);
  box-shadow: 0 4px 16px rgba(0,0,0,.2); flex-wrap: wrap;
}
.hero-auth-btn {
  background: var(--g-brand); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; font-weight: 700;
  border: none; cursor: pointer; padding: 2px 4px;
  text-decoration: underline; font-size: 13px;
  transition: opacity var(--t-base);
}
.hero-auth-btn:hover { opacity: 0.85; }

/* ============================================================
   EXTRACTION HISTORY DRAWER
   ============================================================ */
.history-drawer-wrap {
  position: fixed; inset: 0; z-index: 1500;
  display: flex; justify-content: flex-end;
  transition: opacity 0.25s ease;
}
.history-drawer-wrap.hidden {
  display: none !important;
}

.history-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  animation: fadeIn 0.2s ease both;
}

.history-drawer {
  position: relative; z-index: 1;
  width: 100%; max-width: 480px; height: 100%;
  background: var(--card);
  border-left: 1px solid var(--border-2);
  box-shadow: -8px 0 36px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column;
  animation: slideDrawer 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes slideDrawer {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.history-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-2);
  background: var(--surface);
}
.history-header-left {
  display: flex; align-items: center; gap: 14px;
}
.history-header-icon {
  width: 38px; height: 38px; border-radius: var(--r-md);
  background: rgba(124, 58, 237, 0.16);
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: var(--violet-d);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.history-header-icon svg { width: 19px; height: 19px; }

.history-title-row {
  display: flex; align-items: center; gap: 8px;
}
.history-title {
  font-size: 16px; font-weight: 700; color: var(--txt);
  margin: 0; line-height: 1.2;
}
.history-count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 99px; font-size: 11px; font-weight: 700;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(167, 139, 250, 0.4);
  color: var(--violet-d);
}
.history-sub {
  font-size: 12px; color: var(--txt-3); margin-top: 3px; font-weight: 500;
}
.history-close-btn {
  color: var(--txt-2);
}
.history-close-btn:hover {
  color: var(--txt); background: var(--card-2);
}

.history-body {
  flex: 1; overflow-y: auto;
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
}

.history-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 20px; color: var(--txt-2); font-size: 14px;
}

.history-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 60px 24px;
  background: var(--surface); border: 1px dashed var(--border-2);
  border-radius: var(--r-xl); margin-top: 20px;
}
.history-empty-icon {
  width: 52px; height: 52px; border-radius: var(--r-xl);
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.25);
  color: var(--violet-d);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.history-empty-icon svg { width: 24px; height: 24px; }
.history-empty-title {
  font-size: 16px; font-weight: 700; color: var(--txt); margin-bottom: 6px;
}
.history-empty-desc {
  font-size: 13.5px; color: var(--txt-2); max-width: 300px; line-height: 1.5;
}

.history-list {
  display: flex; flex-direction: column; gap: 14px;
}

.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  transition: all var(--t-base);
  position: relative;
}
.history-card:hover {
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.history-card-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}

.history-card-name-wrap {
  flex: 1; min-width: 0;
}
.history-card-name {
  font-size: 14.5px; font-weight: 700; color: var(--txt);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  word-break: break-word; transition: color var(--t-base);
}
.history-card-name:hover {
  color: var(--violet-d);
}
.history-card-name svg {
  width: 12px; height: 12px; opacity: 0.6; flex-shrink: 0;
}
.history-card-name:hover svg {
  opacity: 1; color: var(--violet-d);
}

.history-rename-form {
  display: flex; align-items: center; gap: 6px; width: 100%;
}
.history-rename-input {
  flex: 1; padding: 5px 10px; font-size: 13px; font-weight: 600;
  background: var(--card-2); border: 1px solid var(--purple);
  border-radius: var(--r-md); color: var(--txt);
  outline: none; font-family: inherit;
}
.history-rename-input:focus {
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.3);
}

.history-meta-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  font-size: 12px; color: var(--txt-3);
}
.history-lang-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600;
  background: rgba(124, 58, 237, 0.15); border: 1px solid rgba(167, 139, 250, 0.35);
  color: var(--violet-d); text-transform: capitalize;
}
.history-date {
  color: var(--txt-2); font-weight: 500;
}
.history-expiry-tag {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--txt-3); font-size: 11.5px;
}
.history-expiry-tag svg { width: 12px; height: 12px; color: var(--warning); opacity: 0.85; }

.history-code-preview {
  margin: 0; padding: 10px 12px;
  background: rgba(7, 9, 15, 0.8);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; line-height: 1.45;
  color: var(--txt-2);
  white-space: pre; overflow-x: hidden;
  max-height: 70px;
}

.history-card-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.history-load-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600;
}
.history-del-btn {
  color: var(--txt-3); padding: 5px 8px; font-size: 12px;
}
.history-del-btn:hover {
  color: #ef4444; background: rgba(239, 68, 68, 0.1);
}

