/* ---------- tokens ---------- */
:root {
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f3f1ec;
  --bg-2: #ebe7df;
  --card: #ffffff;
  --card-2: #f7f5f0;
  --line: #e2ddd3;
  --line-2: #cfc8bb;
  --text: #1b1a17;
  --text-2: #5f5a51;
  --text-3: #948d80;
  --accent: #e8542e;
  --accent-2: #ff7a55;
  --accent-ink: #ffffff;
  --accent-soft: #fdeae3;
  --danger: #c93a2e;
  --stage: #17161a;
  --shadow: 0 1px 2px rgba(30,25,15,.05), 0 12px 32px -18px rgba(30,25,15,.25);
  --radius: 18px;
  --radius-s: 11px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121114; --bg-2: #19181c; --card: #1d1c21; --card-2: #232228;
    --line: #2c2b32; --line-2: #3b3a42; --text: #f1eee8; --text-2: #aaa59b; --text-3: #6f6b63;
    --accent: #ff6a45; --accent-2: #ff8a6a; --accent-ink: #1a0e09; --accent-soft: #33221c;
    --danger: #ff6b5f; --stage: #0a0a0c;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -18px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121114; --bg-2: #19181c; --card: #1d1c21; --card-2: #232228;
  --line: #2c2b32; --line-2: #3b3a42; --text: #f1eee8; --text-2: #aaa59b; --text-3: #6f6b63;
  --accent: #ff6a45; --accent-2: #ff8a6a; --accent-ink: #1a0e09; --accent-soft: #33221c;
  --danger: #ff6b5f; --stage: #0a0a0c;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -18px rgba(0,0,0,.7);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45;
  color: var(--text); background: var(--bg);
  background-image: radial-gradient(1200px 500px at 80% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%);
  min-height: 100dvh; padding: 0 16px max(24px, env(safe-area-inset-bottom));
}
h2 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
button, input, output { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--text-2); }
.hint { color: var(--text-3); font-size: 12.5px; display: block; }
.hint.center { text-align: center; }
.hint.error { color: var(--danger); }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 10.5px; color: var(--text-3); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- header ---------- */
.top { max-width: 1400px; margin: 0 auto; padding: 18px 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark { width: 34px; height: 34px; stroke: none; fill: var(--accent); }
.brand-mark rect:nth-child(2) { opacity: .7; } .brand-mark rect:nth-child(3) { opacity: .55; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand-text small { color: var(--text-2); font-size: 12px; }
.top-controls { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; padding: 3px; background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.seg button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.icon-btn { width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--card-2); display: inline-grid; place-items: center; }
.icon-btn:hover { border-color: var(--line-2); }
.icon-btn .moon { display: none; }
:root[data-theme="dark"] .icon-btn .sun { display: none; }
:root[data-theme="dark"] .icon-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .sun { display: none; }
  :root:not([data-theme="light"]) .icon-btn .moon { display: block; }
}

/* ---------- layout ---------- */
.layout { max-width: 1400px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

/* ---------- stage ---------- */
.stage-card { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.tabs button.selected { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.dim { font-size: 11.5px; letter-spacing: .08em; color: var(--text-3); text-transform: uppercase; }
.stage { position: relative; border-radius: 12px; background: var(--stage); min-height: 420px; height: auto; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); }
.stage.dragover { outline: 2px dashed var(--accent); outline-offset: -6px; }
.stage.loaded { min-height: 320px; max-height: 78vh; }
.stage img { max-width: 100%; max-height: 78vh; display: block; object-fit: contain; }
.empty { text-align: center; padding: 32px 20px; color: #d9d6cf; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty h2 { color: #f4f2ed; font-size: 22px; }
.empty p { margin: 0; max-width: 360px; color: #a9a59c; }
.empty .btn { margin-top: 8px; }
.empty .formats { color: #6f6b63; font-size: 11.5px; letter-spacing: .04em; margin-top: 4px; }
.empty-art { display: grid; grid-template-columns: repeat(2, 30px); gap: 6px; transform: rotate(-6deg); margin-bottom: 12px; }
.empty-art span { width: 30px; height: 30px; border-radius: 6px; background: var(--accent); }
.empty-art span:nth-child(2) { transform: translate(6px, -4px) rotate(8deg); opacity: .8; }
.empty-art span:nth-child(3) { transform: translate(-4px, 5px); opacity: .6; }
.empty-art span:nth-child(4) { transform: translate(8px, 6px) rotate(-6deg); opacity: .9; }
.busy { position: absolute; inset: 0; background: rgba(10,10,12,.55); backdrop-filter: blur(3px); display: grid; place-content: center; gap: 12px; color: #fff; text-align: center; justify-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--accent-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; min-height: 32px; flex-wrap: wrap; }
#fileName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.result-actions { display: flex; gap: 8px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 999px; border: 1px solid transparent; font-weight: 600; font-size: 14px; text-decoration: none; transition: transform .08s ease, background .15s ease; user-select: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.primary.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: var(--card-2); border-color: var(--line); color: var(--text); }
.btn.ghost:hover:not(:disabled) { border-color: var(--line-2); }
.btn.ghost.danger { color: var(--danger); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.big { width: 100%; padding: 14px 18px; font-size: 15px; }
.btn svg { width: 17px; height: 17px; }

/* ---------- panel ---------- */
.panel { padding: 18px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 14px; }
@media (max-width: 900px) { .panel { position: static; } }
.panel-head h2 { font-size: 19px; margin-top: 2px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .field .row label { font-size: 13.5px; font-weight: 500; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
output { font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 600; color: var(--text-2); background: var(--card-2); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; min-width: 40px; text-align: center; }
.scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: -3px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p, 0%), var(--line-2) var(--p, 0%)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--card); border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--card); border: 2px solid var(--accent); }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.presets button { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 10px 6px 9px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--card-2); font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.presets button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.pv { width: 34px; height: 24px; display: block; border-radius: 4px; background: var(--stage); position: relative; overflow: hidden; }
.pv::before, .pv::after { content: ""; position: absolute; background: var(--accent); border-radius: 2px; }
.pv-calm::before { inset: 3px 50% 3px 3px; } .pv-calm::after { inset: 3px 3px 3px 51%; }
.pv-mosaic::before { left: 3px; top: 3px; width: 16px; height: 8px; } .pv-mosaic::after { left: 12px; top: 12px; width: 18px; height: 9px; }
.pv-wild::before { left: 2px; top: 4px; width: 12px; height: 10px; transform: rotate(-8deg); } .pv-wild::after { left: 17px; top: 8px; width: 14px; height: 12px; transform: rotate(6deg); }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--card-2); font-size: 16px; line-height: 1; display: grid; place-items: center; }
.stepper output { min-width: 34px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatches button, .swatches .custom { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--c); padding: 0; position: relative; }
.swatches button.active, .swatches .custom.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
.swatches .custom { background: conic-gradient(#f44, #fa0, #4c4, #4cf, #a4f, #f44); cursor: pointer; overflow: hidden; }
.swatches .custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.toggle { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; padding: 12px 0 0; border-top: 1px solid var(--line); }
.toggle > span { display: flex; flex-direction: column; gap: 2px; }
.toggle b { font-weight: 500; font-size: 13.5px; }
.toggle small { color: var(--text-3); font-size: 12px; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle i { flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(18px); }
.panel-foot { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

/* ---------- history ---------- */
.history { max-width: 1400px; margin: 26px auto 0; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.history-head h2 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--text-2); font-weight: 600; }
.history-tools { display: flex; gap: 8px; align-items: center; }
.history-tools input { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-size: 13px; min-width: 220px; outline: none; }
.history-tools input:focus { border-color: var(--accent); }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.hcard { position: relative; border-radius: 14px; overflow: hidden; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; text-align: left; padding: 0; }
.hcard.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.hcard .thumb { aspect-ratio: 4/3; background: var(--stage); display: grid; place-items: center; overflow: hidden; cursor: pointer; border: 0; padding: 0; width: 100%; }
.hcard .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hcard .badge { position: absolute; top: 8px; left: 8px; font-size: 10.5px; font-weight: 600; letter-spacing: .04em; background: rgba(0,0,0,.55); color: #fff; padding: 3px 8px; border-radius: 999px; backdrop-filter: blur(4px); pointer-events: none; }
.hcard .meta { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.hcard .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hcard .sub { display: flex; justify-content: space-between; color: var(--text-3); font-size: 11.5px; }
.hcard .sub .soon { color: var(--accent); font-weight: 600; }
.hcard .tools { display: flex; gap: 4px; padding: 0 6px 8px; }
.hcard .tools button, .hcard .tools a { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--card-2); font-size: 12px; text-decoration: none; color: var(--text-2); }
.hcard .tools button:hover, .hcard .tools a:hover { color: var(--text); border-color: var(--line-2); }
.hcard .tools .del:hover { color: var(--danger); }
.hcard .tools svg { width: 14px; height: 14px; }
.history-empty { border: 1px dashed var(--line-2); border-radius: 14px; padding: 26px; text-align: center; color: var(--text-2); font-size: 14px; }
.history-empty p { margin: 0; }

/* ---------- footer, modal, toast ---------- */
.foot { max-width: 1400px; margin: 28px auto 0; display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-card { width: min(420px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.modal-card p { margin: 0; font-size: 14px; }
.modal-card input { border: 1px solid var(--line-2); background: var(--card-2); border-radius: var(--radius-s); padding: 11px 14px; font-size: 16px; letter-spacing: .1em; outline: none; }
.modal-card input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 60; max-width: calc(100% - 32px); text-align: center; }
.toast.error { background: var(--danger); color: #fff; }
[hidden] { display: none !important; }

@media (max-width: 600px) {
  body { padding: 0 12px 24px; }
  .brand-text small { display: none; }
  .stage { min-height: 0; }
  .history-tools { width: 100%; } .history-tools input { flex: 1; min-width: 0; }
  .history-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- v2: account, modals, payments ---------- */
.acct { display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card-2); max-width: 300px; }
.acct-email { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.acct-plan { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--line); color: var(--text-2); white-space: nowrap; }
.acct-plan.pro { background: var(--accent); color: var(--accent-ink); }
.acct-plan.team { background: #2f6b4f; color: #fff; }
.file-meta { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.file-meta .hint { font-size: 12px; }
#linkBtn.linked { border-color: var(--accent); color: var(--accent); }
.quota-line { margin: -4px 0 12px; font-size: 13px; color: var(--text-2); }
.modal-card { position: relative; }
.modal-card.center { align-items: center; text-align: center; }
.modal-x { position: absolute; top: 10px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; font-size: 22px; color: var(--text-3); line-height: 1; }
.modal-x:hover { background: var(--card-2); color: var(--text); }
.modal-card h2 { font-size: 20px; padding-right: 28px; }
.modal-card input[type=email], .modal-card input[type=text] { width: 100%; letter-spacing: 0; }
.modal-card input[type=text]#loginCode { letter-spacing: .3em; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }
.modal-card .btn { width: 100%; }
.modal-card .modal-actions .btn { width: auto; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; cursor: pointer; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card-2); }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check a { color: var(--accent); }
.plan-box { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: var(--radius-s); background: var(--card-2); border: 1px solid var(--line); font-size: 14px; }
.plan-box div { display: flex; justify-content: space-between; gap: 12px; }
.plan-box div:first-child b { color: var(--accent); }
.plan-list { margin: 0; padding: 0 0 0 18px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.currency-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.currency-row .btn { flex-direction: column; gap: 2px; padding: 10px 6px; width: 100%; }
.currency-row b { font-size: 18px; }
.currency-row small { font-size: 10.5px; font-weight: 500; color: var(--text-3); text-align: center; line-height: 1.2; }
.muted.small { font-size: 13px; }
.spinner.dark { border-color: var(--line-2); border-top-color: var(--accent); margin: 0 auto 4px; }
.hcard .badge.right { left: auto; right: 8px; padding: 4px 6px; display: grid; place-items: center; }
.hcard .badge.right svg { width: 12px; height: 12px; stroke: #fff; }
.hcard .tools .ln.linked { color: var(--accent); border-color: var(--accent); }
.foot-links a { color: inherit; }
@media (max-width: 600px) {
  .acct-email { display: none; } .acct { padding: 5px 6px; }
  .currency-row { grid-template-columns: 1fr; }
  .top-controls { gap: 6px; }
}
