@font-face {
  font-family: "Figtree";
  src: url("fonts/Figtree-VariableFont_wght.ttf") format("truetype");
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
}

@font-face {
  font-family: "Figtree";
  src: url("fonts/Figtree-Italic-VariableFont_wght.ttf") format("truetype");
  font-style: italic;
  font-weight: 300 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --moss: #325a41;
  --moss-dark: #2a4d37;
  --moss-mid: #4c7558;
  --moss-pale: #e6eee9;
  --gold: #ebcd50;
  --gold-dark: #d4b43a;
  --graphite: #141e19;
  --petroleum: #1e372d;
  --mist: #f0f0f0;
  --white: #fff;
  --text-2: #46554d;
  --text-3: #6e7b74;
  --line: #d8d9d6;
  --line-dark: #2c3a33;
  --danger: #aa4b3d;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-pill: 999px;
  --shadow: 0 18px 48px rgba(20, 30, 25, .14);
  --font: "Figtree", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--mist);
  color: var(--graphite);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, select { color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
::selection { background: var(--gold); color: var(--graphite); }

.app-shell {
  height: 100dvh;
  min-height: 620px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 18px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--moss) 36%, var(--line));
  border-radius: 50%;
  background: var(--moss-pale);
}

.brand-mark img { width: 26px; height: 20px; }
.brand-copy { min-width: 0; display: grid; line-height: 1; }
.brand-copy strong { font-size: 22px; font-weight: 820; letter-spacing: -.035em; }
.brand-copy small {
  margin-top: 6px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 720;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.top-actions { display: flex; align-items: center; gap: 8px; }
.button, .icon-button, .preset-button, .stage-reset {
  border: 1px solid var(--line);
  background: var(--white);
  transition: background-color .18s cubic-bezier(.2, 0, 0, 1), border-color .18s cubic-bezier(.2, 0, 0, 1), transform .18s cubic-bezier(.2, 0, 0, 1);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-pill);
  padding: 0 16px;
  font-weight: 680;
  white-space: nowrap;
}

.button:hover:not(:disabled), .icon-button:hover:not(:disabled), .stage-reset:hover:not(:disabled) {
  border-color: var(--moss-mid);
  background: var(--moss-pale);
}
.button:active:not(:disabled), .icon-button:active:not(:disabled), .stage-reset:active:not(:disabled) { transform: scale(.98); }
.button:disabled { opacity: .45; cursor: wait; }
.button--primary { border-color: var(--gold); background: var(--gold); color: var(--graphite); }
.button--primary:hover:not(:disabled) { border-color: var(--gold-dark); background: var(--gold-dark); }
.button--quiet { background: transparent; }
.button--soft { background: var(--moss-pale); border-color: color-mix(in srgb, var(--moss) 28%, var(--line)); color: var(--moss-dark); }
.icon-button { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 50%; font-size: 18px; }

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 410px);
  gap: 12px;
  padding: 12px;
  background: var(--mist);
}

.viewer {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--graphite);
  box-shadow: 0 1px 0 rgba(20,30,25,.08);
}

.stage-toolbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-dark);
  background: var(--petroleum);
  color: var(--mist);
}

.preset-group { min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.preset-group::-webkit-scrollbar { display: none; }
.preset-button {
  min-height: 34px;
  border-color: var(--line-dark);
  border-radius: var(--r-pill);
  padding: 0 12px;
  background: transparent;
  color: #b8c4bd;
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}
.preset-button:hover { color: var(--white); background: rgba(255,255,255,.06); }
.preset-button.is-active { border-color: var(--gold); background: var(--gold); color: var(--graphite); }
.render-status { display: inline-flex; align-items: center; gap: 7px; color: #b8c4bd; font-size: 11px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 5px rgba(235,205,80,.09); }
.render-status.is-paused .status-dot { background: #89978f; box-shadow: none; }

.stage {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 42%, rgba(50, 90, 65, .15), transparent 48%),
    var(--graphite);
  touch-action: none;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .16;
  background-image:
    linear-gradient(rgba(240,240,240,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240,240,240,.05) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, #000, transparent 70%);
}

#renderCanvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

.stage-brand {
  width: 38px;
  height: 38px;
  position: absolute;
  top: 18px;
  left: 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(240,240,240,.16);
  border-radius: 50%;
  background: rgba(20,30,25,.42);
  backdrop-filter: blur(8px);
  pointer-events: none;
}
.stage-brand img { width: 22px; }
.gesture-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(240,240,240,.15);
  border-radius: var(--r-pill);
  padding: 8px 12px;
  background: rgba(20,30,25,.7);
  color: #c6d0ca;
  font-size: 10px;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  pointer-events: none;
}
.stage-reset {
  width: 39px;
  height: 39px;
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  place-items: center;
  border-color: rgba(240,240,240,.16);
  border-radius: 50%;
  background: rgba(20,30,25,.68);
  color: var(--mist);
  font-size: 18px;
  backdrop-filter: blur(10px);
}
.stage-reset:hover { color: var(--graphite); }

.empty-state {
  position: absolute;
  inset: 22%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed rgba(240,240,240,.3);
  border-radius: var(--r-lg);
  background: rgba(30,55,45,.4);
  color: var(--mist);
}
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: var(--graphite); font-size: 25px; }
.empty-state strong { font-size: 18px; }
.empty-state > span:last-child { color: #b8c4bd; font-size: 11px; }

.size-bar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid var(--line-dark);
  background: var(--petroleum);
}
.size-bar label {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-dark);
  border-radius: var(--r-pill);
  padding: 0 13px;
  background: var(--graphite);
  color: var(--mist);
}
.size-bar label > span { font-size: 11px; font-weight: 760; }
.size-bar input { width: 60px; border: 0; outline: 0; background: transparent; color: var(--mist); font-variant-numeric: tabular-nums; text-align: right; }
.size-bar input[type="number"] { appearance: textfield; }
.size-bar input[type="number"]::-webkit-inner-spin-button,
.size-bar input[type="number"]::-webkit-outer-spin-button { margin: 0; appearance: none; }
.size-bar small { color: #94a49a; }
.size-bar select {
  height: 40px;
  min-width: 142px;
  border: 1px solid var(--line-dark);
  border-radius: var(--r-pill);
  padding: 0 34px 0 14px;
  background: var(--graphite);
  color: var(--mist);
}

.controls-panel {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--white);
  scrollbar-color: var(--moss-mid) transparent;
}

