/* ═══════════════════════════════════════════════
   PassSnap — style.css
   ═══════════════════════════════════════════════ */

/* ── THEMES ── */
[data-theme="light"] {
  --bg: #f5f0e8;
  --surface: #ffffff;
  --surface2: #ede8d8;
  --ink: #0f0e0d;
  --ink2: #4a4540;
  --muted: #7a7060;
  --border: #d4cdb8;
  --accent: #c9432a;
  --accent-hover: #a83520;
  --accent-glow: rgba(201,67,42,0.18);
  --green: #2a9c5c;
  --green-hover: #1e7a47;
  --shadow: 0 4px 20px rgba(15,14,13,0.09);
  --shadow-lg: 0 12px 48px rgba(15,14,13,0.16);
  --header-bg: rgba(245,240,232,0.95);
  --crop-bg: #1e1c1a;
  --canvas-bg: #c8c4bc;
  --noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}
[data-theme="dark"] {
  --bg: #141210;
  --surface: #1e1b18;
  --surface2: #252220;
  --ink: #f0ebe0;
  --ink2: #c8c0b0;
  --muted: #7a7060;
  --border: #333028;
  --accent: #e05030;
  --accent-hover: #c03f22;
  --accent-glow: rgba(224,80,48,0.20);
  --green: #34b86a;
  --green-hover: #28a05a;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
  --header-bg: rgba(20,18,16,0.95);
  --crop-bg: #0e0c0a;
  --canvas-bg: #2a2824;
  --noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}
[data-theme="navy"] {
  --bg: #0d1b2a;
  --surface: #142233;
  --surface2: #1a2d40;
  --ink: #e8f0f8;
  --ink2: #a0b8cc;
  --muted: #607888;
  --border: #2a3d50;
  --accent: #f0a030;
  --accent-hover: #d88820;
  --accent-glow: rgba(240,160,48,0.18);
  --green: #30c880;
  --green-hover: #22a868;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
  --header-bg: rgba(13,27,42,0.96);
  --crop-bg: #060e16;
  --canvas-bg: #1e3048;
  --noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
[data-theme="forest"] {
  --bg: #0e1a10;
  --surface: #162018;
  --surface2: #1e2c20;
  --ink: #e0f0e0;
  --ink2: #90b090;
  --muted: #508050;
  --border: #2a3c2c;
  --accent: #f0c040;
  --accent-hover: #d8a828;
  --accent-glow: rgba(240,192,64,0.18);
  --green: #40d080;
  --green-hover: #30b068;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
  --header-bg: rgba(14,26,16,0.96);
  --crop-bg: #070e08;
  --canvas-bg: #243826;
  --noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
[data-theme="rose"] {
  --bg: #fdf5f5;
  --surface: #ffffff;
  --surface2: #fde8e8;
  --ink: #200808;
  --ink2: #503030;
  --muted: #906060;
  --border: #e8c8c8;
  --accent: #c82050;
  --accent-hover: #a01840;
  --accent-glow: rgba(200,32,80,0.15);
  --green: #2a9060;
  --green-hover: #1e7048;
  --shadow: 0 4px 20px rgba(200,32,80,0.08);
  --shadow-lg: 0 12px 48px rgba(200,32,80,0.14);
  --header-bg: rgba(253,245,245,0.95);
  --crop-bg: #180808;
  --canvas-bg: #e8d0d0;
  --noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Outfit', sans-serif;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: var(--noise);
}

/* ── HEADER ── */
#site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 36px; height: 58px;
  background: var(--header-bg);
  border-bottom: 1.5px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s;
}
.logo {
  font-family: 'DM Serif Display', serif;
  font-size: 23px; letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; text-decoration: none; color: var(--ink);
  transition: opacity 0.2s;
}
.logo:hover { opacity: 0.8; }
.logo em { color: var(--accent); font-style: normal; }
.logo-dot {
  width: 8px; height: 8px; background: var(--accent);
  border-radius: 50%; animation: pulse 2.2s infinite;
  flex-shrink: 0;
}
@keyframes pulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.6);opacity:0.5} }

.header-right { display: flex; align-items: center; gap: 10px; }

