:root {
  color-scheme: light;
  --page-bg-start: #fffaf7;
  --page-bg-end: #f9dbe1;
  --page-bg-spot: rgba(246, 180, 189, 0.34);
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #fffdfb;
  --surface-soft: #fff5f3;
  --ink: #2b2228;
  --muted: #806f76;
  --line: rgba(96, 48, 60, 0.12);
  --strawberry: #d94f65;
  --strawberry-soft: #f6b4bd;
  --coral: #ee7c74;
  --cream: #fff8ef;
  --leaf: #759b6d;
  --shadow: rgba(100, 42, 55, 0.18);
  --shell-border: #19171d;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page-bg-start: #151113;
  --page-bg-end: #331f27;
  --page-bg-spot: rgba(255, 117, 134, 0.16);
  --surface: rgba(34, 25, 30, 0.88);
  --surface-strong: #2a2025;
  --surface-soft: #2f2227;
  --ink: #fff8f6;
  --muted: #d8c1c4;
  --line: rgba(255, 242, 238, 0.13);
  --strawberry: #ff7586;
  --strawberry-soft: #9b4d59;
  --coral: #ff9b8d;
  --cream: #261d1b;
  --leaf: #9fbd89;
  --shadow: rgba(0, 0, 0, 0.45);
  --shell-border: #0c0b0f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Noto Sans KR", system-ui, sans-serif;
  background:
    radial-gradient(circle at 18% 16%, var(--page-bg-spot), transparent 30%),
    linear-gradient(135deg, var(--page-bg-start), var(--page-bg-end));
  color: var(--ink);
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

.studio-page {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(18px, 5vw, 42px);
  isolation: isolate;
}

.studio-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(430px, 100%);
  height: min(760px, calc(100vh - 56px));
  height: min(760px, calc(100dvh - 56px));
  min-height: min(760px, calc(100vh - 56px));
  min-height: min(760px, calc(100dvh - 56px));
  overflow: hidden;
  border: 10px solid var(--shell-border);
  border-radius: 46px;
  background: var(--surface);
  box-shadow:
    0 44px 110px var(--shadow),
    0 18px 44px rgba(100, 42, 55, 0.14),
    inset 0 0 0 1px rgba(255, 255, 255, 0.36);
  backdrop-filter: blur(18px) saturate(1.12);
}

.studio-shell::before {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 2;
  width: 112px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  content: "";
  transform: translateX(-50%);
}

.studio-shell::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.32), transparent 28%),
    radial-gradient(circle at 82% 4%, color-mix(in srgb, var(--strawberry-soft) 18%, transparent), transparent 30%);
  content: "";
}

.studio-header {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 94%, transparent), color-mix(in srgb, var(--surface) 76%, transparent)),
    radial-gradient(circle at 86% 0%, color-mix(in srgb, var(--strawberry-soft) 20%, transparent), transparent 38%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.42);
}

.back-link {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--cream) 74%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--line) 72%, transparent),
    0 10px 24px rgba(100, 42, 55, 0.08);
  color: color-mix(in srgb, var(--ink) 82%, var(--strawberry));
  font-size: 34px;
  line-height: 1;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease;
}

.back-link:hover,
.back-link:focus-visible {
  background: color-mix(in srgb, var(--strawberry-soft) 22%, var(--cream));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--strawberry) 18%, transparent),
    0 14px 30px rgba(100, 42, 55, 0.12);
  transform: translateX(-1px);
}

.back-link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--strawberry) 28%, transparent);
  outline-offset: 3px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--strawberry);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(21px, 5.2vw, 24px);
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.studio-empty {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  min-height: 0;
  padding: clamp(32px, 8vw, 48px) 34px 42px;
  background:
    radial-gradient(circle at 50% 28%, color-mix(in srgb, var(--surface-strong) 88%, transparent), transparent 34%),
    linear-gradient(180deg, transparent, color-mix(in srgb, var(--surface-soft) 50%, transparent));
  text-align: center;
}

.studio-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 118px;
  height: 118px;
  border: 1px solid color-mix(in srgb, var(--strawberry) 12%, white);
  border-radius: 36px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--surface-strong) 84%, transparent), color-mix(in srgb, var(--surface-soft) 92%, transparent)),
    radial-gradient(circle at 26% 20%, rgba(255, 255, 255, 0.9), transparent 36%);
  box-shadow:
    0 22px 48px rgba(120, 49, 61, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.studio-mark::before {
  position: absolute;
  inset: 14px;
  border-radius: 28px;
  background: color-mix(in srgb, var(--strawberry) 8%, transparent);
  content: "";
}

.studio-mark::after {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 18px;
  height: 9px;
  border-radius: 999px 999px 0 999px;
  background: color-mix(in srgb, var(--leaf) 62%, transparent);
  content: "";
  opacity: 0.82;
  transform: rotate(-22deg);
}

.studio-mark svg {
  position: relative;
  z-index: 1;
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 10px 16px rgba(148, 45, 60, 0.18));
}

