/* ===== Font ===== */
@font-face {
  font-family: "Halenoir";
  src: url("assets/fonts/Halenoir-DemiBold.otf") format("opentype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #000; --box: #000;
  --text-rgb: 255,255,255; --accent-rgb: 255,255,255; --glow-rgb: 255,255,255;
  --btn-text: #000; --light: 0;
  --text-op: .85; --ph-op: .32; --stroke-op: .16;
  --cw: 700px; --tscale: 1; --inset: .08;
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }
html, body { height: 100%; }
body {
  font-family: "Halenoir", -apple-system, system-ui, sans-serif;
  background: var(--bg); color: rgb(var(--text-rgb));
  overflow: hidden; transition: background .6s var(--ease), color .6s var(--ease);
}
button, input, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ===== Splash ===== */
#splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: var(--bg); transition: opacity .7s var(--ease), visibility .7s;
}
#splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { text-align: center; }
.splash-word { font-size: clamp(52px, 12vw, 104px); letter-spacing: -.03em; color: #fff;
  animation: rise .9s var(--ease) both; }
.splash-word .dot { color: #6b5cff; }
.splash-bar { width: 200px; height: 3px; margin: 26px auto 0; border-radius: 3px;
  background: rgba(255,255,255,.12); overflow: hidden; }
.splash-bar i { display: block; height: 100%; width: 0; border-radius: 3px;
  background: linear-gradient(90deg,#6b5cff,#c06cff); animation: load 1.3s var(--ease) forwards; }
.splash-sub { margin-top: 16px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,255,255,.4); animation: fade 1s .4s both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) } to { opacity: 1; transform: none } }
@keyframes load { from { width: 0 } to { width: 100% } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

/* ===== App ===== */
.app { position: relative; height: 100dvh; display: flex; flex-direction: column; align-items: center;
  padding: 0 24px 34px; opacity: 0; transition: opacity .6s var(--ease) .1s; }
.app.ready { opacity: 1; }
.bg-glow { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(120% 80% at 50% -10%, rgba(var(--glow-rgb),.16), transparent 60%); }

/* glass primitives */
.chip, .seg button, .cta-ghost, .filebtn {
  background: rgba(var(--text-rgb), .08);
  -webkit-backdrop-filter: blur(20px) saturate(1.5); backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid rgba(var(--text-rgb), .16); color: rgb(var(--text-rgb));
  border-radius: 999px; transition: transform .25s var(--ease), background .25s, border-color .25s; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; font-size: 13px; }
.chip:hover, .seg button:hover, .cta-ghost:hover { background: rgba(var(--text-rgb), .14); transform: translateY(-1px); }
.chip:active { transform: scale(.96); }
.chip .dot-on { width: 6px; height: 6px; border-radius: 50%; background: rgb(var(--accent-rgb)); }
.chip-icon { padding: 9px 11px; }

/* topbar */
.topbar { width: 100%; max-width: 1100px; display: flex; align-items: center; justify-content: space-between;
  padding: 20px 2px 0; z-index: 2; }
.brand { font-size: 26px; letter-spacing: -.03em; }
.brand .dot, .headline .dot { color: rgb(var(--accent-rgb)); }
.top-actions { display: flex; gap: 10px; }
.export-group { display: flex; gap: 4px; }

.headline { z-index: 1; text-align: center; font-size: clamp(30px, 5vw, 52px); letter-spacing: -.02em;
  margin: 18px 0 20px; opacity: .94; }

/* controls */
.controls { display: flex; gap: 12px; align-items: center; z-index: 2; margin-bottom: 16px; }
.seg { display: inline-flex; gap: 4px; padding: 3px; border-radius: 999px;
  background: rgba(var(--text-rgb), .05); border: 1px solid rgba(var(--text-rgb), .12); }
.seg button { border: none; background: transparent; border-radius: 999px; padding: 7px 12px; font-size: 13px;
  color: rgba(var(--text-rgb), .6); backdrop-filter: none; -webkit-backdrop-filter: none; }
.seg button.on { background: rgba(var(--text-rgb), .14); color: rgb(var(--text-rgb)); }
.seg.align button { padding: 8px 11px; }

/* stage + canvas */
.stage { flex: 1; width: 100%; display: grid; place-items: center; z-index: 1; min-height: 0; }
.canvas-wrap { filter: drop-shadow(0 24px 50px rgba(0,0,0,.4)); transition: width .45s var(--ease), height .45s var(--ease); }
.canvas { position: relative; width: 100%; height: 100%; border-radius: calc(var(--cw) * .03);
  overflow: hidden; }
.bg-layer { position: absolute; inset: 0; }
.vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(120% 120% at 50% 50%, transparent 40%, rgba(0,0,0,.42)); }
.vignette.on { opacity: 1; }
.scrim { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(to bottom, transparent, rgba(0,0,0,.45)); }
.scrim.on { opacity: 1; }

