:root {
  color-scheme: light;
  --ink: #182727;
  --muted: #5a6866;
  --paper: #ffffff;
  --ground: #eef3f2;
  --line: #d5dfdc;
  --teal: #08796e;
  --teal-dark: #045e56;
  --coral: #d95d42;
  --amber: #edb745;
  --danger: #b23d32;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--ground);
  font-size: 16px;
  line-height: 1.45;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.site-header {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 26px;
  height: 26px;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
}

.brand-mark span { display: block; border-radius: 3px; background: var(--ink); }
.brand-mark span:first-child { background: var(--teal); }
.brand-mark span:nth-child(2) { background: var(--coral); }
.brand-mark span:nth-child(3) { grid-column: 1 / -1; background: var(--amber); }

.header-status {
  color: var(--muted);
  font-size: 13px;
}
.header-status[data-state="ready"] { color: var(--teal-dark); }
.header-status[data-state="error"] { color: var(--danger); }

.workspace {
  display: grid;
  min-height: calc(100vh - 64px);
  grid-template-columns: minmax(330px, 0.82fr) minmax(0, 1.18fr);
}

.composer, .gallery { padding: 42px clamp(24px, 4vw, 64px); }
.composer { border-right: 1px solid var(--line); background: var(--paper); }
.gallery { display: flex; min-width: 0; flex-direction: column; }

.section-heading { max-width: 480px; margin-bottom: 32px; }
.eyebrow { margin: 0 0 7px; color: var(--teal-dark); font-size: 12px; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: 0; line-height: 1.1; }
h1 { max-width: 420px; font-size: 34px; }
h2 { font-size: 24px; }

#generation-form { max-width: 500px; }
.field-label, legend { display: block; margin-bottom: 9px; color: var(--ink); font-size: 14px; font-weight: 700; }
textarea, .access-field input {
  width: 100%;
  border: 1px solid #bdccc8;
  border-radius: 6px;
  outline: none;
  background: #fbfdfd;
  color: var(--ink);
  padding: 14px;
  resize: vertical;
}
textarea:focus, .access-field input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8, 121, 110, 0.13); }
textarea::placeholder, .access-field input::placeholder { color: #80908d; }

.prompt-footer { display: flex; justify-content: space-between; min-height: 26px; align-items: center; color: var(--muted); font-size: 12px; }
.text-button { border: 0; background: transparent; color: var(--teal-dark); padding: 4px 0; }
.text-button:hover { color: var(--coral); }

.control-group { margin: 22px 0 0; border: 0; padding: 0; }
.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented-control label, .style-grid label { cursor: pointer; }
.segmented-control input, .style-grid input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8fbfa;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.segmented-control input:checked + span { border-color: var(--teal); background: #e3f1ee; color: var(--teal-dark); }
.segmented-control input:focus-visible + span, .style-grid input:focus-visible + span { outline: 3px solid rgba(8, 121, 110, 0.28); outline-offset: 2px; }

.style-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.style-grid span { display: block; min-height: 42px; border: 1px solid var(--line); border-radius: 5px; background: #f8fbfa; padding: 10px 11px; color: var(--muted); font-size: 13px; font-weight: 600; }
.style-grid input:checked + span { border-color: var(--coral); background: #fff0eb; color: #9b3e2a; }

.access-field { margin-top: 22px; }
.generate-button {
  display: inline-flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 28px;
  border: 0;
  border-radius: 5px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}
.generate-button:hover:not(:disabled) { background: var(--teal-dark); }
.generate-button:disabled { cursor: progress; opacity: 0.68; }
.button-spinner { display: none; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,0.45); border-top-color: #fff; border-radius: 50%; animation: spin 0.75s linear infinite; }
.generate-button[data-loading="true"] .button-spinner { display: block; }
.form-message { min-height: 22px; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.form-message[data-state="error"] { color: var(--danger); }
.form-message[data-state="success"] { color: var(--teal-dark); }

.gallery-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--muted); font-size: 22px; line-height: 1; }
.icon-button:hover:not(:disabled) { border-color: var(--coral); color: var(--coral); }
.icon-button:disabled { cursor: not-allowed; opacity: 0.45; }

.empty-state { display: grid; min-height: 420px; place-content: center; justify-items: center; gap: 20px; color: var(--muted); text-align: center; }
.empty-state[hidden] { display: none; }
.empty-state p { max-width: 250px; margin: 0; font-size: 14px; }
.empty-frame { position: relative; width: min(320px, 43vw); aspect-ratio: 1.2; overflow: hidden; border: 1px solid #bfcfca; border-radius: 6px; background: #dfe9e5; }
.empty-frame::before { position: absolute; inset: 0; background-image: linear-gradient(#c3d5cf 1px, transparent 1px), linear-gradient(90deg, #c3d5cf 1px, transparent 1px); background-size: 30px 30px; content: ""; opacity: 0.55; }
.frame-sun { position: absolute; top: 22%; right: 21%; width: 42px; height: 42px; border-radius: 50%; background: var(--amber); }
.frame-ridge { position: absolute; bottom: -6%; transform: rotate(-14deg); transform-origin: bottom left; }
.ridge-one { left: -10%; width: 75%; height: 56%; background: var(--teal); }
.ridge-two { right: -18%; width: 78%; height: 64%; background: var(--coral); transform: rotate(17deg); }

.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 34px; }
.result-card { overflow: hidden; border: 1px solid #ccd8d5; border-radius: 6px; background: #fff; }
.result-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #e1e9e7; }
.result-card[data-aspect="landscape"] img { aspect-ratio: 1.5; }
.result-card[data-aspect="portrait"] img { aspect-ratio: 0.667; }
.result-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 11px; }
.result-meta time { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.download-link { color: var(--teal-dark); font-size: 12px; font-weight: 700; text-decoration: none; }
.download-link:hover { color: var(--coral); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 780px) {
  .site-header { min-height: 58px; padding: 0 20px; }
  .workspace { display: block; min-height: auto; }
  .composer { border-right: 0; border-bottom: 1px solid var(--line); }
  .composer, .gallery { padding: 30px 20px; }
  h1 { font-size: 30px; }
  .empty-state { min-height: 270px; }
  .empty-frame { width: min(270px, 78vw); }
}

@media (max-width: 420px) {
  .header-status { max-width: 112px; text-align: right; }
  .segmented-control { gap: 4px; }
  .segmented-control span { padding: 4px; font-size: 12px; }
  .style-grid { grid-template-columns: 1fr; }
}

