@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-deep: #2a4d37;
  --moss-soft: #e6eee9;
  --yellow: #ebcd50;
  --graphite: #141e19;
  --petroleum: #1e372d;
  --mist: #f0f0f0;
  --white: #fff;
  --line: #d8d9d6;
  --line-dark: #2c3a33;
  --ink: #141e19;
  --muted: #6e7b74;
  --panel-width: 390px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --pill: 999px;
  --shadow: 0 18px 48px rgba(20, 30, 25, 0.16);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; max-width: 100%; overflow-x: hidden; }

body {
  overflow: hidden;
  background: var(--mist);
  color: var(--ink);
  font-family: "Figtree", ui-sans-serif, system-ui, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--yellow); outline-offset: 1px; }

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

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(240, 240, 240, 0.96);
}

.brand-block, .topbar-actions, .stage-toolbar, .stage-actions, .status-line, .toggle-label, .split-actions, .stage-footer { display: flex; align-items: center; }
.brand-block { min-width: 0; gap: 12px; }
.brand-symbol { width: 36px; height: 36px; }
.brand-block h1 { margin: 0; font-size: 19px; line-height: 1; letter-spacing: -0.025em; font-weight: 800; }
.brand-block p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1; }
.topbar-actions { gap: 8px; }

.button, .icon-button, .square-button, .toggle-control, .segmented button, .palette {
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 120ms ease;
}
.button:active, .icon-button:active, .toggle-control:active { transform: scale(0.98); }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--pill); font-size: 12px; font-weight: 700; white-space: nowrap; }
.button i { font-size: 17px; }
.button-primary { background: var(--moss); color: var(--white); }
.button-primary:hover { background: var(--moss-deep); }
.button-secondary { border-color: var(--line); background: var(--white); color: var(--ink); }
.button-secondary:hover { border-color: #a9b0ac; background: #fafafa; }
.button-quiet { border-color: var(--line); background: transparent; color: var(--ink); }
.button-quiet:hover { background: var(--moss-soft); border-color: #a9c2b2; }
.button-danger { border-color: #e0c5c1; background: #fff7f5; color: #8c332b; }
.button-danger:hover { border-color: #bd756e; background: #f9e7e4; }
.full-width { width: 100%; }

.icon-button { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--white); color: var(--ink); font-size: 18px; }
.icon-button:hover { border-color: var(--moss); color: var(--moss); }
.icon-button.inverse { border-color: rgba(240, 240, 240, 0.2); background: rgba(240, 240, 240, 0.06); color: var(--mist); }
.icon-button.inverse:hover { background: rgba(240, 240, 240, 0.12); }

.workspace { display: grid; grid-template-columns: var(--panel-width) minmax(0, 1fr); width: 100%; max-width: 100%; min-width: 0; min-height: 0; overflow: hidden; }
.control-panel { width: 100%; max-width: 100%; min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 20px; border-right: 1px solid var(--line); background: var(--white); scrollbar-width: thin; scrollbar-color: #b9c1bc transparent; }
.panel-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 2px 0 20px; }
.panel-intro h2 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }
.panel-intro p { max-width: 250px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.control-section { width: 100%; max-width: 100%; min-width: 0; overflow: hidden; border-top: 1px solid var(--line); }
.section-header { display: flex; width: 100%; min-height: 54px; align-items: center; justify-content: space-between; padding: 0 4px; background: transparent; color: var(--ink); font-size: 11px; font-weight: 700; line-height: 1; letter-spacing: 0.1em; text-align: left; text-transform: uppercase; }
.section-header:focus-visible { outline: 0; box-shadow: inset 0 -2px var(--yellow); }
.section-header i { color: var(--muted); font-size: 14px; transition: transform 180ms ease; }
.control-section.open .section-header i { transform: rotate(180deg); }
.section-content { display: grid; width: 100%; max-width: 100%; min-width: 0; gap: 15px; padding: 2px 4px 22px; overflow: hidden; }
.section-content[hidden] { display: none; }
.section-note, .helper-text { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }

.field-control, .range-control { display: grid; gap: 7px; min-width: 0; }
.control-label { display: flex; min-width: 0; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 2px; color: #46554d; font-size: 11px; font-weight: 650; line-height: 1.25; }
.control-label output { flex: 0 0 auto; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
input[type="text"], input[type="number"], select { width: 100%; max-width: 100%; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); color: var(--ink); font-size: 12px; }
input[type="text"]:hover, input[type="number"]:hover, select:hover { border-color: #a9b0ac; }

input[type="range"] {
  --range-progress: 50%;
  width: calc(100% - 16px); height: 18px; margin: 0 8px; appearance: none; background: transparent;
}
input[type="range"]:focus-visible { outline: 0; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(235, 205, 80, 0.48), 0 1px 3px rgba(20, 30, 25, 0.2); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(235, 205, 80, 0.48), 0 1px 3px rgba(20, 30, 25, 0.2); }
input[type="range"]::-webkit-slider-runnable-track { height: 5px; border: 1px solid #bfc6c2; border-radius: var(--pill); background: linear-gradient(to right, var(--moss) 0 var(--range-progress), #edf0ee var(--range-progress) 100%); }
input[type="range"]::-webkit-slider-thumb { width: 17px; height: 17px; margin-top: -7px; appearance: none; border: 0; border-radius: 50%; background: var(--moss); box-shadow: 0 1px 3px rgba(20, 30, 25, 0.2); }
input[type="range"]::-moz-range-track { height: 5px; border: 1px solid #bfc6c2; border-radius: var(--pill); background: #edf0ee; }
input[type="range"]::-moz-range-progress { height: 5px; border-radius: var(--pill); background: var(--moss); }
input[type="range"]::-moz-range-thumb { width: 17px; height: 17px; border: 0; border-radius: 50%; background: var(--moss); }

.upload-zone { display: grid; min-height: 96px; place-items: center; align-content: center; gap: 5px; padding: 14px; border: 1px dashed #aab5ae; border-radius: var(--radius-md); background: var(--mist); color: var(--ink); }
.upload-zone:hover, .upload-zone.has-image { border-color: var(--moss); background: var(--moss-soft); }
.upload-zone i { color: var(--moss); font-size: 25px; }
.upload-zone span { font-size: 12px; font-weight: 750; }
.upload-zone small { color: var(--muted); font-size: 10px; }

.toggle-control { display: flex; width: 100%; min-height: 42px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 13px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--mist); color: var(--muted); font-size: 11px; font-weight: 650; }
.toggle-control:hover { border-color: #a9c2b2; }
.toggle-control.is-active { border-color: var(--moss); background: var(--moss-soft); color: var(--moss-deep); }
.toggle-label { gap: 8px; }
.toggle-label i { font-size: 17px; }
.toggle-state { font-weight: 500; }
.split-actions { width: 100%; max-width: 100%; min-width: 0; gap: 8px; }
.split-actions > * { min-width: 0; flex: 1; }
.split-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.text-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.text-button { width: fit-content; padding: 0; background: transparent; color: var(--moss); font-size: 11px; font-weight: 700; }
.text-button:hover { text-decoration: underline; }
.subsection { display: grid; gap: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.custom-format { display: grid; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fafbf9; }
.custom-format[hidden] { display: none; }
.empty-state { margin: 0; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius-md); color: var(--muted); font-size: 10px; text-align: center; }

.effect-card { display: grid; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fafbf9; }
.check-control { display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 11px; font-weight: 700; cursor: pointer; }
.check-control input { width: 16px; height: 16px; margin: 0; accent-color: var(--moss); }
.effect-card:has(.check-control input:not(:checked)) .range-control,
.effect-card:has(.check-control input:not(:checked)) .color-grid { opacity: 0.45; }
.compact-colors { grid-template-columns: 1fr 1fr; }

.zone-list { display: grid; gap: 7px; }
.zone-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 9px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--mist); color: var(--ink); cursor: pointer; }
.zone-row:hover { border-color: #a9c2b2; }
.zone-row.active { border-color: var(--moss); background: var(--moss-soft); }
.zone-icon { display: grid; width: 22px; height: 22px; place-items: center; border: 1px solid var(--moss); border-radius: 50%; color: var(--moss); font-size: 11px; }
.zone-row strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.zone-row small { color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); padding: 3px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--mist); }
.segmented.two { grid-template-columns: repeat(2, 1fr); }
.segmented button { min-width: 0; padding: 9px 6px; border-radius: var(--pill); background: transparent; color: var(--muted); font-size: 10px; font-weight: 650; }
.segmented button.active { background: var(--graphite); color: var(--mist); }

.canvas-tools { display: grid; grid-template-columns: repeat(3, 32px); gap: 3px; padding: 3px; border: 1px solid var(--line-dark); border-radius: var(--pill); background: rgba(240, 240, 240, 0.04); }
.canvas-tools button { display: grid; width: 32px; height: 28px; place-items: center; border-radius: var(--pill); background: transparent; color: #8b9991; font-size: 15px; }
.canvas-tools button:hover { color: var(--mist); }
.canvas-tools button.active { background: var(--yellow); color: var(--graphite); }

.palette-grid { display: grid; grid-template-columns: repeat(4, 44px); gap: 10px; }
.palette { display: grid; width: 44px; height: 44px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--white); }
.palette span { position: relative; display: block; width: 27px; height: 27px; border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); }
.palette span::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--ink); }
.palette.active { border-color: var(--moss); box-shadow: 0 0 0 3px var(--moss-soft); }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.color-control { display: grid; min-width: 0; gap: 7px; }
.color-field { display: flex; min-width: 0; height: 42px; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 6px 5px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); }
.color-field output { min-width: 0; overflow: hidden; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.color-field input[type="color"] { width: 30px; height: 30px; flex: 0 0 auto; padding: 0; overflow: hidden; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(20, 30, 25, 0.18); border-radius: 50%; }
.color-field input[type="color"]::-moz-color-swatch { border: 1px solid rgba(20, 30, 25, 0.18); border-radius: 50%; }

.stage { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; padding: 18px 20px 12px; background: var(--graphite); }
.stage-toolbar { justify-content: space-between; gap: 16px; min-height: 38px; padding-bottom: 12px; color: #b4c0b9; }
.status-line { gap: 8px; font-size: 11px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 4px rgba(235, 205, 80, 0.18); }
.stage-actions { gap: 12px; font-size: 10px; font-variant-numeric: tabular-nums; }
.canvas-wrap { display: flex; min-width: 0; min-height: 0; align-items: center; justify-content: center; overflow: auto; border: 1px solid var(--line-dark); border-radius: var(--radius-lg); background-color: #101612; background-image: radial-gradient(circle at 50% 45%, rgba(50, 90, 65, 0.18), transparent 60%); box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.3); }
.canvas-viewport { flex: 0 0 auto; line-height: 0; box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5); }
#artCanvas { display: block; width: 100%; height: 100%; background: #101412; cursor: crosshair; touch-action: none; user-select: none; }
#artCanvas.is-dragging { cursor: grabbing; }
#artCanvas.tool-move { cursor: grab; }
#artCanvas.tool-mask { cursor: crosshair; }
.stage-footer { justify-content: center; flex-wrap: wrap; gap: 18px; min-height: 32px; padding-top: 8px; color: #86938c; font-size: 10px; }
.stage-footer span { display: flex; align-items: center; gap: 5px; }

.toast { position: fixed; left: 50%; bottom: 20px; z-index: 100; max-width: min(90vw, 560px); padding: 11px 16px; transform: translate(-50%, 18px); border-radius: var(--pill); background: var(--moss); color: var(--white); box-shadow: var(--shadow); font-size: 12px; font-weight: 650; opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: #9b3d32; }

.modal-backdrop { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; background: rgba(20, 30, 25, 0.76); backdrop-filter: blur(4px); }
.modal-backdrop[hidden] { display: none; }
.batch-dialog { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: min(1100px, 96vw); height: min(900px, 92vh); padding: 18px; border-radius: var(--radius-lg); background: var(--mist); box-shadow: var(--shadow); }
.dialog-header, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-header { padding-bottom: 14px; }
.dialog-header h2 { margin: 0; font-size: 20px; letter-spacing: -0.025em; }
.dialog-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.batch-canvas-wrap { display: grid; min-width: 0; min-height: 0; place-items: center; overflow: auto; border-radius: var(--radius-md); background: var(--graphite); }
#batchCanvas { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; cursor: pointer; }
.dialog-actions { justify-content: flex-end; padding-top: 14px; }

@media (max-width: 1120px) {
  :root { --panel-width: 350px; }
  .button span { display: none; }
  .topbar-actions .button { width: 40px; padding: 0; }
}

@media (max-width: 820px) {
  body { overflow-x: hidden; overflow-y: auto; }
  .app-shell { height: auto; min-height: 100dvh; grid-template-rows: auto auto; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .topbar-actions { width: 100%; }
  .topbar-actions .button { flex: 1; width: auto; }
  .topbar-actions .button span { display: inline; }
  .workspace { grid-template-columns: 1fr; }
  .control-panel { max-height: none; border-right: 0; }
  .stage { min-height: 720px; }
  .canvas-tools { order: 3; }
}

@media (max-width: 520px) {
  .brand-block p { display: none; }
  .topbar { padding-inline: 14px; }
  .topbar-actions .button span { display: none; }
  .control-panel { padding-inline: 16px; }
  .text-grid { grid-template-columns: 1fr; }
  .split-controls, .color-grid { grid-template-columns: 1fr; }
  .stage { padding-inline: 10px; min-height: 620px; }
  .stage-footer span:nth-child(2) { display: none; }
}
