@font-face {
  font-family: "Oswald Local";
  src: url("assets/Oswald-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #eef4f1;
  --panel: #ffffff;
  --text: #14231d;
  --muted: #6e7d76;
  --line: #dfe8e3;
  --green: #087d62;
  --green-dark: #07513f;
  --teal: #1e988f;
  --lime: #d8ec30;
  --shadow: 0 18px 55px rgba(17, 50, 37, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(216, 236, 48, .16), transparent 25rem),
    linear-gradient(135deg, #f5f8f6 0%, var(--bg) 100%);
}
button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 82px;
  padding: 14px clamp(18px, 3vw, 38px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid rgba(223, 232, 227, .9);
  backdrop-filter: blur(16px);
}
.topbar h1 { margin: 2px 0 0; font-size: clamp(20px, 2vw, 27px); line-height: 1.15; }
.eyebrow { margin: 0; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
.canvas-badge { padding: 9px 13px; border-radius: 999px; background: #e5f3ee; color: var(--green-dark); font-size: 12px; font-weight: 800; white-space: nowrap; }

.app-shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 2.5vw, 32px) 50px;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 520px);
  gap: 24px;
  align-items: start;
}
.preview-column { min-width: 0; }
.preview-card, .control-panel {
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(220, 230, 224, .95);
  box-shadow: var(--shadow);
}
.preview-card { position: sticky; top: 106px; border-radius: 22px; overflow: hidden; }
.preview-head, .preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 14px 17px;
}
.preview-head { border-bottom: 1px solid var(--line); }
.preview-head strong { display: block; font-size: 14px; }
.preview-head span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.preview-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.canvas-wrap {
  width: 100%;
  padding: 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(45deg, #dfe5e2 25%, transparent 25%, transparent 75%, #dfe5e2 75%),
    linear-gradient(45deg, #dfe5e2 25%, #edf1ef 25%, #edf1ef 75%, #dfe5e2 75%);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
}
canvas {
  display: block;
  width: min(100%, 620px);
  height: auto;
  aspect-ratio: 4 / 5;
  background: #080b09;
  box-shadow: 0 14px 35px rgba(7, 24, 17, .28);
  touch-action: none;
  cursor: grab;
}
canvas.dragging { cursor: grabbing; }

.control-panel { border-radius: 22px; overflow: hidden; }
.panel-section { padding: 22px; border-bottom: 1px solid var(--line); }
.panel-section:last-child { border-bottom: 0; }
.section-title { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.section-title > span {
  flex: 0 0 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green-dark);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}
.section-title h2 { margin: 0; font-size: 16px; }
.section-title p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

label > span, .slider-label { color: #405249; font-size: 11px; font-weight: 700; }
input[type="text"], input[type="number"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cedbd4;
  border-radius: 10px;
  background: #fbfdfc;
  color: var(--text);
  outline: none;
  padding: 8px 11px;
  transition: .2s ease;
}
input[type="text"]:focus, input[type="number"]:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(30, 152, 143, .12); }
.score-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.score-grid label, .control-row label { display: grid; gap: 7px; }
.score-grid input {
  min-height: 62px;
  font-family: Oswald, sans-serif;
  font-weight: 700;
  text-align: center;
  font-size: 29px;
}
.control-row { margin-top: 12px; }
.control-row.two { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.upload-button {
  min-height: 82px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px dashed #a8beb3;
  border-radius: 12px;
  background: #f5faf7;
  transition: .18s ease;
}
.upload-button:hover { border-color: var(--teal); background: #eef9f5; transform: translateY(-1px); }
.upload-button input { display: none; }
.upload-button b { font-size: 11px; }
.upload-button small { margin-top: 5px; color: var(--muted); font-size: 9px; }

.segmented { padding: 4px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border-radius: 12px; background: #edf3f0; }
.layer-button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: #5d6e65; font-size: 11px; font-weight: 700; }
.layer-button.active { background: #fff; color: var(--green-dark); box-shadow: 0 4px 14px rgba(21, 61, 45, .1); }
.quick-actions { margin: 11px 0 19px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.button {
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 800;
  font-size: 11px;
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}
.button:hover { transform: translateY(-1px); filter: brightness(1.02); }
.button:active { transform: translateY(0); }
.button.primary { background: var(--green); color: #fff; box-shadow: 0 9px 20px rgba(8, 125, 98, .24); }
.button.dark { background: #14231d; color: #fff; }
.button.secondary { background: #f4f8f6; border-color: #d8e3dd; color: #395148; }
.button.ghost { background: #fff; border-color: #dbe5e0; color: #486057; }
.button.compact { min-height: 34px; padding: 6px 11px; }

.slider-stack { display: grid; gap: 15px; }
.slider-control { display: grid; grid-template-columns: 1fr 84px; gap: 8px 10px; align-items: center; }
.slider-label { grid-column: 1 / -1; display: flex; justify-content: space-between; }
.slider-label output { color: var(--green); }
input[type="range"] { width: 100%; accent-color: var(--green); }
.slider-control input[type="number"] { min-height: 35px; padding: 5px 8px; font-size: 11px; }
.check-row { margin-top: 16px; display: flex; align-items: center; gap: 9px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--green); }
.check-row span { font-size: 11px; }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.export-grid .button { min-height: 48px; }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 24px;
  padding: 11px 15px;
  border-radius: 11px;
  background: #12231c;
  color: #fff;
  box-shadow: 0 12px 35px rgba(0,0,0,.22);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: minmax(350px, .9fr) minmax(340px, 1fr); }
  .upload-grid { grid-template-columns: 1fr; }
  .upload-button { min-height: 66px; }
}

@media (max-width: 780px) {
  .topbar { min-height: 70px; }
  .app-shell { padding: 12px 10px 30px; grid-template-columns: 1fr; gap: 12px; }
  .preview-card { position: sticky; top: 78px; z-index: 10; border-radius: 16px; }
  .preview-head { padding: 10px 12px; }
  .preview-head span, .preview-footer { display: none; }
  .canvas-wrap { padding: 8px; max-height: 55vh; }
  canvas { width: auto; max-width: 100%; height: min(52vh, 620px); }
  .control-panel { border-radius: 16px; }
  .panel-section { padding: 18px 15px; }
}

@media (max-width: 470px) {
  .canvas-badge { display: none; }
  .score-grid, .control-row.two, .export-grid { grid-template-columns: 1fr 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .slider-control { grid-template-columns: 1fr 74px; }
}
