:root {
  color-scheme: light;
  --surface: #f9f9f9;
  --surface-low: #f3f3f3;
  --surface-container: #eeeeee;
  --surface-high: #e8e8e8;
  --ink: #1a1c1c;
  --muted: #687168;
  --line: #d9dfd7;
  --primary: #769a7e;
  --primary-deep: #44664d;
  --secondary: #8b4c50;
  --secondary-soft: #ffdada;
  --tertiary: #be8646;
  --focus: #44664d;
  --shadow-a: #d1d1d1;
  --shadow-b: #ffffff;
  --canvas: #101714;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--surface);
  color: var(--ink);
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 64px;
  padding: 12px 24px;
  border-bottom: 1px solid rgb(255 255 255 / 0.42);
  background: rgb(118 154 126 / 0.12);
  box-shadow: 0 4px 30px rgb(0 0 0 / 0.08);
  backdrop-filter: blur(18px);
}

.nav-left {
  display: flex;
  align-items: center;
}

.nav-left {
  gap: 30px;
}

.product-name {
  color: var(--primary);
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.icon-button:hover {
  background: rgb(255 255 255 / 0.38);
}

.icon-button:active {
  transform: scale(0.94);
}

.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  padding-top: 64px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 30px;
  height: calc(100vh - 64px);
  padding: 24px;
  overflow-y: auto;
  background: var(--surface-low);
  border-right: 1px solid rgb(203 213 203 / 0.72);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 42px;
}

.eyebrow,
h2 {
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 6px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  color: var(--primary-deep);
  font-size: 1.78rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.field,
.form-grid label,
.sliders label,
.export-option {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.control-group {
  display: grid;
  gap: 14px;
}

.field textarea,
select,
input[type="number"],
input[type="text"],
input[type="color"],
input[type="file"] {
  width: 100%;
  border: 0;
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-container);
  color: var(--ink);
  line-height: 1.55;
  box-shadow:
    inset 6px 6px 12px var(--shadow-a),
    inset -6px -6px 12px var(--shadow-b);
}

select,
input[type="number"],
input[type="text"],
input[type="file"] {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--surface-container);
  color: #59625b;
  box-shadow:
    inset 4px 4px 8px var(--shadow-a),
    inset -4px -4px 8px var(--shadow-b);
}

input[type="color"] {
  width: 100%;
  min-height: 42px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: 7px 7px 14px var(--shadow-a), -7px -7px 14px var(--shadow-b);
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 12px;
}

input[type="file"] {
  min-height: 42px;
  padding: 0;
  color: #59625b;
  cursor: pointer;
  box-shadow: none;
}

input[type="file"]::file-selector-button {
  min-height: 42px;
  margin: 0 12px 0 0;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-container);
  color: var(--primary);
  cursor: pointer;
  font-weight: 900;
  box-shadow:
    7px 7px 14px var(--shadow-a),
    -7px -7px 14px var(--shadow-b);
}

textarea:focus-visible,
input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(118 154 126 / 0.35);
  outline-offset: 3px;
}

.segmented,
.effect-grid,
.preset-row,
.export-actions {
  display: grid;
  gap: 12px;
}

.segmented {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented button,
.effect-grid button,
.preset-row button,
.utility-button,
.export-actions button {
  min-height: 42px;
  border-radius: 14px;
  background: var(--surface-container);
  color: #59625b;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow:
    7px 7px 14px var(--shadow-a),
    -7px -7px 14px var(--shadow-b);
  transition:
    transform 160ms ease,
    color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.segmented button:hover,
.effect-grid button:hover,
.preset-row button:hover,
.utility-button:hover {
  color: var(--primary);
}

.segmented button:active,
.effect-grid button:active,
.preset-row button:active,
.utility-button:active,
.export-actions button:active {
  transform: scale(0.96);
  box-shadow:
    inset 5px 5px 10px var(--shadow-a),
    inset -5px -5px 10px var(--shadow-b);
}

.segmented button.is-active,
.effect-grid button.is-active {
  background: var(--primary);
  color: #ffffff;
  box-shadow:
    inset 2px 2px 5px rgb(68 102 77 / 0.45),
    inset -2px -2px 5px rgb(255 255 255 / 0.18);
}

.effect-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.effect-grid button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px;
  text-align: left;
}

.effect-mark {
  position: relative;
  display: block;
  width: 22px;
  height: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.55);
}

.rain-mark::before,
.rain-mark::after,
.willow-mark::before,
.willow-mark::after,
.soda-mark::before,
.soda-mark::after,
.seed-mark::before,
.seed-mark::after,
.bubble-mark::before,
.bubble-mark::after {
  content: "";
  position: absolute;
}

.rain-mark::before,
.rain-mark::after {
  top: 4px;
  width: 2px;
  height: 14px;
  border-radius: 99px;
  background: #44664d;
}

.rain-mark::before {
  left: 8px;
}

.rain-mark::after {
  left: 14px;
  top: 2px;
}

.willow-mark::before,
.willow-mark::after {
  top: 3px;
  width: 2px;
  height: 15px;
  border-radius: 99px;
  background: #44664d;
  transform-origin: 50% 0;
}

.willow-mark::before {
  left: 9px;
  transform: rotate(12deg);
}

