@font-face {
  font-family: "Anton";
  src: url("../fonts/Anton-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  --navy: #00113E;
  --cyan: #67DCEE;
  --bg: #060b1a;
  --panel: #0c1430;
  --panel-2: #121c3d;
  --line: #1f2b52;
  --text: #e8eefc;
  --muted: #8b97b8;
  --warn: #ffb547;
  --radius: 10px;
}

* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  height: 56px;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--navy);
}
.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand-mark { font-family: "Anton", sans-serif; color: var(--cyan); font-size: 22px; letter-spacing: .5px; }
.brand-sub { font-family: "Anton", sans-serif; font-size: 22px; color: #fff; letter-spacing: .5px; }
.tools { display: flex; align-items: center; justify-content: center; gap: 4px; }
.tools .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.top-right { display: flex; align-items: center; gap: 12px; }
.status { color: var(--muted); font-size: 12px; white-space: nowrap; }

.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid transparent; color: var(--text);
  padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 1;
}
.icon-btn span { font-size: 12.5px; font-weight: 600; }
.icon-btn:hover:not(:disabled) { background: rgba(255,255,255,.06); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.on, .icon-btn.holding { background: var(--cyan); color: var(--navy); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 350px;
  height: calc(100vh - 56px);
  height: calc(100dvh - 56px);
}
.panel { overflow-y: auto; background: var(--panel); padding: 4px 16px 40px; }
.panel.left { border-right: 1px solid var(--line); }
.panel.right { border-left: 1px solid var(--line); }
.tabs { display: none; }

.block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }
.block h2, .adj-sec summary {
  margin: 0 0 10px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--cyan);
}
.block h2 small { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); margin-top: 3px; font-size: 12px; line-height: 1.35; }

.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tpl {
  background: var(--panel-2); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 8px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 5px; transition: border-color .15s, transform .15s;
}
.tpl:hover { border-color: #33427a; transform: translateY(-1px); }
.tpl.active { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan) inset; }
.tpl svg { width: 100%; height: auto; display: block; border-radius: 4px; }
.tpl b { font-size: 12.5px; }
.tpl span { font-size: 11px; color: var(--muted); line-height: 1.25; }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; }
.seg.full { display: flex; }
.seg.full button { flex: 1; }
.seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 10px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; line-height: 1.15;
}
.seg button small { display: block; font-weight: 500; font-size: 10.5px; opacity: .8; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--cyan); color: var(--navy); }

/* ---------- Photo slots ---------- */
.slot-list { display: grid; gap: 8px; }
.slot {
  display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center;
  background: var(--panel-2); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 8px;
  cursor: pointer; transition: border-color .15s;
}
.slot.sel { border-color: var(--cyan); }
.slot.drag { border-color: var(--cyan); background: #16244d; }
.slot-thumb {
  width: 56px; height: 56px; border-radius: 6px; background: #0a1128 center/cover no-repeat;
  border: 1px dashed #33427a; display: grid; place-items: center; color: var(--muted); font-size: 22px;
}
.slot-thumb.has { border-style: solid; color: transparent; }
.slot-main { display: grid; gap: 5px; }
.slot-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.slot-head b { font-size: 13px; }
.slot-actions { display: flex; gap: 3px; }
.slot-meta { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .warnline { color: var(--warn); font-size: 11.5px; }
.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: rgba(103,220,238,.15); color: var(--cyan); margin-left: 6px; vertical-align: 1px; }

.zoom-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
input[type=range] { flex: 1; accent-color: var(--cyan); }

/* ---------- Text ---------- */
.field { margin-bottom: 14px; }
.field label { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.field label .muted { font-weight: 400; }
textarea {
  width: 100%; min-height: 70px; resize: vertical;
  background: #070d22; color: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font: 20px/1.25 "Anton", -apple-system, sans-serif; text-transform: uppercase; letter-spacing: .3px;
}
textarea:focus { outline: none; border-color: var(--cyan); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 8px; }
.chip {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px;
  width: 32px; height: 30px; cursor: pointer; font-size: 17px; line-height: 1; padding: 0;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  transition: transform .1s;
}
.chip:hover { transform: scale(1.12); border-color: var(--cyan); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 10px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13.5px; line-height: 1;
}
.btn:hover:not(:disabled) { border-color: #3a4a85; }
.btn.small { padding: 6px 9px; font-size: 12px; }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--cyan); color: var(--navy); border-color: var(--cyan); }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: default; }
.logo-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.muted { color: var(--muted); }
.small-txt { font-size: 11.5px; }
.warn { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(255,181,71,.1); border: 1px solid rgba(255,181,71,.35); color: var(--warn); font-size: 12px; }

