/* ==========================================================================
   AI Photo Studio — Zen Garden theme
   Minimalist, tranquil, stone-garden inspired design system
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&display=swap");

:root {
  color-scheme: light;

  /* Zen palette — light */
  --background: 40 12% 95%;
  --foreground: 24 10% 15%;
  --card: 40 12% 96%;
  --card-foreground: 24 10% 15%;
  --popover: 40 12% 96%;
  --popover-foreground: 24 10% 15%;
  --primary: 24 10% 20%;
  --primary-foreground: 40 12% 98%;
  --secondary: 35 15% 88%;
  --secondary-foreground: 24 10% 25%;
  --muted: 35 10% 90%;
  --muted-foreground: 24 5% 45%;
  --accent: 75 15% 40%;
  --accent-foreground: 40 12% 98%;
  --destructive: 10 30% 45%;
  --destructive-foreground: 40 12% 98%;
  --border: 35 10% 85%;
  --input: 35 10% 85%;
  --ring: 24 10% 20%;

  --font-sans: "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Noto Serif SC", ui-serif, Georgia, serif;
  --font-mono: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 0.25rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  --shadow-sm: 0px 1px 2px 0px hsl(24 10% 10% / 0.04);
  --shadow: 0px 2px 6px -1px hsl(24 10% 10% / 0.06), 0px 1px 3px 0px hsl(24 10% 10% / 0.04);
  --shadow-md: 0px 4px 14px -2px hsl(24 10% 10% / 0.08), 0px 2px 4px 0px hsl(24 10% 10% / 0.04);
  --shadow-lg: 0px 12px 28px -8px hsl(24 10% 10% / 0.14), 0px 4px 10px -2px hsl(24 10% 10% / 0.06);

  --tracking-normal: 0.02em;
  --tracking-wide: 0.08em;

  --max-width: 1200px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --background: 28 11% 9%;
  --foreground: 42 20% 91%;
  --card: 30 10% 13%;
  --card-foreground: 42 20% 91%;
  --popover: 30 10% 13%;
  --popover-foreground: 42 20% 91%;
  --primary: 42 18% 88%;
  --primary-foreground: 28 12% 10%;
  --secondary: 34 10% 19%;
  --secondary-foreground: 42 18% 88%;
  --muted: 32 9% 17%;
  --muted-foreground: 42 8% 66%;
  --accent: 88 18% 58%;
  --accent-foreground: 28 12% 10%;
  --destructive: 6 55% 62%;
  --destructive-foreground: 28 12% 10%;
  --border: 34 9% 25%;
  --input: 34 9% 27%;
  --ring: 88 18% 58%;

  --shadow-sm: 0px 1px 2px 0px hsl(0 0% 0% / 0.28);
  --shadow: 0px 2px 8px -1px hsl(0 0% 0% / 0.34), 0px 1px 3px 0px hsl(0 0% 0% / 0.24);
  --shadow-md: 0px 8px 22px -6px hsl(0 0% 0% / 0.42), 0px 2px 6px 0px hsl(0 0% 0% / 0.26);
  --shadow-lg: 0px 18px 40px -10px hsl(0 0% 0% / 0.58), 0px 6px 14px -4px hsl(0 0% 0% / 0.34);
}

