@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --canvas: #faf5eb;
  --canvas-end: #ffffff;
  --surface: #ffffff;
  --surface-quiet: #f5efeb;
  --heading: #0c2340;
  --text: #0f172a;
  --muted: #475569;
  --border: #7f8d9f;
  --border-soft: rgba(12, 35, 64, 0.16);
  --navy: #0c2340;
  --green: #0d5c3a;
  --green-soft: #e8f3ed;
  --focus: #a84d08;
  --danger: #9a3412;
  --on-brand: #ffffff;
  --shadow: 0 22px 58px -38px rgba(12, 35, 64, 0.58);
  --font-display: "Outfit", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #071421;
  --canvas-end: #0a1d30;
  --surface: #0c2340;
  --surface-quiet: #102a43;
  --heading: #f8fafc;
  --text: #f8fafc;
  --muted: #cbd5e1;
  --border: #8296aa;
  --border-soft: rgba(203, 213, 225, 0.22);
  --navy: #19476e;
  --green: #0f7047;
  --green-soft: #103a2d;
  --focus: #f0b26b;
  --danger: #ffb195;
  --on-brand: #ffffff;
  --shadow: 0 24px 62px -36px rgba(0, 0, 0, 0.92);
}

* { box-sizing: border-box; }
html { min-width: 0; scroll-behavior: smooth; }
body {
  min-width: 0;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 12%, rgba(13, 92, 58, 0.11), transparent 25rem),
    radial-gradient(circle at 94% 88%, rgba(12, 35, 64, 0.09), transparent 28rem),
    linear-gradient(155deg, var(--canvas), var(--canvas-end));
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button { touch-action: manipulation; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.skip-link {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 300;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  background: var(--heading);
  color: var(--on-brand);
  font-weight: 800;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.generator-shell {
  width: min(100% - 2rem, 1180px);
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.generator-main {
  width: min(100%, 1060px);
  flex: 1;
  margin: 0 auto;
  padding: clamp(2.4rem, 7vw, 5.4rem) 0 clamp(3rem, 7vw, 5.8rem);
}

.tool-hero { max-width: 760px; margin-bottom: clamp(1.8rem, 4vw, 3rem); }
.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
:root[data-theme="dark"] .eyebrow { color: #7ee2b8; }
h1, h2, h3 { color: var(--heading); font-family: var(--font-display); }
h1 {
  max-width: 16ch;
  margin: 0;
  font-size: clamp(2.45rem, 6vw, 4.8rem);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 0.98;
}
.intro { max-width: 650px; margin: 1.1rem 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.1rem); }
.local-note { display: inline-flex; align-items: center; gap: 0.45rem; margin: 1rem 0 0; color: var(--green); font-size: 0.84rem; font-weight: 700; }
.local-note svg { width: 18px; height: 18px; flex: 0 0 auto; }
:root[data-theme="dark"] .local-note { color: #7ee2b8; }

.generator-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  align-items: start;
  gap: clamp(1rem, 3vw, 1.75rem);
}
.placeholder-grid { display: grid; gap: clamp(1rem, 3vw, 1.75rem); }
.image-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  gap: clamp(1rem, 3vw, 1.75rem);
}

.panel {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  padding: clamp(1.2rem, 3.5vw, 2rem);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}
.panel-heading { margin-bottom: 1.35rem; }
.panel-heading h2 { margin: 0; font-size: clamp(1.35rem, 2.5vw, 1.75rem); line-height: 1.12; }
.panel-heading p { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.9rem; }
.panel-kicker { display: block; margin-bottom: 0.35rem; color: var(--green); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
:root[data-theme="dark"] .panel-kicker { color: #7ee2b8; }

.field-list, .field-row { display: grid; gap: 1rem; }
.field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label, legend { color: var(--text); font-size: 0.9rem; font-weight: 750; }
label { display: block; margin-bottom: 0.42rem; }
.field-help { margin: 0.42rem 0 0; color: var(--muted); font-size: 0.79rem; }
input[type="number"], input[type="text"], select, textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 0.72rem 0.82rem;
  background: var(--surface);
  color: var(--text);
}
textarea { min-height: 330px; resize: vertical; line-height: 1.62; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.88; }
input:focus, select:focus, textarea:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }

.check-field { min-height: 50px; display: flex; align-items: center; gap: 0.7rem; margin-top: 0.15rem; }
.check-field input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--green); }
.check-field label { margin: 0; cursor: pointer; }
.color-field { min-width: 0; }
.color-control { display: flex; align-items: center; gap: 0.65rem; }
input[type="color"] { width: 52px; height: 50px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 12px; padding: 0.25rem; background: var(--surface); cursor: pointer; }
.color-value { min-width: 0; overflow-wrap: anywhere; color: var(--muted); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.78rem; }

