:root {
  --bg-cream: #f4ecdf;
  --bg-frost: #eef4f5;
  --bg-gold: #dac6a7;
  --surface: rgba(255, 252, 247, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(255, 255, 255, 0.7);
  --ink: #1a3143;
  --ink-soft: #62717b;
  --accent: #145f83;
  --accent-strong: #103f65;
  --accent-soft: rgba(20, 95, 131, 0.12);
  --warm: #c69157;
  --line: rgba(16, 58, 80, 0.12);
  --line-strong: rgba(16, 58, 80, 0.2);
  --shadow: 0 28px 60px rgba(16, 38, 51, 0.12);
  --shadow-soft: 0 18px 36px rgba(16, 38, 51, 0.08);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --font-body: "Noto Sans Thai", "Aptos", "Leelawadee UI", "Segoe UI", sans-serif;
  --font-display: "Noto Sans Thai", "Aptos", "Leelawadee UI", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

body {
  min-height: 100dvh;
  overflow: auto;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(20, 95, 131, 0.22), transparent 30%),
    radial-gradient(circle at top right, rgba(198, 145, 87, 0.16), transparent 22%),
    linear-gradient(135deg, #fbf7ef 0%, var(--bg-cream) 42%, var(--bg-frost) 100%);
}

[hidden] {
  display: none !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black 38%, transparent 92%);
  opacity: 0.35;
}

button,
input,
summary,
a {
  font: inherit;
}

a {
  color: inherit;
}

button {
  border: 0;
}

button,
input,
summary,
a {
  transition:
    transform 180ms ease,
    opacity 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(20, 95, 131, 0.24);
  outline-offset: 3px;
}

.page-shell {
  width: min(1240px, calc(100% - 32px));
  min-height: calc(100dvh - 24px);
  margin: 12px auto 24px;
  position: relative;
  z-index: 1;
}

.hero-card,
.panel {
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero-card {
  position: relative;
  display: block;
  padding: 34px 36px;
  border-radius: 30px;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: -60px auto auto -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 95, 131, 0.18), transparent 68%);
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -20px -60px auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(198, 145, 87, 0.2), transparent 72%);
}

.hero-copy-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: center;
  max-width: 620px;
}

.eyebrow {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 800;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
}

h1 {
  max-width: 11ch;
  font-size: clamp(2.3rem, 4vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

h2 {
  font-size: clamp(1.35rem, 2.1vw, 1.8rem);
  line-height: 1.16;
}

h3 {
  font-size: 1.08rem;
}

.hero-copy,
.panel-copy,
.section-heading p,
.field-hint {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

.hero-copy {
  max-width: 34ch;
  font-size: 1rem;
}

.hero-actions {
  display: flex;
  margin-top: 2px;
}

.primary-button,
.secondary-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 13px 20px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: white;
  box-shadow: 0 14px 26px rgba(16, 63, 101, 0.22);
}

.primary-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.primary-button:not(:disabled):hover,
.secondary-button:hover,
.secondary-link:hover {
  transform: translateY(-1px);
}

.secondary-button,
.secondary-link {
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-strong);
  border: 1px solid rgba(20, 95, 131, 0.14);
  box-shadow: var(--shadow-soft);
}

.hero-primary {
  padding-inline: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 454px) minmax(440px, 1fr);
  gap: 22px;
  margin-top: 0;
  align-items: start;
}

.panel {
  border-radius: var(--radius-xl);
  min-height: 0;
  padding: 20px;
}

.panel-heading,
.section-heading,
.action-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading {
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(20, 95, 131, 0.08);
}

.panel-copy {
  max-width: 26ch;
  font-size: 0.94rem;
}

.mobile-sheet-header {
  display: none;
}

.sheet-toggle {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 14px 10px;
  background: transparent;
  color: var(--ink);
}

.sheet-handle {
  width: 48px;
  height: 5px;
  border-radius: 999px;
  background: rgba(16, 63, 101, 0.22);
}

.sheet-heading {
  font-weight: 800;
  font-size: 0.95rem;
}

.sheet-toggle-text {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.mobile-sheet-tabs {
  display: none;
}

.sheet-tab {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(20, 95, 131, 0.06);
  color: var(--ink-soft);
  font-weight: 700;
}

.sheet-tab.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: white;
  box-shadow: 0 8px 18px rgba(16, 63, 101, 0.18);
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: visible;
}

.controls-scroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: visible;
}

.dropzone {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 22px;
  border: 1.5px dashed rgba(20, 95, 131, 0.26);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 248, 238, 0.92)),
    var(--surface-strong);
  cursor: pointer;
}