.studio-empty h2 {
  max-width: 310px;
  margin-bottom: -2px;
  font-size: clamp(28px, 8vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.045em;
}

.studio-empty p {
  max-width: 300px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 520px) {
  .studio-page {
    padding: 0;
  }

  .studio-page::before,
  .studio-page::after {
    display: none;
  }

  .studio-shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .studio-shell::before {
    top: 10px;
    background: color-mix(in srgb, var(--ink) 12%, transparent);
  }

  .studio-header {
    padding: max(22px, env(safe-area-inset-top)) 18px 18px;
  }

  .studio-empty {
    padding-right: 26px;
    padding-left: 26px;
  }
}

.studio-shell {
  max-height: min(860px, calc(100vh - 56px));
  max-height: min(860px, calc(100dvh - 56px));
}

.studio-header {
  grid-template-columns: 40px 1fr auto;
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
}

.update-button,
.action-button {
  border: 0;
  border-radius: 999px;
  background: var(--strawberry);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.update-button {
  padding: 10px 14px;
  font-size: 12px;
}

.update-button:disabled,
.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.update-button:not(:disabled):hover,
.action-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.studio-generator {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

.sync-panel {
  display: grid;
  gap: 6px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.sync-status {
  color: var(--ink);
  font-weight: 800;
}

.sheet-status-link {
  color: inherit;
  text-decoration: none;
}

.sheet-status-link:hover,
.sheet-status-link:focus-visible {
  color: inherit;
  text-decoration: none;
}

.generator-scroll {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.error-card,
.control-card,
.preview-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 92%, white 8%);
  box-shadow: 0 16px 36px rgba(70, 28, 42, 0.08);
}

[data-theme="dark"] .error-card,
[data-theme="dark"] .control-card,
[data-theme="dark"] .preview-card {
  background: color-mix(in srgb, var(--surface) 94%, black 6%);
}

[data-theme="dark"] .select-control,
[data-theme="dark"] .custom-input,
[data-theme="dark"] .additional-input {
  background: color-mix(in srgb, var(--surface-strong) 88%, black 12%);
  color: var(--ink);
}

[data-theme="dark"] .select-control option {
  background: var(--surface-strong);
  color: var(--ink);
}

.error-card {
  display: grid;
  gap: 10px;
  padding: 22px;
  text-align: center;
}

.controls-form {
  display: grid;
  gap: 14px;
}

.control-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.control-card[data-required="true"] .control-title::after {
  content: " *";
  color: var(--strawberry);
}

.clothing-card {
  border-color: color-mix(in srgb, var(--strawberry) 42%, var(--line));
}

.control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.control-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.select-control,
.custom-input,
.additional-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  outline: 0;
}

.select-shell {
  position: relative;
}

.select-shell::after {
  position: absolute;
  top: 50%;
  right: 18px;
  width: 8px;
  height: 8px;
  border-right: 2px solid color-mix(in srgb, var(--ink) 78%, var(--strawberry));
  border-bottom: 2px solid color-mix(in srgb, var(--ink) 78%, var(--strawberry));
  pointer-events: none;
  content: "";
  opacity: 0.82;
  transform: translateY(-65%) rotate(45deg);
}

.select-control {
  appearance: none;
  padding: 12px 46px 12px 14px;
}

.select-control option {
  color: var(--ink);
  background: var(--surface-strong);
}

.custom-input,
.additional-input {
  min-height: 44px;
  padding: 12px 14px;
  resize: vertical;
}

.custom-input[hidden] {
  display: none;
}

.requirements-panel {
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--strawberry) 18%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-strong) 92%, var(--strawberry-soft) 8%);
}

.requirements-panel[hidden] {
  display: none;
}

.missing-list:empty {
  display: none;
}

.checkbox-list {
  display: grid;
  gap: 8px;
}

.collapsible-panel {
  display: grid;
  gap: 8px;
}

.collapsible-summary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-strong) 90%, var(--strawberry-soft) 10%);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  list-style: none;
}

.collapsible-summary::-webkit-details-marker {
  display: none;
}

.collapsible-summary::after {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  opacity: 0.68;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 160ms ease;
}

.collapsible-panel[open] > .collapsible-summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.collapsible-count {
  min-width: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--strawberry) 12%, transparent);
  color: var(--strawberry);
  font-size: 11px;
  text-align: center;
}

.collapsible-body {
  display: grid;
  gap: 8px;
}

.checkbox-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  line-height: 1.35;
}

.checkbox-item input {
  align-self: center;
  width: 16px;
  height: 16px;
  margin-top: 0;
  accent-color: var(--strawberry);
}

.outfit-category {
  display: grid;
  gap: 8px;
}

.outfit-category-title {
  color: var(--strawberry);
  font-size: 12px;
  font-weight: 900;
}

.preview-card {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
}

.preview-card h2 {
  margin: 0;
  font-size: 16px;
}

.prompt-preview {
  min-height: 180px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink);
  font-family: "Noto Sans KR", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}

.missing-list {
  margin: 0;
  color: var(--strawberry);
  font-size: 12px;
  font-weight: 800;
}

.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(88px, 0.72fr) minmax(0, 1.28fr);
  gap: 10px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 86%, transparent), color-mix(in srgb, var(--surface-strong) 96%, transparent)),
    color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 -12px 30px rgba(100, 42, 55, 0.08);
}

.action-button {
  min-height: 48px;
  padding: 12px;
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.action-button.secondary {
  background: color-mix(in srgb, var(--strawberry) 14%, transparent);
  color: var(--ink);
}

@media (max-width: 520px) {
  .studio-shell {
    max-height: none;
  }
}
