*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0d0f14;
  --surface:    #13161d;
  --card:       #181c25;
  --border:     #252a36;
  --border-hi:  #2f3647;
  --accent:     #00e5a0;
  --accent-dim: #00b07a;
  --danger:     #ff4d6d;
  --warn:       #ffb627;
  --text:       #e2e8f0;
  --muted:      #64748b;
  --mono:       'JetBrains Mono', monospace;
  --sans:       'Syne', sans-serif;
}

html, body { height: 100%; }

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex; flex-direction: column;
  position: relative; overflow-x: hidden;
}

body::before {
  content: ''; position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(0,229,160,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,160,.025) 1px, transparent 1px);
  background-size: 44px 44px; pointer-events: none; z-index: 0;
}

body::after {
  content: ''; position: fixed;
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,229,160,.05) 0%, transparent 70%);
  top: -100px; right: -100px; pointer-events: none; z-index: 0;
}

.page {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  min-height: 100vh; gap: .85rem;
  padding: 1.75rem 1.5rem 3rem;
  max-width: 1400px; margin: 0 auto; width: 100%;
}

/* ── Header ── */
.header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.header-left .tag {
  font-size: .68rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .35rem;
  display: flex; align-items: center; gap: .4rem;
}
.header-left .tag::before { content: '>'; }
h1 { font-family: var(--sans); font-size: 1.9rem; font-weight: 700; letter-spacing: -.015em; line-height: 1; }
h1 span { color: var(--accent); }
.header-meta { font-size: .68rem; color: var(--muted); line-height: 1.7; text-align: right; }

/* ── Drop zone ── */
.drop-zone {
  border: 1.5px dashed var(--border-hi);
  border-radius: 14px;
  background: var(--card);
  transition: border-color .15s, background .15s, padding .2s;
  overflow: hidden;
}

.dz-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .65rem; padding: 3.5rem 2rem; text-align: center;
}
.dz-icon {
  width: 52px; height: 52px; border-radius: 12px;
  background: rgba(0,229,160,.07); border: 1px solid rgba(0,229,160,.15);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.dz-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.dz-sub { font-size: .78rem; color: var(--muted); }
.dz-browse {
  color: var(--accent); background: none; border: none; cursor: pointer;
  font-family: var(--mono); font-size: .78rem;
  text-decoration: underline; text-underline-offset: 3px; padding: 0;
}
.dz-browse:hover { color: #00ffb3; }
.dz-hint { font-size: .65rem; color: var(--border-hi); letter-spacing: .03em; margin-top: .2rem; }

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(0,229,160,.04);
}
.drop-zone.drag-over .dz-icon { background: rgba(0,229,160,.12); border-color: rgba(0,229,160,.3); }

/* Loaded compact state */
.dz-loaded {
  display: flex; align-items: center; gap: .85rem;
  padding: .85rem 1.25rem;
}
.dz-loaded-icon {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.2);
  display: flex; align-items: center; justify-content: center; color: #fbbf24;
}
.dz-loaded-name {
  font-size: .82rem; color: var(--text); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dz-loaded-meta { font-size: .7rem; color: var(--muted); }
.dz-change {
  font-size: .68rem; color: var(--accent-dim); background: none; border: none;
  cursor: pointer; font-family: var(--mono); padding: .3rem .65rem;
  border-radius: 5px; border: 1px solid rgba(0,229,160,.2);
  transition: all .12s; white-space: nowrap;
}
.dz-change:hover { color: var(--accent); border-color: rgba(0,229,160,.4); background: rgba(0,229,160,.05); }

/* ── Controls bar ── */
.controls-bar {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: .85rem 1.1rem;
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end;
}
.ctrl-group { display: flex; flex-direction: column; gap: .4rem; }
.ctrl-label {
  font-size: .6rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
}
.ctrl-actions { margin-left: auto; display: flex; align-items: flex-end; gap: .5rem; flex-wrap: wrap; }

/* Tab groups (scale / bg) */
.tab-group {
  display: flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .18rem; gap: .12rem;
}
.tab-btn {
  padding: .28rem .7rem; border-radius: 6px; border: none;
  background: none; color: var(--muted);
  font-family: var(--mono); font-size: .72rem;
  cursor: pointer; transition: all .12s; white-space: nowrap;
}
.tab-btn.active { background: var(--accent); color: #0d0f14; font-weight: 700; }
.tab-btn:not(.active):hover { color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .38rem .85rem; border-radius: 7px; border: none;
  font-family: var(--mono); font-size: .75rem; cursor: pointer;
  transition: all .14s; white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #0d0f14; font-weight: 700; }
.btn-primary:not(:disabled):hover { background: #00ffb3; }
.btn-ghost {
  background: none; color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:not(:disabled):hover { color: var(--text); border-color: var(--border-hi); background: var(--surface); }

/* ── Info bar ── */
.info-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: .35rem;
  padding: .5rem .85rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; font-size: .69rem; color: var(--muted);
}
.info-sep { color: var(--border-hi); }
.info-file { color: var(--text); font-weight: 500; }
.info-scale { color: var(--accent-dim); }

/* ── Progress ── */
.progress-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden;
}
.progress-track {
  height: 3px; background: var(--border);
  position: relative; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent);
  width: 0; transition: width .25s ease;
  position: relative;
}
.progress-fill::after {
  content: ''; position: absolute; right: 0; top: 0; bottom: 0;
  width: 40px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.3));
}
.progress-label {
  padding: .5rem .85rem; font-size: .68rem; color: var(--muted);
}

/* ── Page grid ── */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .85rem;
}

.page-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .15s, transform .15s;
}
.page-card:hover { border-color: var(--border-hi); transform: translateY(-2px); }