.dropzone-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.dropzone-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.dropzone:hover,
.dropzone.is-dragging {
  transform: translateY(-1px);
  border-color: rgba(20, 95, 131, 0.52);
  box-shadow: 0 16px 30px rgba(20, 95, 131, 0.12);
}

.dropzone-badge,
.section-tag,
.meta-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(20, 95, 131, 0.08);
  border: 1px solid rgba(20, 95, 131, 0.08);
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 700;
}

.dropzone-icon {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(20, 95, 131, 0.16), rgba(198, 145, 87, 0.18));
}

.dropzone-icon::before,
.dropzone-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(16, 63, 101, 0.72);
  transform: translate(-50%, -50%);
  border-radius: 999px;
}

.dropzone-icon::before {
  width: 20px;
  height: 3px;
}

.dropzone-icon::after {
  width: 3px;
  height: 20px;
}

.dropzone strong {
  font-size: 0.98rem;
  line-height: 1.25;
}

.dropzone-copy > span {
  color: var(--ink-soft);
  line-height: 1.35;
}

.field-group {
  display: grid;
  gap: 4px;
}

.field-label,
.field-group label,
.slider-row label {
  font-weight: 700;
}

.mode-switch,
.mode-panel {
  display: grid;
  gap: 8px;
}

.toggle-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  border-radius: 16px;
  border: 1px solid rgba(20, 95, 131, 0.1);
  background: rgba(255, 255, 255, 0.72);
}

.toggle-button {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 700;
}

.toggle-button.is-active {
  background: linear-gradient(135deg, rgba(20, 95, 131, 0.16), rgba(16, 63, 101, 0.18));
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(20, 95, 131, 0.08);
}

