/* Strand — plain CSS. Tokens, then base, then screens. No framework. */

:root {
  color-scheme: light dark;

  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --surface-2: #F2F1EC;
  --line: #E3E1DA;
  --line-strong: #C9C6BC;
  --text: #1A1A19;
  --text-2: #5C5B56;
  --muted: #6F6D66;
  --disabled: #A9A79E;
  --accent: #E5531B;
  --accent-text: #B93E0E;
  --accent-soft: #FDE8DE;
  --ink: #1A1A19;
  --on-ink: #FFFFFF;
  --danger: #C62828;
  --danger-soft: #FDE2E2;
  --success: #2E7D4F;
  --checker-a: #FFFFFF;
  --checker-b: #E6E4DD;
  --overlay: rgba(26, 26, 25, .55);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .10);

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --r-1: 4px;
  --r-2: 8px;
  --r-3: 12px;
  --r-full: 999px;

  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F0F0E;
    --surface: #171716;
    --surface-2: #1F1F1D;
    --line: #2C2C29;
    --line-strong: #3E3E3A;
    --text: #F2F1EC;
    --text-2: #B3B1A8;
    --muted: #8B897F;
    --disabled: #55534D;
    --accent: #FF6A33;
    --accent-text: #FF7F52;
    --accent-soft: #3A1F14;
    --ink: #F2F1EC;
    --on-ink: #0F0F0E;
    --danger: #FF6B6B;
    --danger-soft: #3A1818;
    --success: #6CCB8E;
    --checker-a: #1C1C1A;
    --checker-b: #2A2A28;
    --overlay: rgba(0, 0, 0, .65);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 40px; line-height: 44px; letter-spacing: -0.02em; }
h2 { font-size: 28px; line-height: 34px; }
h3 { font-size: 22px; line-height: 28px; }
p { margin: 0; }
a { color: inherit; }

@media (min-width: 1024px) {
  h1 { font-size: 56px; line-height: 60px; }
  h2 { font-size: 36px; line-height: 42px; }
}

.lead { font-size: 18px; line-height: 28px; color: var(--text-2); }
.caption { font-size: 13px; line-height: 18px; color: var(--muted); }
.micro {
  font-size: 12px; line-height: 16px; font-weight: 500;
  letter-spacing: .02em; text-transform: uppercase; color: var(--muted);
}
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: inherit;
}

/* ---------- buttons ---------- */

button, .btn {
  font: 500 14px/1 var(--font-ui);
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r-2);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), opacity var(--dur-1);
}
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--ink);
  color: var(--on-ink);
  border-color: var(--ink);
}
.btn-primary:hover:not(:disabled) { opacity: .9; }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-wide { width: 100%; }

.icon-btn {
  width: 44px; height: 44px; min-height: 44px; padding: 0;
  border-color: transparent; background: transparent;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }

svg { stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; fill: none; }

/* ---------- header ---------- */

.header {
  position: sticky; top: 0; z-index: 50;
  height: 56px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  background: var(--bg);
  transition: box-shadow var(--dur-1);
}
.header.scrolled { box-shadow: var(--shadow-1); }
body.in-editor .header { display: none; }
body.in-editor .footer { display: none; }
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 17px; letter-spacing: -0.01em;
  text-decoration: none; margin-right: auto;
}
.mark { width: 24px; height: 24px; border-radius: 6px; background: var(--ink); display: block; }
.mark use { stroke: var(--accent); }

@media (min-width: 834px) { .header { padding: 0 32px; } }
@media (min-width: 1280px) { .header { padding: 0 40px; } }

/* ---------- layout ---------- */

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 834px) { .wrap { padding: 0 32px; } }
@media (min-width: 1280px) { .wrap { padding: 0 40px; } }

.section { padding-block: 64px; }
@media (min-width: 1024px) { .section { padding-block: 96px; } }

[hidden] { display: none !important; }

/* ---------- checkerboard ---------- */

.checker {
  background:
    conic-gradient(var(--checker-b) 25%, var(--checker-a) 0 50%, var(--checker-b) 0 75%, var(--checker-a) 0)
    0 0 / 24px 24px;
}

/* ---------- landing ---------- */

