:root {
  color-scheme: light;
  --ink: #121725;
  --muted: #667085;
  --line: #d9dee8;
  --panel: #ffffff;
  --page: #eef2f7;
  --blue: #071e68;
  --blue-2: #174ea6;
  --red: #e52a35;
  --focus: #d9b45f;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, "Noto Sans Khmer", "Khmer OS Siemreap", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 8%, rgba(217, 180, 95, 0.18), transparent 30rem),
    linear-gradient(135deg, #f8fafc 0%, var(--page) 58%, #e5eaf3 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: center;
}

.workspace {
  min-width: 0;
  display: grid;
  place-items: center;
}

#frameCanvas {
  width: min(100%, calc(100vh - 48px));
  max-width: 940px;
  aspect-ratio: 1;
  height: auto;
  display: block;
  cursor: grab;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(22, 35, 67, 0.22);
  background: #fff;
  touch-action: none;
}

#frameCanvas:active {
  cursor: grabbing;
}

.control-panel {
  width: 100%;
  padding: 22px;
  display: grid;
  gap: 18px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(217, 222, 232, 0.9);
  border-radius: 8px;
  box-shadow: 0 20px 48px rgba(32, 40, 62, 0.12);
}

.brand-block {
  display: grid;
  gap: 6px;
}

.eyebrow {
  margin: 0;
  color: var(--blue-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  line-height: 1.18;
  letter-spacing: 0;
}

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

label {
  color: #344054;
  font-size: 0.92rem;
  font-weight: 700;
}

#imageInput {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.upload-button,
button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.upload-button:hover,
button:hover {
  border-color: #b9c2d2;
  box-shadow: 0 8px 18px rgba(22, 35, 67, 0.09);
  transform: translateY(-1px);
}

.upload-button:focus-within,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(217, 180, 95, 0.45);
  outline-offset: 2px;
}

.status-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

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

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.frame-options,
.language-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.frame-option.is-active,
.language-button.is-active {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.download-button {
  color: #fff;
  border-color: var(--blue);
  background: linear-gradient(135deg, var(--blue), #102e86 62%, var(--red));
}

.download-button:hover {
  border-color: var(--blue);
}

@media (max-width: 980px) {
  .app-shell {
    width: min(760px, calc(100vw - 28px));
    grid-template-columns: 1fr;
    align-items: start;
  }

  #frameCanvas {
    width: 100%;
  }

}

@media (max-width: 520px) {
  .app-shell {
    width: calc(100vw - 20px);
    padding: 10px 0 18px;
    gap: 12px;
  }

  .control-panel {
    padding: 16px;
  }

}