/* ---------- Stage ---------- */
.stage {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px; gap: 10px; min-height: 0;
  background: radial-gradient(circle at 50% 0%, rgba(103,220,238,.06), transparent 60%), var(--bg);
}
.canvas-wrap { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; position: relative; }
#preview {
  display: block; max-width: 100%; max-height: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  touch-action: none; background: #0a1128; cursor: default;
}
#preview.dropping { outline: 3px solid var(--cyan); outline-offset: 3px; }
.compare-badge {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: #fff; color: var(--navy); font: 700 11px/1 -apple-system, sans-serif; letter-spacing: .1em;
  padding: 6px 10px; border-radius: 99px; pointer-events: none;
}
.stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; font-size: 12px; }
.zoom-pill { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Adjust panel ---------- */
.adj-head { padding: 12px 0 10px; border-bottom: 1px solid var(--line); }
.photo-chips { display: flex; gap: 6px; margin-bottom: 10px; }
.photo-chip {
  flex: 1; display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 12px; font-weight: 600;
}
.photo-chip i { width: 28px; height: 28px; border-radius: 5px; background: #0a1128 center/cover; flex: none; font-style: normal; display: grid; place-items: center; color: var(--muted); }
.photo-chip.active { border-color: var(--cyan); }
.photo-chip:disabled { opacity: .4; cursor: default; }
.histogram { width: 100%; height: 78px; display: block; background: #070d22; border-radius: 8px; border: 1px solid var(--line); }
.clip-row { display: flex; justify-content: space-between; font-size: 11px; margin: 4px 2px 8px; }
.clip-row .hot { color: var(--warn); }
.adj-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.presets { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: thin; }
.preset {
  flex: none; display: grid; gap: 4px; justify-items: center; cursor: pointer; background: none; border: 0; padding: 0;
  font-size: 11px; color: var(--muted);
}
.preset canvas { width: 58px; height: 58px; border-radius: 7px; border: 1.5px solid var(--line); display: block; background: #0a1128; }
.preset:hover canvas { border-color: var(--cyan); }
.preset:hover { color: var(--text); }

.adj-body { padding-bottom: 30px; }
.adj-sec { border-bottom: 1px solid var(--line); }
.adj-sec summary { list-style: none; cursor: pointer; padding: 14px 0 12px; margin: 0; display: flex; justify-content: space-between; align-items: center; }
.adj-sec summary::-webkit-details-marker { display: none; }
.adj-sec summary::after { content: "▾"; color: var(--muted); transition: transform .15s; }
.adj-sec:not([open]) summary::after { transform: rotate(-90deg); }
.adj-sec summary .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); margin-left: 8px; display: none; }
.adj-sec summary .dot.on { display: inline-block; }
.adj-sec summary .ttl { display: flex; align-items: center; }
.sec-body { padding-bottom: 14px; }
.sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin: 12px 0 4px; font-weight: 700; }

.srow { display: grid; grid-template-columns: 92px 1fr 46px; align-items: center; gap: 8px; padding: 3px 0; }
.srow label { font-size: 12.5px; color: #c9d2ea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; user-select: none; }
.srow.changed label { color: #fff; font-weight: 600; }
.srow output { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); cursor: text; }
.srow.changed output { color: var(--cyan); }
.srow input[type=range] {
  -webkit-appearance: none; appearance: none; height: 18px; background: transparent; margin: 0; cursor: pointer;
}
.srow input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--track, #2a3766); }
.srow input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--track, #2a3766); }
.srow input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px;
  border: 2px solid var(--navy); box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.srow input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--navy); }
.srow input[type=range]:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }

.mini-seg { display: flex; gap: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px; margin-bottom: 8px; }
.mini-seg button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 5px 4px; border-radius: 5px; font-size: 12px; font-weight: 600; cursor: pointer; }
.mini-seg button.active { background: #2a3766; color: #fff; }
.mini-seg button.r.active { background: #b33a3a; } .mini-seg button.g.active { background: #2f8f52; } .mini-seg button.b.active { background: #3a5fc4; }

.curve-box { position: relative; }
.curve { width: 100%; aspect-ratio: 1; display: block; border-radius: 8px; border: 1px solid var(--line); touch-action: none; cursor: crosshair; }
.curve-presets { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.wheel-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; margin: 6px 0 8px; }
.wheel { width: 150px; height: 150px; display: block; touch-action: none; cursor: crosshair; border-radius: 50%; }
.wheel-info { font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.wheel-info b { color: var(--text); font-weight: 600; }
.swatch { width: 100%; height: 22px; border-radius: 6px; border: 1px solid var(--line); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; padding: 6px 0; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: #2a3766; border-radius: 99px; transition: .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--cyan); }
.switch input:checked + span::after { transform: translateX(16px); }

.adj-empty { padding: 30px 6px; text-align: center; }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; background: rgba(2,5,14,.72); display: grid; place-items: center; z-index: 60; padding: 16px; backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.sheet { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px 20px; box-shadow: 0 30px 80px rgba(0,0,0,.55); max-height: 90vh; overflow: auto; }
.sheet.narrow { width: min(420px, 100%); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet h3 { margin: 0; font-family: "Anton", sans-serif; font-weight: 400; font-size: 22px; letter-spacing: .3px; color: var(--cyan); }
.sheet .row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.sheet .row label { font-size: 13px; font-weight: 600; }
.export-btns { display: grid; gap: 8px; margin: 12px 0 8px; }
.export-btns .btn { width: 100%; padding: 13px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 2px 2px 4px; cursor: pointer; }
.check input { accent-color: var(--cyan); width: 16px; height: 16px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13px; }
.keys dt { font-weight: 700; color: var(--text); white-space: nowrap; }
.keys dd { margin: 0; color: var(--muted); }

.credit {
  position: fixed; right: 16px; bottom: 14px; z-index: 40; pointer-events: none;
  font-size: 11.5px; font-weight: 600; letter-spacing: .03em; color: var(--muted);
  background: rgba(6,11,26,.82); border: 1px solid var(--line); padding: 5px 10px; border-radius: 99px;
  backdrop-filter: blur(4px);
}
.panel { padding-bottom: 56px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #fff; color: var(--navy); padding: 10px 16px; border-radius: 999px;
  font-weight: 600; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 80; max-width: 90vw; text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .layout { grid-template-columns: 360px minmax(0, 1fr); }
  .tabs { display: flex; gap: 4px; position: sticky; top: 0; z-index: 4; background: var(--panel); padding: 10px 0 8px; border-bottom: 1px solid var(--line); }
  .tabs button { flex: 1; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); padding: 9px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 13px; }
  .tabs button.active { background: var(--cyan); color: var(--navy); border-color: var(--cyan); }
  .panel.right { grid-column: 1; grid-row: 1; border-left: 0; border-right: 1px solid var(--line); }
  .panel.left { grid-column: 1; grid-row: 1; }
  .stage { grid-column: 2; grid-row: 1; }
  body[data-tab="design"] .panel.right { display: none; }
  body[data-tab="adjust"] .panel.left { display: none; }

  .tools .icon-btn span { display: none; }
  #stageHint { display: none; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { grid-template-columns: auto auto; height: auto; padding: 8px 12px; row-gap: 6px; }
  .tools { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .brand-mark, .brand-sub { font-size: 18px; }
  .credit { right: 10px; bottom: 10px; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .stage { grid-column: 1; grid-row: 1; position: sticky; top: 0; z-index: 5; height: 52vh; padding: 10px; border-bottom: 1px solid var(--line); }
  .panel.left, .panel.right { grid-column: 1; grid-row: 2; overflow: visible; border-right: 0; }
  .tpl { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .tpl svg { width: 40px; flex: none; }
  .adj-head { top: 0; position: static; }
  .stage-bar #stageHint { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