/* Theme switcher */
.theme-switcher { display: flex; align-items: center; gap: 5px; }
.theme-btn {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
  position: relative;
}
.theme-btn:hover { transform: scale(1.2); }
.theme-btn.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }
.theme-btn[data-t="light"]  { background: linear-gradient(135deg,#f5f0e8 50%,#c9432a 50%); }
.theme-btn[data-t="dark"]   { background: linear-gradient(135deg,#141210 50%,#e05030 50%); }
.theme-btn[data-t="navy"]   { background: linear-gradient(135deg,#0d1b2a 50%,#f0a030 50%); }
.theme-btn[data-t="forest"] { background: linear-gradient(135deg,#0e1a10 50%,#f0c040 50%); }
.theme-btn[data-t="rose"]   { background: linear-gradient(135deg,#fdf5f5 50%,#c82050 50%); }

.badge {
  font-family: 'DM Mono', monospace; font-size: 9px;
  background: var(--ink); color: var(--bg);
  padding: 3px 9px; border-radius: 20px; letter-spacing: 1px; text-transform: uppercase;
}

/* ── MAIN ── */
.main {
  position: relative; z-index: 1;
  max-width: 1120px; margin: 0 auto;
  padding: 80px 20px 80px; /* 80px top = header height + gap */
}

/* ── HERO ── */
.hero { text-align: center; margin-bottom: 36px; }
.hero h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(32px,5vw,56px); line-height: 1.1;
  letter-spacing: -1px; margin-bottom: 10px;
}
.hero h1 em { color: var(--accent); font-style: italic; }
.hero p { color: var(--muted); font-size: 14px; font-weight: 300; max-width: 400px; margin: 0 auto; line-height: 1.7; }

/* ── WORKSPACE GRID ── */
.workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

/* ── PANEL ── */
.panel {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s;
}
.panel-header {
  padding: 14px 18px 11px; border-bottom: 1.5px solid var(--border);
  display: flex; align-items: center; gap: 8px; background: var(--surface2);
  transition: background 0.3s, border-color 0.3s;
}
.panel-header h2 {
  font-size: 10px; font-weight: 700; letter-spacing: 0.9px;
  text-transform: uppercase; font-family: 'DM Mono', monospace; color: var(--muted);
}
.panel-num {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink); color: var(--bg);
  font-size: 10px; font-family: 'DM Mono', monospace;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.panel-body { padding: 18px; }

/* ── UPLOAD ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 11px;
  padding: 38px 16px; text-align: center; cursor: pointer;
  transition: all 0.22s; background: var(--surface2); position: relative;
}
.upload-zone:hover, .upload-zone.over { border-color: var(--accent); background: var(--accent-glow); }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-icon { font-size: 38px; margin-bottom: 10px; display: block; }
.upload-zone p { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.upload-zone strong { color: var(--accent); }
.upload-hint { font-size: 10px; color: var(--muted); font-family: 'DM Mono', monospace; margin-top: 4px; display: block; }

#preview-container { display: none; flex-direction: column; gap: 10px; }
.preview-img-wrap { border-radius: 9px; overflow: hidden; border: 1.5px solid var(--border); background: var(--surface2); }
#preview-img { width: 100%; height: 210px; object-fit: cover; display: block; }

/* ── BUTTONS ── */
.btn {
  font-family: 'Outfit', sans-serif; font-weight: 500; font-size: 12px;
  padding: 8px 14px; border-radius: 8px; border: 1.5px solid transparent;
  cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center;
  justify-content: center; gap: 5px; white-space: nowrap;
}
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary { background: var(--ink); color: var(--bg); flex: 1; }
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-accent { background: var(--accent); color: #fff; width: 100%; font-size: 14px; padding: 12px 18px; }
.btn-accent:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow); }
.btn-accent:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-green { background: var(--green); color: #fff; flex: 1; }
.btn-green:hover { background: var(--green-hover); transform: translateY(-1px); }
.btn-edit {
  background: var(--surface2); border-color: var(--border);
  color: var(--ink2); width: 100%; font-size: 12px;
}
.btn-edit:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-edit.open { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-row { display: flex; gap: 7px; flex-wrap: wrap; }

/* ── SETTINGS ── */
.setting-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.setting-row:last-of-type { margin-bottom: 0; }
.setting-row label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.7px;
  text-transform: uppercase; font-family: 'DM Mono', monospace; color: var(--muted);
}
.select-wrap { position: relative; }
.select-wrap select {
  width: 100%; padding: 8px 28px 8px 10px; border: 1.5px solid var(--border);
  border-radius: 8px; background: var(--surface2); font-family: 'Outfit', sans-serif;
  font-size: 12px; color: var(--ink); cursor: pointer; appearance: none;
  transition: border-color 0.2s, background 0.2s;
}
.select-wrap select:focus { outline: none; border-color: var(--accent); }
.select-wrap::after { content: '▾'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); font-size: 10px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
input[type="number"], input[type="text"], input[type="color"] {
  width: 100%; padding: 7px 10px; border: 1.5px solid var(--border);
  border-radius: 8px; background: var(--surface2); color: var(--ink);
  font-family: 'Outfit', sans-serif; font-size: 12px; transition: border-color 0.2s;
}
input[type="number"]:focus, input[type="text"]:focus { outline: none; border-color: var(--accent); }
input[type="color"] { padding: 3px 5px; height: 34px; cursor: pointer; }

/* ── BACKGROUND COLORS ── */
.color-options { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.color-btn {
  width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid transparent;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.color-btn:hover { transform: scale(1.18); }
.color-btn.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.custom-color-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.custom-color-row label { font-size: 11px; color: var(--muted); font-family: 'DM Mono', monospace; white-space: nowrap; }

/* ── EDIT DRAWER ── */
.edit-drawer {
  display: none; border: 1.5px solid var(--accent); border-radius: 12px;
  overflow: hidden; margin-top: 4px; background: var(--surface);
  box-shadow: 0 6px 28px var(--accent-glow); animation: slideDown .2s ease;
}
.edit-drawer.open { display: block; }
@keyframes slideDown { from{opacity:0;transform:translateY(-6px)} to{opacity:1;transform:translateY(0)} }
.edit-drawer-inner { display: grid; grid-template-columns: 1fr 1fr; }
.crop-side { padding: 14px; background: var(--crop-bg); border-right: 1px solid rgba(255,255,255,0.06); display: flex; flex-direction: column; gap: 8px; }
.crop-canvas-wrap { border-radius: 8px; overflow: hidden; }
#crop-canvas { display: block; width: 100%; cursor: move; }
.crop-actions { display: flex; gap: 6px; }
.cbtn {
  flex: 1; padding: 7px 6px; border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 7px; background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.75); cursor: pointer; font-size: 11px;
  font-family: 'Outfit', sans-serif; font-weight: 600; transition: all 0.2s; text-align: center;
}
.cbtn:hover { background: rgba(255,255,255,0.14); color: #fff; border-color: rgba(255,255,255,0.3); }
.cbtn-apply { background: var(--green); border-color: var(--green); color: #fff; }
.cbtn-apply:hover { background: var(--green-hover); }

.controls-side { padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; max-height: 420px; background: var(--surface); }
.controls-side::-webkit-scrollbar { width: 4px; }
.controls-side::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.ctrl-section { display: flex; flex-direction: column; gap: 7px; }
.ctrl-title {
  font-size: 9px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
  font-family: 'DM Mono', monospace; color: var(--muted);
  padding-bottom: 5px; border-bottom: 1px solid var(--border);
}
.slider-row { display: flex; flex-direction: column; gap: 3px; }
.slider-label { display: flex; justify-content: space-between; align-items: center; }
.slider-label span { font-size: 10px; color: var(--ink2); font-family: 'DM Mono', monospace; }
.slider-val { font-size: 10px; font-family: 'DM Mono', monospace; background: var(--surface2); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); color: var(--ink); }
input[type=range] { width: 100%; accent-color: var(--accent); cursor: pointer; height: 3px; }
.rot-row { display: flex; gap: 5px; }
.rot-btn {
  flex: 1; padding: 6px; border: 1.5px solid var(--border); border-radius: 7px;
  background: var(--surface2); cursor: pointer; font-size: 15px; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; color: var(--ink);
}
.rot-btn:hover { border-color: var(--accent); background: var(--accent-glow); }
.filter-row { display: flex; gap: 5px; flex-wrap: wrap; }
.filter-btn {
  flex: 1; min-width: 44px; padding: 5px 4px; border: 1.5px solid var(--border);
  border-radius: 6px; background: var(--surface2); cursor: pointer;
  font-size: 10px; font-weight: 700; font-family: 'DM Mono', monospace;
  color: var(--muted); transition: all 0.2s; text-align: center;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.on { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

/* ── OUTPUT PANEL ── */
.output-panel { grid-column: 1 / -1; }
#output-area { display: none; flex-direction: column; gap: 14px; }
.sheet-info { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.sheet-info p { font-size: 11px; color: var(--muted); font-family: 'DM Mono', monospace; }
.sheet-info strong { color: var(--ink); }
#sheet-dims { font-family:'DM Mono',monospace; font-size:10px; background:var(--surface2); padding:3px 8px; border-radius:5px; border:1px solid var(--border); color: var(--muted); }
.canvas-wrapper { background: var(--canvas-bg); border-radius: 11px; padding: 12px; display: flex; justify-content: flex-start; align-items: flex-start; overflow: auto; max-height: 600px; }
#output-canvas { display: block; box-shadow: var(--shadow-lg); border-radius: 2px; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }
.download-bar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── SPINNER ── */
.spinner { width: 14px; height: 14px; border: 2.5px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: none; }
@keyframes spin { to{transform:rotate(360deg)} }
.generating .spinner { display: block; }
.generating .btn-text { display: none; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(70px);
  background: var(--ink); color: var(--bg);
  padding: 9px 18px; border-radius: 30px; font-size: 12px; font-weight: 500;
  transition: transform 0.32s cubic-bezier(.34,1.56,.64,1);
  z-index: 2000; white-space: nowrap; pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── RESPONSIVE ── */
@media (max-width: 720px) {
  .workspace { grid-template-columns: 1fr; }
  #site-header { padding: 0 14px; }
  .edit-drawer-inner { grid-template-columns: 1fr; }
  .crop-side { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.06); }
  .main { padding: 72px 12px 60px; }
  .badge { display: none; }
}

/* ── MULTI-SHEET PREVIEW ── */
.sheets-wrap { display: flex; flex-direction: column; gap: 14px; }
.sheet-page { position: relative; }
.sheet-page-label {
  font-size: 10px; font-family: 'DM Mono', monospace; color: var(--muted);
  margin-bottom: 6px;
}
