:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #20232b;
  background: #f3f6fa;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: linear-gradient(180deg, #f5f7fa 0%, #eef3f7 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button:focus-visible, input:focus-visible, #reference-input:focus-visible + .reference-picker {
  outline: 3px solid rgba(58, 116, 255, 0.32);
  outline-offset: 3px;
}

.topbar {
  height: 76px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 24px;
  background: rgba(248, 250, 252, 0.92);
  border-bottom: 1px solid #e6ebf1;
  backdrop-filter: blur(16px);
}

.window-dots { display: flex; gap: 16px; }
.window-dots span { width: 27px; height: 27px; border-radius: 50%; background: #ff5f3a; }
.window-dots span:nth-child(2) { background: #ffb20e; }
.window-dots span:nth-child(3) { background: #87d70d; }

.brand { display: flex; align-items: center; gap: 12px; font-size: 25px; font-weight: 720; letter-spacing: -0.03em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: white;
  background: linear-gradient(145deg, #93c5fd, #2159bc);
  border-radius: 11px;
  box-shadow: 0 5px 14px rgba(32, 88, 181, 0.22);
}

.account-actions { justify-self: end; display: flex; gap: 10px; }
.icon-button, .secondary-button {
  border: 1px solid #d9e1eb;
  border-radius: 999px;
  background: white;
  color: #263141;
  padding: 10px 16px;
  font-weight: 650;
}
.icon-button:hover, .secondary-button:hover { background: #f5f8fc; }

.studio-shell {
  display: grid;
  grid-template-columns: minmax(330px, 0.47fr) minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 76px);
  padding: 24px;
}

.control-panel, .canvas-panel {
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid #dce4ed;
  border-radius: 30px;
  box-shadow: 0 18px 50px rgba(68, 85, 105, 0.06);
}

.control-panel { padding: 30px; }
.canvas-panel { padding: 28px; display: flex; flex-direction: column; min-width: 0; }

.section-heading {
  display: flex;
  gap: 10px;
  color: #7d8aa0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 22px;
}
.style-heading { margin-top: 36px; }

.reference-card {
  position: relative;
  min-height: 220px;
  border: 1.5px dashed #cbd9ed;
  border-radius: 23px;
  overflow: hidden;
  background: #fbfdff;
}
#reference-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.reference-picker {
  display: flex;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 11px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
}
.reference-picker:hover { background: #f7faff; }
.reference-picker strong { font-size: 19px; }
.reference-picker span:last-child { color: #8190a8; font-size: 14px; }
.picker-plus {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  color: #2f74ef;
  background: #edf4ff;
  font-size: 36px;
  font-weight: 300;
}
.reference-preview-wrap { position: absolute; inset: 0; background: #eef3f8; }
.reference-preview-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.remove-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 25, 33, 0.85);
  color: white;
  padding: 9px 13px;
  font-weight: 650;
}

.style-list { display: grid; gap: 10px; }
.style-card {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 15px;
  padding: 12px;
  border: 1.5px solid transparent;
  border-radius: 19px;
  background: transparent;
  color: inherit;
  text-align: left;
}
.style-card:hover { background: #f6f8fb; }
.style-card[aria-pressed="true"] { border-color: #4c82ff; background: #edf3ff; }
.style-thumb {
  width: 64px;
  height: 64px;
  border: 1px solid rgba(41, 52, 68, 0.13);
  border-radius: 17px;
  position: relative;
  overflow: hidden;
  background: #efe6cf;
}
.style-thumb::before, .style-thumb::after { content: ""; position: absolute; }
.thumb-zine::before { width: 8px; height: 45px; background: #191c20; left: 22px; top: 10px; transform: rotate(-25deg); }
.thumb-zine::after { width: 24px; height: 24px; border-radius: 50%; background: #f45135; right: 8px; bottom: 8px; }
.thumb-abstract { background: linear-gradient(#9cb8c9 0 48%, #f0e5cd 48%); }
.thumb-abstract::before { width: 72px; height: 30px; left: -5px; bottom: 7px; background: #285768; transform: skewY(-12deg); }
.thumb-abstract::after { width: 38px; height: 22px; left: 10px; bottom: 6px; background: #d96642; border-radius: 50%; }
.thumb-sticker { background: #eee8d7; }
.thumb-sticker::before { width: 26px; height: 39px; background: #79a997; border-radius: 5px; left: 11px; top: 12px; }
.thumb-sticker::after { width: 14px; height: 14px; background: #d27b69; border-radius: 50%; right: 10px; bottom: 12px; box-shadow: 0 -20px #eaae45; }
.thumb-pin { background: linear-gradient(#92b2c0 0 50%, #143e3f 50%); }
.thumb-pin::after { width: 18px; height: 18px; border: 6px solid #e4bc49; border-radius: 50%; background: #e46044; left: 23px; bottom: 8px; }
.style-copy strong { display: block; margin-bottom: 5px; font-size: 16px; }
.style-copy span { display: block; color: #7f8da4; font-size: 13px; line-height: 1.45; }
.ai-badge { color: #71819b; background: #edf1f7; border-radius: 8px; padding: 7px 8px; font-size: 12px; }

.generate-button {
  width: 100%;
  margin-top: 26px;
  border: 0;
  border-radius: 16px;
  padding: 18px;
  background: #171a20;
  color: white;
  font-size: 20px;
}
.generate-button:hover:not(:disabled) { background: #292e38; }
.generate-button:disabled { opacity: 0.45; }
.privacy-note { color: #8390a4; font-size: 12px; line-height: 1.45; text-align: center; margin: 14px 18px 0; }

.canvas-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.eyebrow { margin: 0 0 5px; color: #8390a4; font-size: 12px; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.canvas-heading h1 { margin: 0; font-size: 22px; font-weight: 660; }
.status-message { margin-top: 16px; color: #6d7d94; font: 500 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.status-message[data-error="true"] { color: #b33131; }
.retention-note { margin: 7px 0 16px; color: #909bad; font-size: 12px; }

.artboard {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 580px;
  overflow: hidden;
  border-radius: 24px;
  background-color: #f7f9fc;
  background-image:
    linear-gradient(45deg, #edf1f6 25%, transparent 25%),
    linear-gradient(-45deg, #edf1f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf1f6 75%),
    linear-gradient(-45deg, transparent 75%, #edf1f6 75%);
  background-size: 32px 32px;
  background-position: 0 0, 0 16px, 16px -16px, -16px 0;
}
.empty-state, .loading-state { max-width: 550px; text-align: center; padding: 40px; }
.empty-state h2, .loading-state h2 { margin: 26px 0 9px; font-size: 25px; font-weight: 560; }
.empty-state p, .loading-state p { margin: 0; color: #8190a8; font-size: 17px; line-height: 1.55; }
.empty-illustration { position: relative; width: 110px; height: 85px; margin: 0 auto; }
.empty-illustration span { position: absolute; width: 72px; height: 72px; border: 4px solid white; border-radius: 14px; background: linear-gradient(145deg, #b4d7ed, #4d7d9a); transform: rotate(-11deg); left: 7px; top: 3px; box-shadow: 0 8px 18px rgba(44, 75, 98, 0.16); }
.empty-illustration span:last-child { left: 38px; top: 17px; transform: rotate(8deg); background: linear-gradient(145deg, #cbe6fa 45%, #3677ce 45%); }
.spinner { width: 52px; height: 52px; margin: 0 auto; border: 5px solid #d9e4f3; border-top-color: #3976ee; border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-image { display: block; max-width: 100%; max-height: calc(100vh - 260px); object-fit: contain; box-shadow: 0 18px 42px rgba(33, 40, 51, 0.15); }

[hidden] { display: none !important; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .window-dots { display: none; }
  .brand { justify-self: start; }
  .studio-shell { grid-template-columns: 1fr; }
  .artboard { min-height: 520px; }
}

@media (max-width: 600px) {
  .topbar { height: auto; min-height: 66px; padding: 10px 14px; }
  .brand { font-size: 19px; }
  .brand-mark { width: 34px; height: 34px; }
  .secondary-button, .icon-button { padding: 8px 11px; font-size: 12px; }
  .studio-shell { min-height: auto; padding: 10px; gap: 10px; }
  .control-panel, .canvas-panel { border-radius: 21px; padding: 20px; }
  .style-card { grid-template-columns: 54px 1fr auto; gap: 11px; padding: 8px; }
  .style-thumb { width: 54px; height: 54px; }
  .artboard { min-height: 420px; }
  .canvas-heading { align-items: stretch; flex-direction: column; }
  .canvas-actions button { width: 100%; }
  .result-image { max-height: 65vh; }
}

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