.page-thumb {
  /* Checkerboard pattern to show transparency */
  background-color: #252a36;
  background-image:
    linear-gradient(45deg, #1a1e29 25%, transparent 25%),
    linear-gradient(-45deg, #1a1e29 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1e29 75%),
    linear-gradient(-45deg, transparent 75%, #1a1e29 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  display: flex; align-items: center; justify-content: center;
  min-height: 160px; position: relative; overflow: hidden;
  cursor: zoom-in;
}
.page-thumb img {
  width: 100%; height: auto; display: block;
  max-height: 320px; object-fit: contain;
}
.page-thumb:hover::after {
  content: '🔍';
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 1.4rem; opacity: .75;
}

.page-footer {
  padding: .6rem .75rem;
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  border-top: 1px solid var(--border);
}
.page-label { font-size: .7rem; color: var(--text); }
.page-dim { font-size: .6rem; color: var(--muted); margin-top: .08rem; }
.page-info { display: flex; flex-direction: column; min-width: 0; }
.btn-dl {
  font-size: .65rem; color: var(--accent-dim); cursor: pointer;
  padding: .28rem .6rem; border-radius: 5px;
  border: 1px solid rgba(0,229,160,.2); background: none;
  font-family: var(--mono); transition: all .12s;
  display: flex; align-items: center; gap: .3rem; white-space: nowrap; flex-shrink: 0;
}
.btn-dl:hover { color: var(--accent); border-color: rgba(0,229,160,.4); background: rgba(0,229,160,.05); }

/* ── Empty state in grid ── */
.grid-empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem; padding: 3rem; color: var(--muted); font-size: .78rem; text-align: center;
}
.grid-empty svg { opacity: .3; }

/* ── Error ── */
.error-bar {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; background: rgba(255,77,109,.06);
  border: 1px solid rgba(255,77,109,.2); border-radius: 8px;
  font-size: .75rem; color: #ff7191;
}
.error-bar svg { flex-shrink: 0; color: var(--danger); }

/* ── Footer ── */
.footer-note { font-size: .63rem; color: var(--muted); text-align: center; letter-spacing: .04em; }
.footer-note a { color: var(--accent-dim); text-decoration: none; }
.footer-note a:hover { color: var(--accent); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 99px; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.page { animation: fadeUp .35s ease both; }
@keyframes cardIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.page-card { animation: cardIn .18s ease both; }

@media (max-width: 860px) {
  .page-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .ctrl-actions { margin-left: 0; }
}
@media (max-width: 480px) {
  .page-grid { grid-template-columns: repeat(2, 1fr); }
  .controls-bar { gap: .75rem; }
}

/* ── Site Nav ── */
.site-nav {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(13,15,20,.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-nav-inner {
  display: flex; align-items: center; height: 56px; gap: 2rem;
  max-width: 1400px; margin: 0 auto; padding: 0 2rem; width: 100%;
}
.nav-logo { font-family: var(--mono); font-size: 1.35rem; font-weight: 500; color: var(--accent); text-decoration: none; letter-spacing: -.01em; white-space: nowrap; display: flex; align-items: center; gap: .15rem; }
.nav-logo .brace { color: var(--muted); font-weight: 400; }
.nav-links { display: flex; align-items: center; gap: 1.5rem; flex: 1; }
.nav-links a { font-family: var(--mono); font-size: .78rem; color: var(--muted); text-decoration: none; letter-spacing: .03em; transition: color .14s; }
.nav-links a:hover { color: var(--text); }
.nav-dropdown { position: relative; }
.nav-dropdown-toggle { display: inline-flex; align-items: center; gap: .35rem; background: none; border: none; cursor: pointer; font-family: var(--mono); font-size: .78rem; color: var(--accent); padding: 0; letter-spacing: .03em; transition: color .14s; }
.nav-dropdown-toggle:hover { color: #00ffb3; }
.nav-dropdown-toggle svg { transition: transform .2s ease; }
.nav-dropdown.open .nav-dropdown-toggle svg { transform: rotate(180deg); }
.nav-dropdown-menu { position: absolute; top: calc(100% + 1rem); left: 50%; transform: translateX(-50%); min-width: 220px; background: #181c25; border: 1px solid var(--border-hi); border-radius: 10px; padding: .4rem; display: none; flex-direction: column; gap: .15rem; box-shadow: 0 12px 32px rgba(0,0,0,.6); z-index: 999; }
.nav-dropdown.open .nav-dropdown-menu { display: flex; animation: dropIn .15s ease both; }
.nav-dropdown-menu a { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: 7px; font-size: .75rem; color: #94a3b8; text-decoration: none; transition: background .12s, color .12s; white-space: nowrap; letter-spacing: .02em; }
.nav-dropdown-menu a:hover { background: rgba(0,229,160,.07); color: var(--accent); }
.nav-dropdown-menu a.active { background: rgba(0,229,160,.1); color: var(--accent); }
.nav-dropdown-menu a svg { opacity: .55; flex-shrink: 0; }
.nav-dropdown-menu a:hover svg, .nav-dropdown-menu a.active svg { opacity: 1; }
@keyframes dropIn { from { opacity: 0; transform: translateX(-50%) translateY(-6px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.nav-cv { font-family: var(--mono); font-size: .72rem; font-weight: 700; padding: .35rem .85rem; border-radius: 6px; background: var(--accent); color: #0d0f14; text-decoration: none; letter-spacing: .05em; transition: background .14s; white-space: nowrap; margin-left: auto; }
.nav-cv:hover { background: #00ffb3; }
@media (max-width: 640px) { .nav-links a:not(.nav-dropdown-toggle) { display: none; } }