html[data-theme="dark-blue"] {
  color-scheme: dark;

  --background: 222 38% 4%;
  --foreground: 220 32% 96%;
  --card: 222 22% 8%;
  --card-foreground: 220 32% 96%;
  --popover: 222 22% 9%;
  --popover-foreground: 220 32% 96%;
  --primary: 220 32% 96%;
  --primary-foreground: 223 35% 6%;
  --secondary: 222 18% 14%;
  --secondary-foreground: 220 28% 90%;
  --muted: 222 18% 13%;
  --muted-foreground: 224 15% 64%;
  --accent: 224 84% 70%;
  --accent-foreground: 222 35% 6%;
  --destructive: 2 67% 63%;
  --destructive-foreground: 220 32% 96%;
  --border: 222 16% 20%;
  --input: 222 16% 22%;
  --ring: 224 84% 70%;

  --shadow-sm: 0px 1px 2px 0px hsl(224 70% 2% / 0.32);
  --shadow: 0px 2px 10px -1px hsl(224 70% 2% / 0.42), 0px 1px 4px 0px hsl(224 70% 2% / 0.3);
  --shadow-md: 0px 10px 26px -7px hsl(224 70% 2% / 0.52), 0px 3px 8px 0px hsl(224 70% 2% / 0.32);
  --shadow-lg: 0px 22px 52px -14px hsl(224 70% 2% / 0.68), 0px 8px 18px -5px hsl(224 70% 2% / 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-sans);
  font-weight: 400;
  letter-spacing: var(--tracking-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100%;
}

body {
  background-image:
    radial-gradient(1200px 600px at 80% -10%, hsl(75 15% 40% / 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, hsl(24 10% 20% / 0.05), transparent 60%);
  background-attachment: fixed;
}

html[data-theme="dark"] body {
  background-image:
    radial-gradient(1000px 520px at 78% -8%, hsl(88 18% 58% / 0.12), transparent 58%),
    radial-gradient(900px 520px at -8% 108%, hsl(42 20% 91% / 0.07), transparent 60%);
}

html[data-theme="dark-blue"] body {
  background-color: hsl(var(--background));
  background-image:
    radial-gradient(1150px 720px at 0% 0%, hsl(234 72% 18% / 0.48), transparent 58%),
    radial-gradient(980px 620px at 100% 0%, hsl(20 70% 14% / 0.42), transparent 56%),
    linear-gradient(180deg, hsl(222 38% 5% / 0.96), hsl(222 38% 3% / 1));
}

body.modal-open {
  overflow: hidden;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

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

.hidden {
  display: none !important;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 28px 96px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: hsl(var(--card) / 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 16px;
  z-index: 20;
}

.brand-button {
  background: transparent;
  border: none;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: hsl(var(--foreground));
  letter-spacing: var(--tracking-wide);
  padding: 4px 2px;
}

.brand-button::before {
  content: "◯";
  margin-right: 10px;
  color: hsl(var(--accent));
  font-weight: 400;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.guest-limit {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: 6px 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--muted) / 0.6);
}

.language-menu-wrap {
  position: relative;
}

.language-menu-button {
  background: hsl(var(--muted) / 0.6);
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 6px 10px 6px 7px;
  min-height: 36px;
  min-width: 62px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-shadow: none;
}

.language-menu-current-icon,
.language-menu-item img {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px hsl(var(--border) / 0.55);
}

.language-menu-button:hover:not(:disabled),
.language-menu-wrap.is-open .language-menu-button {
  background: hsl(var(--secondary));
  box-shadow: var(--shadow-sm);
}

.language-menu-chevron {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.72;
  transition: transform 120ms ease;
}

.language-menu-wrap.is-open .language-menu-chevron {
  transform: translateY(2px) rotate(225deg);
}

.language-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: 74px;
  padding: 7px;
  background: hsl(var(--popover) / 0.98);
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: saturate(140%) blur(10px);
}

html[data-theme="dark"] .language-menu,
html[data-theme="dark-blue"] .language-menu {
  background: hsl(30 8% 16% / 0.98);
}

.language-menu-item {
  width: 100%;
  background: transparent;
  color: hsl(var(--foreground));
  border: none;
  border-radius: var(--radius);
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 12px 1fr;
  align-items: center;
  gap: 9px;
  justify-items: center;
  box-shadow: none;
}

.language-menu-item:hover:not(:disabled),
.language-menu-item[aria-checked="true"] {
  background: hsl(var(--secondary));
  transform: none;
  box-shadow: none;
}

.language-menu-mark {
  width: 10px;
  height: 6px;
  border-left: 2px solid hsl(var(--accent));
  border-bottom: 2px solid hsl(var(--accent));
  transform: rotate(-45deg);
  opacity: 0;
}

.language-menu-item[aria-checked="true"] .language-menu-mark {
  opacity: 1;
}

.theme-toggle {
  background: hsl(var(--muted) / 0.6);
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 6px 10px 6px 7px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: none;
}

.theme-toggle:hover:not(:disabled) {
  background: hsl(var(--secondary));
  box-shadow: var(--shadow-sm);
}

.theme-toggle-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px hsl(var(--border) / 0.55);
}

.theme-toggle-label {
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

button,
.form-card button[type="submit"],
#toggleGenerationButton {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: 1px solid hsl(var(--primary));
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: var(--tracking-normal);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, color 120ms ease;
  box-shadow: var(--shadow-sm);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.secondary-button {
  background: transparent;
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: none;
}

.secondary-button:hover:not(:disabled) {
  background: hsl(var(--secondary));
  border-color: hsl(var(--border));
}

.back-button {
  background: transparent;
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  box-shadow: none;
  margin-bottom: 24px;
}

.back-button::before {
  content: "←";
  margin-right: 8px;
}

.back-button:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

/* ==========================================================================
   Hero / Home
   ========================================================================== */

.hero {
  text-align: center;
  padding: 72px 20px 56px;
}

.badge {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: hsl(var(--accent));
  padding: 6px 14px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--card));
  margin-bottom: 24px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4.2vw, 3.25rem);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 auto 16px;
  max-width: 820px;
  color: hsl(var(--foreground));
  letter-spacing: 0.01em;
}