.panel-intro {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-intro > div { min-width: 0; display: grid; }
.panel-intro strong { font-size: 16px; font-weight: 760; letter-spacing: -.02em; }
.panel-intro span { margin-top: 3px; color: var(--text-3); font-size: 11px; }

.control-section { border-bottom: 1px solid var(--line); }
.control-section > summary {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  list-style: none;
  font-size: 13px;
  font-weight: 760;
  cursor: pointer;
}
.control-section > summary::-webkit-details-marker { display: none; }
.control-section > summary i { transition: transform .18s ease; }
.control-section[open] > summary i { transform: rotate(180deg); }
.control-section > summary:hover { background: var(--moss-pale); }
.section-body { display: grid; gap: 16px; padding: 2px 16px 20px; }

.upload-card {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px;
  background: var(--mist);
  color: inherit;
  text-align: left;
}
.upload-card:hover { border-color: var(--moss-mid); background: var(--moss-pale); }
.upload-preview { height: 58px; overflow: hidden; border-radius: var(--r-sm); background: var(--graphite); }
.upload-preview canvas { width: 100%; height: 100%; display: block; object-fit: cover; }
.upload-copy { min-width: 0; display: grid; }
.upload-copy strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.upload-copy small { margin-top: 4px; color: var(--moss); font-size: 10px; font-weight: 680; }
.upload-card > i { margin-right: 5px; color: var(--moss); font-size: 19px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; border-radius: var(--r-pill); padding: 4px; background: var(--mist); }
.segmented button { min-height: 36px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text-3); font-weight: 680; }
.segmented button.is-active { background: var(--graphite); color: var(--mist); }

