* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #ededed;
  --panel: #ffffff;
  --muted: #6b6b6b;
  --text: #0e0e0e;
  --accent: #141414;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow: auto;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(0, 0, 0, 0.02) 0, rgba(0, 0, 0, 0.02) 1.4px, transparent 1.4px),
    radial-gradient(circle at 78% 12%, rgba(0, 0, 0, 0.018) 0, rgba(0, 0, 0, 0.018) 1.2px, transparent 1.2px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(236, 236, 236, 0.72));
  background-size: 180px 180px, 200px 200px, 100% 100%;
  background-repeat: repeat;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  background-size: 260px 260px;
  mix-blend-mode: multiply;
  opacity: 0.35;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 100vh;
  background: var(--panel);
  padding: 96px 16px 16px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  gap: 18px;
  box-sizing: border-box;
}

.hero {
  position: fixed;
  top: 12px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 8px;
  background: var(--panel);
  z-index: 12;
}

h1 {
  margin: 0;
  letter-spacing: -0.02em;
  font-size: 18px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.upload {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.file-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, background 0.15s ease;
}

.file-button:hover {
  transform: translateY(-1px);
  background: #000;
  color: #fff;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-name,
.error {
  font-size: 13px;
}

.file-name {
  color: var(--muted);
}

.error {
  color: #c64b4b;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 360px) 1fr;
  gap: 16px;
  align-items: start;
  min-height: calc(100vh - 80px);
}

.preview-wrap {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(560px, calc(100vw - 360px));
  max-width: 640px;
  height: 70vh;
  max-height: 80vh;
  min-height: 420px;
  padding: 10px;
  box-sizing: border-box;
  z-index: 6;
  pointer-events: none;
}

.controls {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: start;
  position: sticky;
  top: 108px;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0 2px;
}

.control-section + .control-section {
  margin-top: 8px;
}

.section-title {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.control-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pill-grid {
  display: grid;
  gap: 10px;
}

.inline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.foldout {
  background: #f7f7f7;
  border: none;
  border-radius: 14px;
  box-shadow: none;
  overflow: hidden;
}

.foldout-head {
  width: 100%;
  padding: 12px 14px;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  transition: background 0.15s ease, color 0.15s ease;
}

.foldout-head:hover {
  background: rgba(0, 0, 0, 0.03);
}

.foldout-head:focus-visible {
  outline: 2px solid #0b0b0b;
  outline-offset: 2px;
}

.foldout-title {
  flex: 1;
  text-align: left;
}

.chevron {
  font-weight: 700;
  color: var(--muted);
}

.foldout-body {
  padding: 6px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.controls-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.control {
  display: block;
  background: #f6f6f6;
  border: none;
  border-radius: 12px;
  padding: 8px 10px 10px;
}

.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 14px;
}

.control .value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--text);
  margin-top: 4px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 2px;
}

.timeline input[type='range'] {
  margin-top: 0;
  accent-color: var(--accent);
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: none;
  border-radius: 0;
  padding: 8px 0;
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.pill-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  border: none;
  background: #e9e9e9;
  color: var(--text);
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.pill:hover {
  transform: translateY(-1px);
}

.pill.active {
  background: var(--accent);
  color: #fff;
}

.pill:disabled,
.toggle button:disabled,
.color-input:disabled,
.text-input:disabled,
select:disabled,
input[type='range']:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.dropdown {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: #f5f5f5;
  font-size: 14px;
  color: var(--text);
}

.import-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #e9e9e9;
  color: var(--text);
  padding: 7px 11px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

.status-line {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

.subsection {
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  padding: 6px 0 10px;
  margin-bottom: 6px;
  min-height: 36px;
}

.subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.subsection-title {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.subsection-toggle {
  font-weight: 700;
  color: var(--muted);
  padding-left: 8px;
}

.subsection-body {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.subsection:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.pill.block {
  width: 100%;
  justify-content: center;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.support-links {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  z-index: 20;
}

.support-links a {
  text-decoration: none;
}

.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  background: rgba(245, 245, 245, 0.96);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.secondary:hover {
  transform: translateY(-1px);
  background: #f6f6f6;
}

.secondary:focus-visible {
  outline: 2px solid #0b0b0b;
  outline-offset: 2px;
}

.secondary:active {
  transform: translateY(0);
}

.primary {
  padding: 12px 16px;
  border-radius: 14px;
  border: none;
  background: #0b0b0b;
  color: #f8f8f6;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.primary:not(:disabled):hover {
  transform: translateY(-1px);
  filter: none;
}

.color-input {
  background: #fff;
  border: none;
  border-radius: 12px;
  width: 52px;
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

.text-input {
  background: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  min-width: 140px;
  font-size: 14px;
}

.preview {
  background: transparent;
  border: none;
  border-radius: 16px;
  padding: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  margin: 0;
  pointer-events: none;
}

.layout-spacer {
  display: none;
}

.export-fab {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
}

.mobile-export {
  display: none;
}

.mobile-bar {
  display: none;
}

.mobile-toolbar {
  display: none;
}

.export-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 96px 16px 24px;
  z-index: 14;
}

.export-modal {
  width: min(360px, 100%);
  background: var(--panel);
  border-radius: 16px;
  padding: 14px 14px 16px;
  box-sizing: border-box;
}

.export-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.export-options .pill-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 10px;
}

.export-options .block {
  width: 100%;
  justify-content: center;
  min-height: 44px;
}

.export-modal .ghost {
  background: transparent;
  color: var(--text);
  padding: 6px 10px;
}

.preview canvas {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 0;
  background: transparent;
  border: none;
}

@media (max-width: 960px) {
  .primary {
    width: 100%;
    text-align: center;
  }

  .toggle {
    align-items: flex-start;
  }

  .color-input {
    width: 56px;
  }

  .text-input {
    width: 100%;
  }

  .support-links {
    right: 12px;
    bottom: 12px;
  }

  .page {
    padding: 60px 12px 180px;
    display: flex;
    flex-direction: column;
  }

  .hero {
    display: none;
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 4px 4px;
    position: fixed;
    top: 10px;
    left: 12px;
    right: 12px;
    z-index: 20;
  }

  .mobile-bar .title {
    font-size: 18px;
    font-weight: 700;
  }

  .mobile-upload {
    padding: 8px 12px;
  }

  .layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .preview-wrap {
    position: static;
    transform: none;
    max-width: none;
    width: 100%;
    height: auto;
    min-height: 70vh;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    margin-top: 8px;
    order: 1;
  }

  .preview {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    min-height: 70vh;
    height: 70vh;
    max-height: 80vh;
    pointer-events: auto;
  }

  .export-fab {
    display: none;
  }

  .support-links {
    display: none;
  }

  .controls {
    display: none;
  }

  .mobile-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    margin: 0 auto;
    background: rgba(247, 247, 247, 0.98);
    backdrop-filter: blur(12px);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.12);
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 8px));
    z-index: 22;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }

  .mobile-tabs .pill {
    text-transform: capitalize;
    justify-content: center;
  }

  .mobile-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 34vh;
    overflow: auto;
    padding-top: 4px;
  }

  .mobile-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
  }
}
}

.status {
  margin: 0;
}

.export-progress {
  position: relative;
  height: 8px;
  background: #e2e2e2;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.export-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0b0b0b, #2d2d2d);
  border-radius: 999px;
  transition: width 0.15s ease;
}

.export-progress-label {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
