/* ============================================================================
   SnapFrame Studio — app styles
   ========================================================================= */
:root {
  --bg: #0a0b10;
  --bg-2: #101118;
  --panel: #14161e;
  --panel-2: #191c26;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eceef4;
  --muted: #9aa0b0;
  --muted-2: #6f7585;
  --violet: #8b5cf6;
  --cyan: #22d3ee;
  --lime: #c6f24e;
  --radius: 16px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.8);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 80% -160px, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(900px 500px at 10% -100px, rgba(34, 211, 238, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; }

img, canvas, svg { max-width: 100%; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--violet);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 10px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(10, 11, 16, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(34, 211, 238, 0.8));
  color: #fff;
  flex: none;
}
.brand-name { font-size: 16px; }
.brand-tag {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 2px 5px;
  transform: translateY(-1px);
}
.topnav {
  display: flex;
  gap: 18px;
  margin-left: 10px;
  font-size: 14px;
  color: var(--muted);
}
.topnav a { text-decoration: none; }
.topnav a:hover { color: var(--text); }
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.lang {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}
.lang-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  padding: 5px 10px;
  cursor: pointer;
}
.lang-btn.on { background: rgba(255, 255, 255, 0.10); color: var(--text); }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-mini {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--violet), #6366f1);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(139, 92, 246, 0.9);
  flex: 1;
}
.btn-primary:hover { background: linear-gradient(135deg, #9d74ff, #7376ff); }
.btn-pro {
  background: linear-gradient(135deg, rgba(198, 242, 78, 0.16), rgba(34, 211, 238, 0.16));
  border-color: rgba(198, 242, 78, 0.45);
  color: #e9ffc0;
  font-size: 13px;
  padding: 7px 13px;
}
.btn-pro:hover { background: rgba(198, 242, 78, 0.22); }
.btn-pro-full {
  width: 100%;
  margin-top: 10px;
  background: linear-gradient(135deg, rgba(198, 242, 78, 0.9), rgba(34, 211, 238, 0.85));
  color: #0b0f08;
  border: 0;
  font-weight: 700;
}
.btn.busy { opacity: 0.7; }

/* ---------- hero ---------- */
.hero {
  max-width: 1500px;
  margin: 0 auto;
  padding: 34px 20px 12px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(198, 242, 78, 0.16);
  flex: none;
}
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 3.6vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.035em;
  font-weight: 700;
  max-width: 22ch;
}
.hero-sub {
  margin: 0;
  max-width: 68ch;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- ads ---------- */
.ad-wrap {
  max-width: 1500px;
  margin: 18px auto 0;
  padding: 0 20px;
  min-height: 0;
}
.ad-wrap .adsbygoogle { display: block; }

/* ---------- studio ---------- */
.studio {
  max-width: 1500px;
  margin: 18px auto 30px;
  padding: 0 20px;
  display: grid;
  gap: 18px;
  grid-template-columns: 388px minmax(0, 1fr);
  grid-template-areas: "panel stage";
  align-items: start;
}

.stage-wrap {
  grid-area: stage;
  min-width: 0;
  position: sticky;
  top: 74px;
}
.stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    conic-gradient(from 210deg at 50% 0%, rgba(139, 92, 246, 0.10), rgba(34, 211, 238, 0.06), transparent 70%),
    #0c0d13;
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: grab;
  overflow: hidden;
}
.stage.dragging { cursor: grabbing; }
#canvas {
  display: block;
  max-width: 100%;
  max-height: min(66vh, 720px);
  width: auto;
  height: auto;
  border-radius: 10px;
  background:
    linear-gradient(45deg, #15161c 25%, transparent 25%, transparent 75%, #15161c 75%) 0 0 / 16px 16px,
    linear-gradient(45deg, #15161c 25%, #101116 25%, #101116 75%, #15161c 75%) 8px 8px / 16px 16px;
  pointer-events: none;
}
.stage-badge {
  position: absolute;
  top: 12px;
  left: 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(8, 10, 16, 0.6);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 999px;
  pointer-events: none;
}
.stage-badge.warn {
  color: #10130a;
  background: rgba(198, 242, 78, 0.9);
  border-color: transparent;
}
.stage-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: space-between;
  padding: 10px 4px 0;
  font-size: 12px;
  color: var(--muted-2);
}
.output-size { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- panel ---------- */
.panel {
  grid-area: panel;
  min-width: 0;
  background: linear-gradient(180deg, var(--panel), #101219);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 16px 16px;
  position: sticky;
  top: 74px;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}
.panel-sec {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.panel-sec:last-of-type { border-bottom: 0; }
.sec-title {
  margin: 0 0 10px;
  font-size: 11.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 700;
}
.sec-label {
  margin: 12px 0 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

/* drop zone */
.drop {
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.drop:hover, .drop:focus-visible {
  border-color: rgba(139, 92, 246, 0.7);
  background: rgba(139, 92, 246, 0.08);
  outline: none;
}
.drop svg { color: var(--violet); }
.drop-title { margin: 6px 0 2px; font-size: 14px; font-weight: 600; color: var(--text); }
.drop-hint { margin: 0; font-size: 11.5px; color: var(--muted-2); }
.drop.has-image { padding: 10px; border-style: solid; border-color: rgba(198, 242, 78, 0.4); }
.drop.has-image .drop-title { font-size: 12.5px; }
.drop.has-image svg { display: none; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.row-wrap { flex-wrap: wrap; }
.row-actions { margin-top: 12px; }
.meta-row { justify-content: space-between; }
.file-name {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.samples { display: flex; gap: 6px; flex-wrap: wrap; }
.sample-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.sample-chip:hover { color: var(--text); border-color: var(--line-strong); }

/* segments */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  margin-top: 8px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 4px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button.on { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.seg-sm button { font-size: 12px; padding: 4px 4px; }
.seg button:hover { color: var(--text); }

/* presets */
.presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.preset {
  position: relative;
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 7px 7px 6px;
  cursor: pointer;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
  overflow: hidden;
}
.preset:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.06); }
.preset.on {
  border-color: rgba(139, 92, 246, 0.9);
  background: rgba(139, 92, 246, 0.14);
  color: var(--text);
}
.preset-thumb {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  margin-bottom: 5px;
  background: #0c0d12;
}
.preset-name { display: block; font-weight: 600; }
.preset.locked .preset-thumb { opacity: 0.55; }
.preset-lock {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(198, 242, 78, 0.92);
  color: #10130a;
}

/* swatches */
.swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}
.swatch {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  height: 34px;
  cursor: pointer;
  padding: 0;
  position: relative;
}
.swatch.on {
  outline: 2px solid var(--violet);
  outline-offset: 1px;
}
.swatch-none {
  background:
    linear-gradient(45deg, #1b1d25 25%, transparent 25%, transparent 75%, #1b1d25 75%) 0 0 / 8px 8px,
    linear-gradient(45deg, #1b1d25 25%, #0c0d12 25%, #0c0d12 75%, #1b1d25 75%) 4px 4px / 8px 8px;
}
.custom-colors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.custom-colors .color-angle { grid-column: 1 / -1; }
.color-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
}
.color-field em { color: var(--text); font-style: normal; font-variant-numeric: tabular-nums; }
input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  padding: 2px;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 6px; }

/* sliders */
.slider { display: block; margin-top: 10px; }
.slider-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slider-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.slider-top em { color: var(--text); font-style: normal; font-variant-numeric: tabular-nums; }
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.14);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--violet);
  margin-top: -5.5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.14);
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--violet);
}

/* fields */
.field { display: block; margin-top: 10px; font-size: 12px; color: var(--muted); }
.field > span { display: block; margin-bottom: 4px; }
input[type="text"] {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
}
input[type="text"]:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.8);
}
.local-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--muted-2);
}
.lock-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 3px rgba(198, 242, 78, 0.14);
  flex: none;
}