.control-list { display: grid; gap: 14px; }
.range-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px 12px; }
.range-control > span { min-width: 0; overflow: hidden; color: var(--text-2); font-size: 12px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.range-control output {
  min-width: 55px;
  border-radius: var(--r-sm);
  padding: 3px 7px;
  background: var(--mist);
  color: var(--text-2);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.range-control input[type="range"] {
  width: 100%;
  grid-column: 1 / -1;
  margin: 0;
  accent-color: var(--moss);
}
.range-control.compact { padding-bottom: 4px; }

input[type="range"] { height: 18px; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: var(--r-pill); background: var(--moss-pale); }
input[type="range"]::-webkit-slider-thumb { margin-top: -5px; }

.color-list { gap: 14px; }
.color-control { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.color-control > span:first-child { min-width: 0; color: var(--text-2); font-size: 12px; font-weight: 620; }
.color-field { height: 38px; display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--mist); }
.color-field input[type="color"] { width: 40px; height: 40px; border: 0; padding: 0; background: transparent; cursor: pointer; }
.color-field input[type="text"] { width: 83px; border: 0; outline: 0; padding: 0 10px 0 7px; background: transparent; color: var(--graphite); font-size: 11px; font-variant-numeric: tabular-nums; }

.select-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.select-control > span { color: var(--text-2); font-size: 12px; font-weight: 620; }
.select-control select, .export-grid select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 0 32px 0 12px;
  background: var(--mist);
  font-size: 11px;
}

.switch-control { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); padding-top: 16px; cursor: pointer; }
.switch-control > span:first-child { display: grid; }
.switch-control strong { color: var(--text-2); font-size: 12px; }
.switch-control small { margin-top: 2px; color: var(--text-3); font-size: 10px; }
.switch-control input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { width: 44px; height: 26px; position: relative; flex: 0 0 auto; border-radius: var(--r-pill); background: #bdc5c0; transition: .18s ease; }
.switch-ui::after { content: ""; width: 20px; height: 20px; position: absolute; top: 3px; left: 3px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 3px rgba(20,30,25,.24); transition: .18s ease; }
.switch-control input:checked + .switch-ui { background: var(--moss); }
.switch-control input:checked + .switch-ui::after { transform: translateX(18px); }
.switch-control input:focus-visible + .switch-ui { outline: 3px solid var(--gold); outline-offset: 2px; }

.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.button-row .button { padding: 0 10px; font-size: 11px; }

.export-section { background: color-mix(in srgb, var(--moss-pale) 46%, var(--white)); }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.export-grid label { display: grid; gap: 6px; color: var(--text-3); font-size: 10px; font-weight: 680; }
.export-grid select { width: 100%; background: var(--white); }
.codec-note { margin: -2px 0 0; color: var(--text-3); font-size: 10px; }
.codec-note strong { color: var(--moss); }
.export-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.export-actions .button { min-width: 0; padding: 0 10px; font-size: 11px; }
.export-actions .full { grid-column: 1 / -1; }
.export-progress { display: grid; gap: 7px; }
.progress-track { height: 7px; overflow: hidden; border-radius: var(--r-pill); background: var(--moss-pale); }
.progress-track span { width: 0%; height: 100%; display: block; border-radius: inherit; background: var(--moss); transition: width .12s linear; }
.export-progress > span { color: var(--text-3); font-size: 10px; }

.statusbar {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  padding: 0 16px;
  background: var(--white);
  color: var(--text-3);
  font-size: 10px;
}
.statusbar span { display: inline-flex; align-items: center; gap: 6px; }
.statusbar i { color: var(--moss); }

.notice {
  max-width: min(420px, calc(100vw - 32px));
  position: fixed;
  right: 18px;
  bottom: 50px;
  z-index: 60;
  border: 1px solid var(--line-dark);
  border-radius: var(--r-md);
  padding: 12px 14px;
  background: var(--graphite);
  color: var(--mist);
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s cubic-bezier(.2, 0, 0, 1);
}
.notice.is-visible { opacity: 1; transform: translateY(0); }
.notice.is-error { border-color: #c97766; }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 360px; }
  .gesture-hint { max-width: calc(100% - 130px); overflow: hidden; text-overflow: ellipsis; }
  .preset-button { padding-inline: 10px; }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .app-shell { min-height: 100dvh; height: auto; display: block; }
  .topbar { min-height: 70px; position: sticky; top: 0; padding: 10px 12px; }
  .brand-copy small { display: none; }
  .brand-copy strong { font-size: 18px; }
  .brand-mark { width: 38px; height: 38px; }
  .top-actions .button--quiet { width: 40px; padding: 0; }
  .top-actions .button--quiet span, .top-actions .button--quiet:not(#playButton) { font-size: 0; }
  .top-actions .button--quiet i { font-size: 18px; }
  .top-actions .button--primary { padding-inline: 13px; }
  .workspace { display: block; padding: 0; }
  .viewer { height: 49dvh; min-height: 390px; position: sticky; top: 70px; z-index: 10; border-radius: 0; box-shadow: 0 10px 28px rgba(20,30,25,.18); }
  .stage-toolbar { min-height: 50px; }
  .render-status { display: none; }
  .stage-brand { top: 12px; left: 12px; }
  .gesture-hint { left: 12px; bottom: 12px; max-width: calc(100% - 74px); transform: none; }
  .stage-reset { right: 12px; bottom: 12px; }
  .size-bar { min-height: 58px; gap: 6px; padding: 8px; }
  .size-bar label { height: 36px; gap: 4px; padding-inline: 9px; }
  .size-bar input { width: 45px; }
  .size-bar select { height: 36px; min-width: 118px; padding-left: 10px; font-size: 10px; }
  .controls-panel { border: 0; border-radius: 0; overflow: visible; }
  .panel-intro { min-height: 68px; }
  .statusbar { display: none; }
  .notice { bottom: 18px; }
}

@media (max-width: 520px) {
  .top-actions { gap: 5px; }
  .top-actions .button { min-height: 38px; }
  .brand { gap: 8px; }
  .brand-copy strong { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .viewer { height: 47dvh; min-height: 352px; }
  .stage-toolbar { padding-inline: 8px; }
  .preset-button { min-height: 31px; font-size: 10px; }
  .gesture-hint { font-size: 9px; }
  .size-bar label > span, .size-bar small { display: none; }
  .size-bar label { padding-inline: 6px; }
  .size-bar input { width: 58px; font-size: 11px; text-align: center; }
  .size-bar select { flex: 1; min-width: 105px; }
  .button-row, .export-actions { grid-template-columns: 1fr; }
  .export-actions .full { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