.card { position: absolute; inset: calc(var(--cw) * var(--inset)); border-radius: calc(var(--cw) * .045);
  display: flex; overflow: hidden; transition: background .3s; }
.card-fill { position: absolute; inset: 0; border-radius: inherit; }
.card-content { position: relative; margin: auto; width: 100%; padding: calc(var(--cw) * .06);
  display: flex; flex-direction: column; gap: calc(var(--cw) * .022); }
.c-head { font-size: calc(var(--cw) * .055 * var(--tscale)); line-height: 1.08; letter-spacing: -.01em;
  color: rgb(var(--text-rgb)); }
.c-body { font-size: calc(var(--cw) * .032 * var(--tscale)); line-height: 1.3;
  color: rgba(var(--text-rgb), var(--text-op)); white-space: pre-wrap; }
.c-placeholder { font-size: calc(var(--cw) * .032 * var(--tscale)); color: rgba(var(--text-rgb), var(--ph-op)); text-align: center; }

/* text alignment */
.canvas[data-align="left"]   .card-content { align-items: flex-start; text-align: left; }
.canvas[data-align="center"] .card-content { align-items: center; text-align: center; }
.canvas[data-align="right"]  .card-content { align-items: flex-end; text-align: right; }

/* card styles (deterministic — no backdrop-filter so export matches) */
.card[data-style="none"] .card-fill { display: none; }
.card[data-style="solid"] .card-fill { background: var(--box);
  box-shadow: inset 0 0 0 1px rgba(var(--text-rgb), var(--stroke-op)); }
.card[data-style="elevated"] .card-fill { background: var(--box);
  box-shadow: inset 0 0 0 1px rgba(var(--text-rgb), calc(var(--stroke-op) * .8)), 0 calc(var(--cw)*.02) calc(var(--cw)*.05) rgba(0,0,0,.45); }
.card[data-style="minimal"] .card-fill { background: rgba(var(--box-rgb), .18);
  box-shadow: inset 0 0 0 1px rgba(var(--text-rgb), .28); }
.card[data-style="glass"] .card-fill {
  background:
    linear-gradient(135deg, rgba(255,255,255,.16), rgba(255,255,255,.02)),
    rgba(var(--box-rgb), .42);
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.32), 0 calc(var(--cw)*.012) calc(var(--cw)*.03) rgba(0,0,0,.35); }
body.is-light .card[data-style="glass"] .card-fill {
  background: linear-gradient(135deg, rgba(255,255,255,.5), rgba(255,255,255,.05)), rgba(var(--box-rgb), .55); }

/* watermark */
.watermark { position: absolute; inset: calc(var(--cw)*.045); display: flex; align-items: center; gap: .4em;
  font-size: calc(var(--cw) * .024); color: rgb(var(--text-rgb)); pointer-events: none; }
.watermark .xm { width: 1.05em; height: 1.05em; }
.wm-tl { justify-content: flex-start; align-items: flex-start; }
.wm-tr { justify-content: flex-end; align-items: flex-start; }
.wm-bl { justify-content: flex-start; align-items: flex-end; }
.wm-br { justify-content: flex-end; align-items: flex-end; }
.wm-bc { justify-content: center; align-items: flex-end; }