.hero { display: grid; gap: 32px; align-items: start; }
@media (min-width: 1024px) {
  .hero { grid-template-columns: 520px minmax(0, 1fr); gap: 40px; }
}
.hero-copy { display: grid; gap: 20px; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
  min-height: 220px;
  padding: 32px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-3);
  background: var(--surface);
  text-align: center;
  transition: border-color var(--dur-1), background var(--dur-1);
}
@media (min-width: 1024px) { .drop { min-height: 360px; } }
.drop.over { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.drop.invalid { border-style: solid; border-color: var(--danger); background: var(--danger-soft); }
.drop-actions { display: grid; gap: 10px; width: 100%; max-width: 320px; }

.samples { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.sample {
  width: 56px; height: 56px; min-height: 56px; padding: 0;
  border-radius: var(--r-2); overflow: hidden; border: 1px solid var(--line);
}
.sample img { width: 100%; height: 100%; object-fit: cover; display: block; }

#ts-host:not(:empty) { display: grid; justify-items: center; margin-top: 4px; }

.specs { margin-top: 12px; text-align: center; }
@media (min-width: 1024px) { .specs { text-align: left; } }

.cards { display: grid; gap: 16px; margin-top: 32px; }
@media (min-width: 834px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card {
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  overflow: hidden;
}
.card-body { padding: 14px 16px; }

.compare-box { position: relative; aspect-ratio: 1; }
.compare-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare-box .after { opacity: 0; transition: opacity var(--dur-2) var(--ease); }
.compare-box.show-after .after { opacity: 1; }
.compare-pill {
  position: absolute; left: 8px; bottom: 8px;
  min-height: 36px; padding: 0 12px; font-size: 12px;
  border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--line);
}

/* ---------- editor ---------- */

.editor { display: flex; flex-direction: column; min-height: 100dvh; }
.editor-bar {
  height: 52px; display: flex; align-items: center; gap: 8px;
  padding: 0 8px 0 4px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.editor-file { font-family: var(--font-mono); font-size: 13px; color: var(--muted); margin-right: auto; }

.stage {
  flex: 1; position: relative; display: grid; place-items: center;
  padding: 16px; overflow: hidden; min-height: 40dvh;
  background: var(--surface-2);
}
.canvas-frame { position: relative; width: fit-content; max-width: 100%; border-radius: var(--r-3); overflow: hidden; }
#canvas, #cursor { display: block; grid-area: 1/1; max-width: 100%; max-height: 52dvh; }
.canvas-frame { display: grid; touch-action: none; }
#cursor { pointer-events: none; }
@media (min-width: 1000px) { #canvas, #cursor { max-height: 64dvh; } }

.quota-pill {
  position: absolute; left: 20px; bottom: 20px;
  padding: 6px 12px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; color: var(--text-2); box-shadow: var(--shadow-1);
}

.toolbar {
  display: flex; align-items: center; justify-content: space-around; gap: 4px;
  padding: 8px 8px calc(8px + var(--safe-b));
  border-top: 1px solid var(--line); background: var(--bg);
}
.tool {
  flex-direction: column; gap: 4px;
  min-width: 52px; height: 56px; padding: 0 6px;
  border-color: transparent; background: transparent;
  font-size: 11px; color: var(--text-2);
}
.tool svg { width: 20px; height: 20px; }
.tool[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); }
.tool[aria-pressed="true"] svg { stroke: var(--accent); }

.editor-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
@media (min-width: 1000px) {
  .editor-body { flex-direction: row; }
  .stage { flex: 1; }
  .panel {
    width: 296px; flex: 0 0 296px; border-left: 1px solid var(--line);
    padding: 16px; overflow-y: auto; display: grid; gap: 20px; align-content: start;
    background: var(--bg);
  }
  .toolbar {
    flex-direction: column; justify-content: flex-start;
    width: 64px; flex: 0 0 64px; border-top: 0; border-right: 1px solid var(--line);
    padding: 8px 4px;
  }
}
.panel { display: grid; gap: 20px; padding: 16px; }
@media (max-width: 999px) {
  .panel { border-top: 1px solid var(--line); }
  /* Thumb reach: tools sit at the bottom on phones, below the image. */
  .editor-body { display: flex; flex-direction: column; }
  .stage { order: 1; }
  .toolbar { order: 2; position: sticky; bottom: 0; z-index: 20; border-top: 1px solid var(--line); }
  .panel { order: 3; }
}

.field { display: grid; gap: 8px; }
.field > .micro { margin-bottom: 2px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1 1 0; min-width: 64px; }
.seg button[aria-pressed="true"] {
  background: var(--surface-2); border-color: var(--line-strong); font-weight: 600;
}
.swatch-row { display: flex; gap: 8px; align-items: center; }
.sw { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: var(--r-2); }
.sw[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }

.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type="range"] { flex: 1; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 24px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: var(--r-1); background: var(--line-strong); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; margin-top: -10px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: var(--r-1); background: var(--line-strong); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface);
}

/* ---------- processing ---------- */

.processing { display: grid; place-items: center; gap: 20px; padding: 48px 16px; text-align: center; }
.proc-frame { position: relative; border-radius: var(--r-3); overflow: hidden; max-width: 100%; }
.proc-frame img { display: block; max-width: 100%; max-height: 52dvh; }
.proc-trace { position: absolute; inset: 0; width: 100%; height: 100%; }
.proc-trace rect {
  fill: none; stroke: var(--accent); stroke-width: 1.5;
  stroke-dasharray: 25% 75%; animation: trace 1.6s linear infinite;
}
@keyframes trace { to { stroke-dashoffset: -100%; } }

/* ---------- pricing ---------- */

.plans { display: grid; gap: 16px; margin-top: 32px; }
@media (min-width: 1024px) { .plans { grid-template-columns: repeat(3, 1fr); gap: 24px; align-items: stretch; } }
.plan {
  border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface);
  padding: 24px 20px; display: flex; flex-direction: column; gap: 16px;
}
.plan.featured { border-top: 2px solid var(--accent); }
.plan-price { font-family: var(--font-mono); font-size: 36px; line-height: 40px; font-weight: 500; }
.plan.featured .plan-price { font-size: 40px; }
.plan-price span { font-family: var(--font-ui); font-size: 16px; font-weight: 400; color: var(--text-2); }
.plan ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 14px; }
.plan li { display: flex; gap: 10px; align-items: flex-start; }
.plan li svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 3px; stroke: var(--accent); }
.plan .btn, .plan button { margin-top: auto; }