.willow-mark::after {
  left: 14px;
  transform: rotate(-12deg);
}

.bubble-mark::before,
.bubble-mark::after {
  border: 2px solid #44664d;
  border-radius: 999px;
}

.bubble-mark::before {
  inset: 4px 8px 8px 5px;
}

.bubble-mark::after {
  inset: 10px 4px 4px 12px;
}

.soda-mark::before {
  left: 4px;
  right: 4px;
  top: 7px;
  height: 2px;
  border-radius: 99px;
  background: #44664d;
}

.soda-mark::after {
  left: 7px;
  bottom: 5px;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #44664d;
  box-shadow: 7px -4px 0 #769a7e;
}

.seed-mark::before {
  left: 10px;
  top: 5px;
  width: 2px;
  height: 14px;
  border-radius: 99px;
  background: var(--tertiary);
}

.seed-mark::after {
  inset: 4px;
  border: 2px dotted var(--secondary);
  border-radius: 999px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid h2,
.form-grid .preset-row,
.form-grid .file-field,
.form-grid .font-load-button,
.form-grid .custom-font-field,
.form-grid .utility-button,
.export-actions h2,
.export-option,
.export-status,
.download-link {
  grid-column: 1 / -1;
}

.preset-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.font-load-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.sliders label {
  grid-template-columns: minmax(46px, 1fr) auto;
  align-items: center;
}

.sliders output {
  color: #8a928a;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.sliders input {
  grid-column: 1 / -1;
  width: 100%;
  appearance: none;
  height: 20px;
  background: transparent;
}

.sliders input::-webkit-slider-runnable-track,
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: #eeeeee;
  box-shadow:
    inset 2px 2px 5px var(--shadow-a),
    inset -2px -2px 5px var(--shadow-b);
}

.sliders input::-webkit-slider-thumb,
input[type="range"]::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -6px;
  appearance: none;
  border-radius: 999px;
  background: var(--primary);
  box-shadow:
    2px 2px 5px var(--shadow-a),
    -2px -2px 5px var(--shadow-b);
  cursor: pointer;
}

.export-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgb(203 213 203 / 0.75);
}

.export-actions button {
  min-height: 52px;
  color: #ffffff;
  background: var(--primary);
  border-radius: 18px;
}

.export-actions button:nth-of-type(2) {
  color: var(--primary);
  background: #ffffff;
}

.export-actions button:disabled {
  cursor: wait;
  opacity: 0.56;
}

.export-status {
  min-height: 20px;
  margin: 0;
  color: #7c857d;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.45;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 14px;
  background: rgb(118 154 126 / 0.18);
  color: var(--primary-deep);
  font-size: 0.82rem;
  font-weight: 900;
  text-decoration: none;
}

.download-link[hidden] {
  display: none;
}

.stage-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: calc(100vh - 64px);
  padding: 32px;
  overflow: hidden;
  background: var(--surface);
}

.stage-glow {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.stage-glow-a {
  top: 18%;
  left: 18%;
  width: 380px;
  height: 380px;
  background: rgb(118 154 126 / 0.07);
  filter: blur(100px);
}

.stage-glow-b {
  right: 16%;
  bottom: 16%;
  width: 320px;
  height: 320px;
  background: rgb(255 218 218 / 0.2);
  filter: blur(90px);
}

#wordCanvas {
  position: relative;
  z-index: 1;
  display: block;
  width: min(100%, calc((100vh - 160px) * var(--canvas-ratio, 0.75)));
  max-width: calc(100vw - 424px);
  height: auto;
  max-height: calc(100vh - 160px);
  aspect-ratio: var(--canvas-aspect, 1080 / 1440);
  border-radius: 34px;
  background: var(--canvas);
  box-shadow:
    16px 16px 32px var(--shadow-a),
    -16px -16px 32px var(--shadow-b);
  cursor: grab;
  touch-action: none;
}

#wordCanvas.is-dragging {
  cursor: grabbing;
}

.stage-toolbar {
  position: absolute;
  z-index: 3;
  right: 56px;
  bottom: 56px;
  left: 56px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.stage-toolbar > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-toolbar span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgb(118 154 126 / 0.12);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.48);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  backdrop-filter: blur(14px);
}

.stage-toolbar .icon-button {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: rgb(255 255 255 / 0.74);
  color: var(--primary);
  box-shadow: 0 16px 36px rgb(0 0 0 / 0.16);
  pointer-events: auto;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel {
    height: auto;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid rgb(203 213 203 / 0.72);
  }

  .stage-wrap {
    min-height: 72vh;
    padding: 20px;
  }

  #wordCanvas {
    width: min(100%, calc(72vh * var(--canvas-ratio, 0.75)));
    max-width: calc(100vw - 40px);
    max-height: 72vh;
  }

  .stage-toolbar {
    right: 36px;
    bottom: 36px;
    left: 36px;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 10px 16px;
  }

  .panel {
    padding: 20px;
  }

  .effect-grid,
  .form-grid,
  .export-actions {
    grid-template-columns: 1fr;
  }

  .stage-toolbar {
    align-items: flex-start;
  }

  .stage-toolbar > div {
    max-width: calc(100% - 62px);
  }
}