.hero p {
  font-size: 1.02rem;
  color: hsl(var(--muted-foreground));
  margin: 0 auto;
  max-width: 620px;
  line-height: 1.6;
}

/* Carousel */
.carousel-wrap {
  position: relative;
  overflow: hidden;
  margin: 24px 0 56px;
  padding: 12px 0;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
}

.carousel-track {
  display: flex;
  gap: 16px;
  width: max-content;
  animation: zen-scroll 70s linear infinite;
}

.carousel-track:hover {
  animation-play-state: paused;
}

@keyframes zen-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Scenario grid */
.gallery-section {
  margin-top: 16px;
}

.template-search-section {
  margin: 4px auto 32px;
  max-width: 720px;
}

.template-search-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-search-field span {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: hsl(var(--accent));
  font-weight: 500;
}

.template-search-field input {
  width: 100%;
  font: inherit;
  font-size: 0.98rem;
  color: hsl(var(--foreground));
  background: hsl(var(--card) / 0.88);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 13px 15px;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.template-search-field input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.14), var(--shadow-sm);
}

.gallery-section h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 20px;
  letter-spacing: 0.02em;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.scenario-card {
  position: relative;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 14px 14px 18px;
  text-align: left;
  color: hsl(var(--card-foreground));
  position: relative;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scenario-card:not(:disabled):hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: hsl(var(--accent) / 0.5);
}

.scenario-card.compact {
  flex: 0 0 240px;
  width: 240px;
}

.scenario-card h3 {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 700;
  margin: 0;
  color: hsl(var(--foreground));
  letter-spacing: 0.01em;
}

.scenario-card p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
}

.scenario-card:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.scenario-image {
  position: relative;
  aspect-ratio: 4 / 3;
  background: hsl(var(--muted));
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid hsl(var(--border));
}

.scenario-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease;
}

.scenario-card:hover .scenario-image img {
  transform: scale(1.04);
}

.scenario-image.is-missing img {
  display: none;
}

.scenario-image.is-missing::after {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--muted-foreground));
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  padding: 12px;
  text-align: center;
}

.soon {
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
}

/* ==========================================================================
   Generate view
   ========================================================================== */

.generate-layout {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 860px) {
  .generate-layout {
    grid-template-columns: 1fr;
  }
}