/* pro card */
.pro-card {
  margin-top: 14px;
  border: 1px solid rgba(198, 242, 78, 0.28);
  background: linear-gradient(160deg, rgba(198, 242, 78, 0.10), rgba(34, 211, 238, 0.07));
  border-radius: 14px;
  padding: 14px;
}
.pro-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.pro-card h2 { margin: 0; font-size: 15px; letter-spacing: -0.01em; }
.pro-price { font-size: 13px; color: var(--lime); font-weight: 700; }
.pro-card p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- howto ---------- */
.howto {
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  margin-top: 40px;
}
.howto-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 36px 20px 28px;
}
.howto h2 { margin: 0 0 18px; font-size: 22px; letter-spacing: -0.02em; }
.howto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.howto-grid article {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
}
.howto-grid .step {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--violet);
}
.howto-grid h3 { margin: 6px 0 6px; font-size: 15px; }
.howto-grid p { margin: 0; font-size: 13px; color: var(--muted); }
.howto-links {
  margin: 20px 0 0;
  font-size: 13px;
  color: var(--muted-2);
}
.howto-links a { color: var(--muted); text-decoration-color: rgba(255, 255, 255, 0.25); }

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  background: #08090d;
  padding: 34px 0 22px;
}
.footer-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 1fr 1fr;
  gap: 24px;
}
.footer-brand p { margin: 6px 0 0; font-size: 13px; color: var(--muted); max-width: 34ch; }
.footer-brand .muted { color: var(--muted-2); font-size: 12px; }
.footer-nav h3 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.footer-nav a {
  display: block;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 3px 0;
}
.footer-nav a:hover { color: var(--text); }
.footer-copy {
  max-width: 1500px;
  margin: 22px auto 0;
  padding: 0 20px;
  font-size: 12px;
  color: var(--muted-2);
}