.asset-dropzone {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px dashed rgba(20, 95, 131, 0.22);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.asset-dropzone:hover,
.asset-dropzone.is-dragging {
  transform: translateY(-1px);
  border-color: rgba(20, 95, 131, 0.42);
  box-shadow: 0 14px 24px rgba(20, 95, 131, 0.08);
}

.asset-dropzone.has-file {
  border-style: solid;
  border-color: rgba(20, 95, 131, 0.34);
  background: rgba(255, 255, 255, 0.82);
}

.asset-dropzone:focus-visible {
  outline: 3px solid rgba(20, 95, 131, 0.24);
  outline-offset: 3px;
}

.watermark-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.inline-button {
  justify-self: flex-start;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(20, 95, 131, 0.08);
  color: var(--accent-strong);
  font-weight: 700;
}

.color-section,
.slider-section {
  display: grid;
  gap: 10px;
}

.color-tools {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(20, 95, 131, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
}

input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  outline: none;
}

input[type="text"]:focus,
input[type="color"]:focus {
  border-color: rgba(20, 95, 131, 0.45);
  box-shadow: 0 0 0 4px rgba(20, 95, 131, 0.12);
}

.compact-heading {
  margin-bottom: -2px;
}

.slider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.slider-row {
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border: 1px solid rgba(20, 95, 131, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
}

.slider-wide {
  grid-column: 1 / -1;
}

.slider-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.slider-control span {
  min-width: 50px;
  text-align: right;
  font-weight: 700;
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.color-field {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(20, 95, 131, 0.12);
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  cursor: pointer;
}

.swatch-button.is-active {
  border-color: var(--accent-strong);
  transform: scale(1.08);
  box-shadow:
    0 0 0 4px rgba(20, 95, 131, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

input[type="color"] {
  width: 52px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: white;
  padding: 4px;
}

.action-row {
  margin-top: auto;
}

.preview-action-row {
  display: flex;
  justify-content: flex-start;
}

.preview-action-button {
  min-width: 220px;
}

.preview-panel {
  position: sticky;
  top: 12px;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 12px;
  align-content: start;
  overflow: visible;
}

.preview-heading {
  align-items: center;
}

.canvas-shell {
  position: relative;
  min-height: clamp(420px, 62vh, 760px);
  display: grid;
  place-items: center;
  border-radius: 26px;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(241, 232, 214, 0.84)),
    rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(20, 95, 131, 0.08);
  overflow: hidden;
}

.canvas-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(20, 95, 131, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 95, 131, 0.03) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.7;
  pointer-events: none;
}

#previewCanvas {
  display: none;
  position: relative;
  z-index: 1;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  border-radius: 22px;
  box-shadow: 0 28px 48px rgba(28, 52, 69, 0.18);
}

@media (max-width: 1120px) {
  .hero-copy-panel {
    max-width: 560px;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .page-shell {
    width: min(100% - 18px, 840px);
    min-height: auto;
    margin: 14px auto 24px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .panel {
    min-height: auto;
    padding: 18px;
    border-radius: 24px;
  }

  .panel-heading {
    gap: 10px;
    padding-bottom: 12px;
  }

  .controls-panel {
    gap: 14px;
    overflow: visible;
  }

  .controls-scroll {
    gap: 14px;
    overflow: visible;
  }

  .dropzone {
    padding: 16px;
  }

  .dropzone-main {
    align-items: start;
  }

  .dropzone strong {
    font-size: 0.98rem;
  }

  .swatch-button {
    width: 40px;
    height: 40px;
  }

  .preview-action-row {
    position: sticky;
    bottom: 10px;
    z-index: 4;
    padding-top: 8px;
    margin-top: -2px;
  }

  .preview-panel {
    position: static;
    overflow: visible;
  }

  .canvas-shell {
    min-height: clamp(300px, 52vh, 420px);
    height: auto;
  }

  #previewCanvas {
    width: 100%;
    max-height: 56vh;
  }
}

@media (max-width: 720px) {
  body {
    overflow: hidden;
  }

  .page-shell {
    width: 100%;
    height: 100dvh;
    margin: 0;
  }

  .panel {
    padding: 16px;
    border-radius: 20px;
  }

  .action-row,
  .section-heading,
  .preview-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .workspace {
    display: block;
    height: 100dvh;
  }

  .preview-panel,
  .controls-panel {
    position: fixed;
    left: 8px;
    right: 8px;
  }

  .preview-panel {
    top: 8px;
    bottom: calc(58dvh + 16px);
    z-index: 1;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 14px;
    gap: 12px;
  }

  .controls-panel {
    bottom: 8px;
    z-index: 5;
    max-height: 58dvh;
    padding: 0;
    border-radius: 24px 24px 18px 18px;
    overflow: hidden;
    box-shadow: 0 -12px 34px rgba(16, 38, 51, 0.16);
  }

  body.sheet-collapsed .controls-panel {
    max-height: 92px;
  }

  body.sheet-collapsed .preview-panel {
    bottom: 108px;
  }

  .mobile-sheet-header {
    display: block;
    border-bottom: 1px solid rgba(20, 95, 131, 0.08);
    background: rgba(255, 255, 255, 0.82);
  }

  .mobile-sheet-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 0 14px 12px;
  }

  .controls-scroll {
    gap: 14px;
    padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dropzone-main {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .dropzone-copy {
    gap: 4px;
  }

  .mobile-section-block[hidden] {
    display: none;
  }

  body.sheet-collapsed .controls-scroll {
    opacity: 0;
    pointer-events: none;
  }

  body.sheet-collapsed .sheet-toggle {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .slider-grid {
    grid-template-columns: 1fr;
  }

  .color-field {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .swatch-row {
    gap: 8px;
  }

  .swatch-button {
    width: 42px;
    height: 42px;
  }

  .slider-row {
    padding: 11px 11px 10px;
  }

  .canvas-shell {
    min-height: 0;
    height: 100%;
    padding: 12px;
  }

  .primary-button,
  .secondary-button,
  .secondary-link {
    width: 100%;
  }

  .preview-action-row {
    position: static;
    padding-top: 2px;
    margin-top: 0;
  }

  .preview-action-button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .eyebrow {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
  }

  h2 {
    font-size: 1.42rem;
  }

  .dropzone-badge,
  .section-tag,
  .meta-badge {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .dropzone {
    gap: 6px;
    padding: 14px;
    border-radius: 18px;
  }

  .dropzone-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .dropzone strong {
    font-size: 0.95rem;
  }

  input[type="text"] {
    padding: 11px 12px;
  }

  .color-tools {
    padding: 12px;
  }

  .mobile-sheet-header {
    border-bottom-color: rgba(20, 95, 131, 0.06);
  }

  .sheet-toggle {
    padding: 10px 12px 8px;
  }

  .mobile-sheet-tabs {
    gap: 6px;
    padding: 0 12px 10px;
  }

  .sheet-tab {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.84rem;
  }

  .sheet-heading {
    font-size: 0.9rem;
  }

  .sheet-toggle-text {
    font-size: 0.78rem;
  }

  .slider-control {
    gap: 8px;
  }

  .slider-control span {
    min-width: 44px;
    font-size: 0.86rem;
  }

  .canvas-shell {
    min-height: 0;
    border-radius: 20px;
  }

  #previewCanvas {
    border-radius: 16px;
    max-height: 48vh;
  }
}