.scenario-preview-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scenario-preview-card h1 {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  margin: 0;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.scenario-preview-card p {
  margin: 0;
  color: hsl(var(--muted-foreground));
  line-height: 1.6;
  font-size: 0.95rem;
}

.scenario-icon.large {
  position: relative;
  aspect-ratio: 16 / 10;
  background: hsl(var(--muted));
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid hsl(var(--border));
}

.scenario-icon.large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scenario-icon.large.is-missing img {
  display: none;
}

.scenario-icon.large.is-missing::after {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--muted-foreground));
  font-family: var(--font-serif);
  font-size: 1.05rem;
}

/* Form card */
.form-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-card h2 {
  font-family: var(--font-serif);
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.section-label {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: hsl(var(--accent));
  font-weight: 500;
}

.knight-options {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  background: hsl(var(--muted) / 0.32);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-group > span {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

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

.segmented-options button {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: none;
  padding: 9px 10px;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.segmented-options button.is-active,
.segmented-options button:hover:not(:disabled) {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
  transform: none;
  box-shadow: var(--shadow-sm);
}

.color-options {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.color-options button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  padding: 0;
  background: var(--swatch);
  border: 2px solid hsl(var(--border));
  box-shadow: var(--shadow-sm);
}

.color-options button:hover:not(:disabled),
.color-options button.is-active {
  transform: translateY(-1px);
  border-color: hsl(var(--foreground));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18), var(--shadow-sm);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}

.field > span {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

.field input[type="email"],
.field input[type="password"],
.field input[type="text"],
.field select {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  padding: 10px 12px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field input:focus,
.field select:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.14);
}

.field select option {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
}

/* Dropzone */
.file-field {
  position: relative;
  border: 1.5px dashed hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  background: hsl(var(--muted) / 0.4);
  cursor: pointer;
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}

.file-field > span:first-child {
  position: absolute;
  top: 10px;
  left: 16px;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}

.file-field input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.dropzone-content strong {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  word-break: break-word;
  max-width: 100%;
}

.dropzone-content small {
  font-size: 0.82rem;
  color: hsl(var(--muted-foreground));
}

.file-field.is-dragging {
  border-color: hsl(var(--accent));
  background: hsl(var(--accent) / 0.08);
}

.file-field.has-file {
  border-style: solid;
  border-color: hsl(var(--accent) / 0.5);
  background: hsl(var(--card));
}

.status {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
  letter-spacing: var(--tracking-normal);
}

/* ==========================================================================
   Results
   ========================================================================== */

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 32px;
}

.result-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.generation-pending-card,
.generation-error-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.generation-skeleton {
  position: relative;
  aspect-ratio: 1 / 1;
  background:
    linear-gradient(110deg, transparent 0 35%, hsl(var(--foreground) / 0.1) 45%, transparent 55% 100%),
    repeating-linear-gradient(135deg, hsl(var(--muted) / 0.78) 0 12px, hsl(var(--muted) / 0.48) 12px 24px);
  background-size: 220% 100%, 100% 100%;
  animation: generation-shimmer 1.45s linear infinite;
}

@keyframes generation-shimmer {
  from { background-position: 220% 0, 0 0; }
  to { background-position: -40% 0, 0 0; }
}

.generation-pending-copy,
.generation-error-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.generation-pending-copy strong,
.generation-error-card strong {
  font-family: var(--font-serif);
  color: hsl(var(--foreground));
  font-size: 1rem;
}

.generation-pending-copy p,
.generation-error-card p {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.9rem;
  line-height: 1.5;
}

.generation-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.generation-steps span {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--muted) / 0.42);
  color: hsl(var(--muted-foreground));
  font-size: 0.72rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.generation-error-card {
  border-color: hsl(var(--destructive) / 0.5);
}

.generation-error-card strong {
  color: hsl(var(--destructive));
}

.result-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: hsl(var(--muted));
}

.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: 0.88rem;
  color: hsl(var(--muted-foreground));
  border-top: 1px solid hsl(var(--border));
}

.result-footer a {
  color: hsl(var(--accent));
  font-weight: 500;
  letter-spacing: 0.04em;
}

.result-footer a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Auth
   ========================================================================== */

.auth-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
  max-width: 860px;
  margin: 0 auto;
}