/* ---------- pro modal ---------- */
.pro-modal {
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, #16181f, #101218);
  color: var(--text);
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.9);
}
.pro-modal::backdrop { background: rgba(4, 5, 9, 0.72); backdrop-filter: blur(4px); }
.pro-modal-inner { padding: 22px; position: relative; }
.pro-modal h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -0.02em; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.modal-note {
  margin: 0 0 10px;
  font-size: 13px;
  color: #f0d9a0;
  background: rgba(240, 217, 160, 0.08);
  border: 1px solid rgba(240, 217, 160, 0.25);
  border-radius: 10px;
  padding: 8px 10px;
}
.pro-list { margin: 0 0 14px; padding-left: 18px; font-size: 13.5px; color: var(--muted); }
.pro-list li { margin: 4px 0; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 auto; }
.modal-fine { margin: 10px 0 0; font-size: 11.5px; color: var(--muted-2); }
.license-row { display: flex; gap: 6px; }
.license-row input { flex: 1; min-width: 0; }
.btn.disabled { opacity: 0.5; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: rgba(20, 22, 30, 0.96);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .studio { grid-template-columns: 340px minmax(0, 1fr); }
}

@media (max-width: 960px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 4px; }
  .topnav {
    order: 3;
    width: 100%;
    margin: 0;
    gap: 16px;
    font-size: 13px;
    padding-bottom: 2px;
    border-top: 1px solid var(--line);
    padding-top: 6px;
  }
  .studio {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "stage" "panel";
  }
  .stage-wrap, .panel { position: static; max-height: none; }
  .stage { min-height: 0; }
  #canvas { max-height: 46vh; }
  .panel { max-height: none; overflow: visible; }
  .hero { padding-top: 24px; }
  .presets { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 620px) {
  body { font-size: 14.5px; }
  .topbar-inner { padding: 8px 14px; gap: 10px; }
  .brand-tag { display: none; }
  .hero, .ad-wrap, .studio, .howto-inner, .footer-inner { padding-left: 14px; padding-right: 14px; }
  .presets { grid-template-columns: 1fr 1fr; }
  .swatches { grid-template-columns: repeat(5, 1fr); }
  .footer-inner { grid-template-columns: 1fr; gap: 18px; }
  .stage { padding: 10px; border-radius: 16px; }
  #canvas { max-height: 40vh; }
  .lang-btn { padding: 5px 8px; font-size: 12px; }
  .topbar-actions .btn-pro { padding: 6px 10px; font-size: 12px; }
  .stage-foot { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