.button-row { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 1.2rem; }
.button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.72rem 1.1rem;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(1px); }
.button-primary { background: linear-gradient(135deg, var(--navy), var(--green)); color: var(--on-brand); box-shadow: 0 12px 24px -16px rgba(12, 35, 64, 0.72); }
.button-secondary { border-color: var(--border); background: var(--surface); color: var(--heading); }
.button-secondary:hover { background: var(--surface-quiet); }
.button svg { width: 19px; height: 19px; }

.output-panel { display: flex; flex-direction: column; }
.output-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.output-toolbar h2 { margin: 0; font-size: clamp(1.3rem, 2.4vw, 1.65rem); }
.output-count { flex: 0 0 auto; border-radius: 999px; padding: 0.32rem 0.62rem; background: var(--green-soft); color: var(--green); font-size: 0.75rem; font-weight: 800; }
:root[data-theme="dark"] .output-count { color: #9ee4c2; }
.output-text { flex: 1; background: var(--surface-quiet); }
.status { min-height: 1.45rem; margin: 0.7rem 0 0; color: var(--muted); font-size: 0.83rem; }
.status.is-error { color: var(--danger); font-weight: 700; }

.fake-output { min-height: 280px; }
.section-divider { height: 1px; margin: 0.3rem 0; border: 0; background: var(--border-soft); }
.image-preview-wrap { display: grid; align-content: center; min-height: 100%; }
.canvas-frame {
  width: 100%;
  min-height: 260px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 0.8rem;
  background:
    linear-gradient(45deg, var(--surface-quiet) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface-quiet) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-quiet) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface-quiet) 75%),
    var(--surface);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}
canvas { display: block; max-width: 100%; max-height: min(58vh, 520px); border-radius: 10px; box-shadow: 0 16px 34px -22px rgba(0, 0, 0, 0.52); }
.preview-caption { margin: 0.7rem 0 0; color: var(--muted); font-size: 0.8rem; text-align: center; }

.tool-switcher { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.2rem; }
.tool-switcher a { min-height: 44px; display: inline-flex; align-items: center; border: 1px solid var(--border-soft); border-radius: 999px; padding: 0.55rem 0.8rem; background: var(--surface); color: var(--heading); font-size: 0.82rem; font-weight: 700; text-decoration: none; }
.tool-switcher a[aria-current="page"] { border-color: transparent; background: var(--green-soft); color: var(--green); }
:root[data-theme="dark"] .tool-switcher a[aria-current="page"] { color: #9ee4c2; }

.app-footer { padding: 1.5rem 0 2.2rem; border-top: 1px solid var(--border-soft); color: var(--muted); font-size: 0.83rem; text-align: center; }
.app-footer p { margin: 0 0 0.35rem; }
.app-footer nav { line-height: 2; }
.app-footer a { color: var(--heading); font-weight: 700; text-underline-offset: 2px; }
.app-footer span { margin: 0 0.2rem; color: var(--border); }

@media (max-width: 820px) {
  .generator-grid, .image-workspace { grid-template-columns: 1fr; }
  .generator-main { width: min(100%, 680px); }
  textarea { min-height: 280px; }
}

@media (max-width: 560px) {
  .generator-shell { width: min(100% - 1.2rem, 1180px); }
  .generator-main { padding-top: 1.8rem; }
  .panel { border-radius: 18px; padding: 1rem; }
  .field-row { grid-template-columns: 1fr; }
  .button-row .button { width: 100%; }
  .output-toolbar { align-items: flex-start; flex-direction: column; gap: 0.5rem; }
  .canvas-frame { min-height: 210px; padding: 0.5rem; }
}

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