.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 11px 16px;
  font-weight: 500;
  font-size: 0.9rem;
  text-align: center;
  transition: background 120ms ease, transform 120ms ease;
}

.google-button::before {
  content: "G";
  font-family: var(--font-serif);
  font-weight: 700;
  color: hsl(var(--accent));
}

.google-button:hover {
  background: hsl(var(--secondary));
  transform: translateY(-1px);
}

.google-button.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

/* ==========================================================================
   Profile
   ========================================================================== */

.profile-layout {
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 960px;
  margin: 0 auto;
}

.profile-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.profile-card h1 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  margin: 0;
  font-weight: 700;
}

.profile-card > p {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.92rem;
}

.profile-limit {
  padding: 12px 14px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--muted) / 0.45);
  color: hsl(var(--foreground));
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
}

.history-placeholder {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.65);
}

.history-card.failed .history-placeholder {
  color: hsl(var(--destructive));
}

.favorite-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: hsl(var(--card) / 0.86);
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
  z-index: 2;
}

.favorite-mark.active {
  color: hsl(var(--accent));
}

.scenario-badge {
  align-self: flex-start;
  padding: 4px 9px;
  border-radius: 999px;
  background: hsl(var(--accent) / 0.14);
  color: hsl(var(--accent));
  border: 1px solid hsl(var(--accent) / 0.25);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.history-section .section-heading {
  margin-bottom: 20px;
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.section-heading h2,
.section-heading h1 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  margin: 0;
  font-weight: 700;
}

.section-heading > span {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: hsl(var(--accent));
  font-weight: 500;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.history-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.history-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.history-card img {
  width: 100%;
  height: 300px;
  object-fit: cover;
  cursor: zoom-in;
  background: hsl(var(--muted));
  transition: opacity 160ms ease;
}

.history-card img:hover {
  opacity: 0.92;
}

@media (max-width: 640px) {
  .history-card img {
    height: 240px;
  }
}

.history-card button {
  background: transparent;
  color: hsl(var(--destructive));
  border: none;
  border-top: 1px solid hsl(var(--border));
  border-radius: 0;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  box-shadow: none;
}

.history-card button:hover:not(:disabled) {
  background: hsl(var(--destructive) / 0.08);
  transform: none;
  box-shadow: none;
}

.empty-state {
  margin: 0;
  padding: 24px;
  text-align: center;
  color: hsl(var(--muted-foreground));
  border: 1px dashed hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--muted) / 0.4);
  grid-column: 1 / -1;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.image-modal,
.confirm-modal,
.error-modal {
  position: fixed;
  inset: 0;
  background: hsl(24 10% 10% / 0.72);
  backdrop-filter: blur(6px);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: zen-fade-in 160ms ease;
}

html[data-theme="dark"] .image-modal,
html[data-theme="dark"] .confirm-modal,
html[data-theme="dark"] .error-modal,
html[data-theme="dark-blue"] .image-modal,
html[data-theme="dark-blue"] .confirm-modal,
html[data-theme="dark-blue"] .error-modal {
  background: hsl(28 12% 5% / 0.78);
}

@keyframes zen-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.image-modal img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
  background: hsl(var(--card));
}

.modal-close,
.confirm-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  width: 40px;
  height: 40px;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.confirm-card {
  position: relative;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px 24px;
  max-width: 440px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.confirm-card h2 {
  font-family: var(--font-serif);
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.confirm-card p {
  margin: 0;
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
  font-size: 0.92rem;
}

.confirm-close {
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  box-shadow: none;
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: hsl(var(--muted-foreground));
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

#confirmLogoutButton {
  background: hsl(var(--destructive));
  border-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 600px) {
  .page {
    padding: 20px 16px 80px;
  }

  .topbar {
    padding: 12px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .brand-button {
    font-size: 1rem;
  }

  .hero {
    padding: 40px 8px 32px;
  }

  .scenario-card.compact {
    flex: 0 0 200px;
    width: 200px;
  }
}