details { border-bottom: 1px solid var(--line); padding: 14px 0; }
summary { cursor: pointer; font-weight: 500; list-style: none; min-height: 28px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "▸ "; color: var(--muted); }
details[open] summary::before { content: "▾ "; }
details p { margin-top: 10px; color: var(--text-2); font-size: 14px; }

/* ---------- account menu ---------- */

.avatar {
  width: 44px; height: 44px; min-height: 44px; padding: 0;
  border-radius: var(--r-full); border-color: transparent; background: transparent;
}
.avatar img, .avatar .initials {
  width: 32px; height: 32px; border-radius: var(--r-full);
  display: grid; place-items: center; object-fit: cover;
  background: var(--surface-2); font-size: 13px; font-weight: 600;
}
.menu {
  position: absolute; top: 52px; right: 16px; z-index: 60;
  width: 296px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-2); box-shadow: var(--shadow-2);
  padding: 8px; display: grid; gap: 2px;
}
.menu-head { padding: 10px 10px 12px; display: grid; gap: 2px; }
.menu-plan { padding: 12px 10px; border-block: 1px solid var(--line); display: grid; gap: 8px; }
.bar { height: 4px; border-radius: var(--r-1); background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar.low i { background: var(--danger); }
.menu button { justify-content: flex-start; border-color: transparent; background: transparent; width: 100%; }
.menu button:hover { background: var(--surface-2); }

/* ---------- misc ---------- */

.notice {
  padding: 14px 16px; border-radius: var(--r-2);
  border: 1px solid var(--line); background: var(--surface-2);
  display: grid; gap: 12px; text-align: center;
}
.notice.error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); text-align: left; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  z-index: 90; max-width: calc(100vw - 32px);
  padding: 12px 16px; border-radius: var(--r-2);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  font-size: 14px; display: flex; gap: 12px; align-items: center;
}

.footer { border-top: 1px solid var(--line); padding: 24px 0 40px; margin-top: 32px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  .proc-trace rect { stroke-dasharray: none; }
}