/* input */
.input-wrap { z-index: 2; width: min(640px, 100%); display: flex; gap: 12px; align-items: flex-start;
  margin-top: 22px; padding: 15px 20px; border-radius: 18px;
  background: rgba(var(--text-rgb), .05); border: 1px solid rgba(var(--text-rgb), .14);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.input-wrap i { color: rgb(var(--accent-rgb)); margin-top: 2px; }
.input-wrap textarea { flex: 1; resize: none; background: none; border: none; outline: none;
  font-size: 17px; line-height: 1.35; max-height: 130px; }
.input-wrap textarea::placeholder { color: rgba(var(--text-rgb), .4); }

/* CTA */
.cta-row { z-index: 2; display: flex; gap: 12px; margin-top: 22px; }
.cta { display: inline-flex; align-items: center; gap: 9px; padding: 0 26px; height: 52px; border-radius: 999px;
  font-size: 16px; color: var(--btn-text); background: rgb(var(--accent-rgb));
  box-shadow: 0 12px 28px rgba(var(--accent-rgb), .35); transition: transform .25s var(--ease), filter .2s; }
.cta:hover { transform: translateY(-2px); filter: brightness(1.06); }
.cta:active { transform: scale(.97); }
.cta.full { width: 100%; justify-content: center; margin-top: 8px; }
.cta-ghost { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; }

/* panels */
.panel { position: fixed; top: 0; right: 0; z-index: 40; height: 100dvh; width: 380px; max-width: 92vw;
  display: flex; flex-direction: column; transform: translateX(110%); transition: transform .42s var(--ease);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(40px) saturate(1.4); backdrop-filter: blur(40px) saturate(1.4);
  border-left: 1px solid rgba(var(--text-rgb), .12); }
.panel.small { width: 320px; }
.panel.open { transform: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 22px 8px; font-size: 18px; }
.panel-head span { display: inline-flex; align-items: center; gap: 9px; }
.panel-head .x { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(var(--text-rgb), .08); }
.panel-body { padding: 12px 22px 30px; overflow-y: auto; }
.sec-label { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: rgba(var(--text-rgb), .5); margin: 18px 0 10px; }
.panel .seg { display: flex; width: 100%; }
.panel .seg button { flex: 1; }

.grid { display: grid; gap: 10px; }
.grid.themes { grid-template-columns: repeat(3, 1fr); }
.grid.swatches { grid-template-columns: repeat(2, 1fr); }
.grid.pos { grid-template-columns: repeat(2, 1fr); }
.grid.cards { display: grid; grid-template-columns: repeat(5, 1fr); }

.sw { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9;
  border: 1px solid rgba(var(--text-rgb), .15); cursor: pointer; transition: transform .2s var(--ease); }
.sw:hover { transform: translateY(-2px); }
.sw.on { outline: 2.5px solid rgb(var(--accent-rgb)); outline-offset: 1px; }
.sw .nm { position: absolute; left: 6px; bottom: 5px; font-size: 10px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.sw .ck { position: absolute; right: 5px; top: 5px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.theme-sw { display: grid; place-items: center; font-size: 20px; }

.card-btn { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 4px; border-radius: 12px;
  font-size: 10px; color: rgba(var(--text-rgb), .6); background: rgba(var(--text-rgb), .05);
  border: 1px solid rgba(var(--text-rgb), .12); }
.card-btn.on { color: rgb(var(--text-rgb)); background: rgba(var(--accent-rgb), .22); border-color: rgba(var(--text-rgb), .35); }

.row-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: 12px; margin-bottom: 8px; text-align: left;
  background: rgba(var(--text-rgb), .05); border: 1px solid rgba(var(--text-rgb), .12); color: rgb(var(--text-rgb)); }
.row-btn .sub { font-size: 11px; color: rgba(var(--text-rgb), .5); }
.row-btn.on { background: rgba(var(--accent-rgb), .22); border-color: rgba(var(--text-rgb), .3); }
.row-btn .ck { color: rgb(var(--accent-rgb)); }

.field { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-radius: 12px;
  background: rgba(var(--text-rgb), .06); border: 1px solid rgba(var(--text-rgb), .15); }
.field input { flex: 1; background: none; border: none; outline: none; font-size: 15px; }
.field .at { color: rgba(var(--text-rgb), .5); }
.field .xmark { width: 15px; height: 15px; background: rgb(var(--text-rgb)); -webkit-mask: var(--xmask) center/contain no-repeat; mask: var(--xmask) center/contain no-repeat; }

.slider-row { display: flex; justify-content: space-between; font-size: 13px; margin: 16px 0 8px; }
.slider-row .val { color: rgba(var(--text-rgb), .6); }
input[type=range] { width: 100%; accent-color: rgb(var(--accent-rgb)); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; font-size: 14px; cursor: pointer; }
.toggle-row input { display: none; }
.toggle-row .switch { width: 44px; height: 26px; border-radius: 999px; background: rgba(var(--text-rgb), .18); position: relative; transition: background .25s; }
.toggle-row .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); }
.toggle-row input:checked + .switch { background: rgb(var(--accent-rgb)); }
.toggle-row input:checked + .switch::after { transform: translateX(18px); }

.filebtn { display: inline-flex; align-items: center; gap: 7px; padding: 11px 16px; font-size: 13px; border-radius: 999px; margin: 4px 8px 0 0; }
.filebtn.ghost { background: rgba(var(--text-rgb), .05); }

.scrim-modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .3s; }
.scrim-modal.show { opacity: 1; }

.toast { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px); z-index: 60; opacity: 0;
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 999px; font-size: 13px;
  background: color-mix(in srgb, var(--bg) 80%, transparent); border: 1px solid rgba(var(--text-rgb), .16);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); transition: opacity .35s var(--ease), transform .35s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .ok { color: #46d17a; }

svg.ic { width: 1em; height: 1em; display: block; }
.headline, .brand, .splash-word { font-weight: 600; }

@media (max-width: 560px) {
  .headline { margin: 10px 0 14px; }
  .top-actions .chip span { display: none; }
  .panel { width: 100%; max-width: 100%; }
}
