:root {
  --bg: #14161A;
  --bg-raised: #1C1F25;
  --paper: #F6F3EC;
  --paper-dim: #E7E2D6;
  --ink: #EDEBE4;
  --ink-dim: #9A9CA3;
  --muted: #8B8D93;
  --accent: #FF6B35;
  --accent-dim: #C9502A;
  --teal: #4A7C7C;
  --line: #2A2E35;
  --radius: 10px;
  --font-display: 'Vazirmatn', sans-serif;
  --font-body: 'Vazirmatn', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px;
}

.mono { font-family: var(--font-mono); }

/* subtle film-grain overlay */
.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* header */
.site-header {
  border-bottom: 1px solid var(--line);
  padding: 20px 0;
}
.header-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  display: block;
  border-radius: 7px;
}
.brand-mark {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--paper);
}
.brand-tag {
  font-size: 0.78rem;
  color: var(--muted);
  margin-right: 12px;
}
.header-nav a {
  color: var(--muted);
  text-decoration: none;
  margin-right: 24px;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.header-nav a:hover { color: var(--accent); }
.lang-toggle {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  margin-right: 8px;
}
.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* hero */
.hero {
  padding: 72px 24px 32px;
}
.eyebrow {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  margin: 0 0 14px;
}
h1 {
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  line-height: 1.2;
  margin: 0 0 20px;
  font-weight: 700;
  color: var(--paper);
}
h1 .accent { color: var(--accent); }
.lede {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.75;
  max-width: 640px;
  margin: 0;
}

/* lab / dropzone */
.lab { padding: 24px 24px 80px; }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag-over {
  border-color: var(--accent);
  background: #21252c;
  outline: none;
}
.dropzone-icon {
  color: var(--muted);
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.dropzone.drag-over .dropzone-icon { color: var(--accent); }
.dropzone-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--paper);
  margin: 0 0 6px;
}
.dropzone-sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
}

/* controls */
.controls-panel {
  display: flex;
  align-items: end;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding: 20px 24px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}
.control-group label {
  font-size: 0.85rem;
  color: var(--muted);
}
select, input[type="range"] {
  accent-color: var(--accent);
}
select {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 0.92rem;
}
.meta-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.82rem;
  color: var(--teal);
  white-space: nowrap;
}
.heic-notice {
  margin-top: 12px;
  color: var(--teal);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  text-align: center;
}
.error-notice {
  margin-top: 12px;
  color: #d94f4f;
  background: rgba(217, 79, 79, 0.08);
  border: 1px solid rgba(217, 79, 79, 0.3);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 6px;
  padding: 11px 22px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-right: auto;
}
.btn-primary:hover { background: #ff7f52; }
.btn-primary:active { transform: scale(0.98); }

/* results sheet - contact-sheet style grid */
.sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 28px;
}
.frame {
  background: var(--paper);
  border-radius: 6px;
  padding: 10px 10px 14px;
  position: relative;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.compare {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  overflow: hidden;
  background: var(--paper-dim);
  direction: ltr;
  touch-action: pan-y;
}
.compare-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
}
.compare-after {
  clip-path: inset(0 50% 0 0);
}
.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
  pointer-events: none;
}
.compare-divider::before,
.compare-divider::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 50%;
}
.compare-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  -webkit-appearance: none;
  appearance: none;
}
.compare-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 100%;
  height: 100%;
}
.frame.processing .compare-after { opacity: 0; }
.frame-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  color: #2a2a2a;
}
.frame-meta .size-before {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #8a8a8a;
  text-decoration: line-through;
}
.frame-meta .size-after {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
}
.stamp {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #1a1a1a;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 3px;
  transform: rotate(-4deg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.frame-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.frame-download {
  flex: 1;
  display: block;
  text-align: center;
  font-size: 0.8rem;
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--teal);
  border-radius: 5px;
  padding: 6px 0;
  transition: background 0.2s, color 0.2s;
}
.frame-download:hover {
  background: var(--teal);
  color: var(--paper);
}
.frame-delete {
  flex: 0 0 auto;
  background: none;
  border: 1px solid #c0392b;
  color: #c0392b;
  border-radius: 5px;
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.frame-delete:hover {
  background: #c0392b;
  color: var(--paper);
}
.frame.processing .stamp { background: var(--muted); }
.frame.processing .compare-before { opacity: 0.5; }

/* how it works */
.about {
  padding: 20px 24px 20px;
  border-top: 1px solid var(--line);
}
.about h2 {
  font-size: 1.4rem;
  color: var(--paper);
  margin-bottom: 18px;
}
.about p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.85;
  max-width: 720px;
  margin: 0 0 16px;
}

.how { padding: 40px 24px 60px; border-top: 1px solid var(--line); }
.how h2, .faq h2 {
  font-size: 1.6rem;
  color: var(--paper);
  margin-bottom: 32px;
}
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}
.step-num {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
}
.step h3 {
  color: var(--paper);
  font-size: 1.05rem;
  margin: 10px 0 8px;
}
.step p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
  margin: 0;
}

/* faq */
.faq { padding: 20px 24px 80px; border-top: 1px solid var(--line); }
.faq details {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--paper);
  font-size: 1rem;
}
.faq p {
  color: var(--muted);
  margin: 12px 0 0;
  line-height: 1.7;
  font-size: 0.92rem;
}

/* footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px 0;
}
.footer-inner {
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 600px) {
  .hero { padding: 48px 20px 24px; }
  .lab { padding: 20px 20px 60px; }
  .dropzone { padding: 40px 16px; }
  .header-nav a { margin-right: 14px; font-size: 0.85rem; }
  .lang-toggle { padding: 5px 10px; }
}

/* LTR (English) tweaks */
html[dir="ltr"] .brand-tag { margin-right: 0; margin-left: 12px; }
html[dir="ltr"] .header-nav a { margin-right: 0; margin-left: 24px; }
html[dir="ltr"] .lang-toggle { margin-right: 0; margin-left: 8px; }
html[dir="ltr"] .btn-primary { margin-right: 0; margin-left: auto; }
