:root {
  --deep-navy: #0b263e;
  --editorial-navy: #123653;
  --warm-cream: #f3efe5;
  --old-paper: #e7dfd2;
  --muted-gold: #c3a062;
  --charcoal: #26303a;
  --soft-grey: #c9c4b8;
  --white: #ffffff;
  --line: rgba(38, 48, 58, 0.16);
  --shadow: 0 18px 60px rgba(11, 38, 62, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #ece7dc;
  color: var(--charcoal);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: 0;
}

.control-panel {
  min-height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(243, 239, 229, 0.92);
  overflow-y: auto;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  width: 124px;
  height: 34px;
  object-fit: contain;
  object-position: left center;
}

h1 {
  margin: 0;
  color: var(--deep-navy);
  font-size: 18px;
  line-height: 1.2;
}

p {
  margin: 4px 0 0;
  color: rgba(38, 48, 58, 0.7);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 18px;
}

.span-all {
  grid-column: 1 / -1;
}

.field,
.field-set {
  min-width: 0;
}

.field span,
.field-set legend {
  display: block;
  margin-bottom: 7px;
  color: rgba(38, 48, 58, 0.72);
  font-size: 12px;
  font-weight: 700;
}

textarea,
input[type="text"],
input:not([type]) {
  width: 100%;
}

textarea,
input {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--charcoal);
  outline: none;
  border-radius: 6px;
}

textarea {
  min-height: 210px;
  padding: 12px;
  resize: vertical;
  line-height: 1.7;
}

input {
  height: 40px;
  padding: 0 10px;
}

input[type="file"] {
  height: auto;
  padding: 10px;
}

textarea:focus,
input:focus {
  border-color: rgba(195, 160, 98, 0.8);
  box-shadow: 0 0 0 3px rgba(195, 160, 98, 0.18);
}

.field-set {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.36);
}

.field-set legend {
  padding: 0 4px;
}

.choice {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--deep-navy);
  font-size: 13px;
  font-weight: 700;
}

.choice input {
  width: 16px;
  height: 16px;
  accent-color: var(--deep-navy);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 10px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 4px;
}

button {
  height: 42px;
  border: 1px solid rgba(11, 38, 62, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--deep-navy);
  font-weight: 800;
  cursor: pointer;
}

button.primary {
  background: var(--deep-navy);
  color: var(--warm-cream);
}

button:hover {
  border-color: var(--muted-gold);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.preview-panel {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(38, 48, 58, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(38, 48, 58, 0.04) 1px, transparent 1px),
    #f6f2e9;
  background-size: 32px 32px;
}

.cover-mount {
  position: relative;
  width: min(78vh, calc(100vw - 500px));
  max-width: 760px;
  min-width: 320px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  background: var(--warm-cream);
}

.cover-mount.is-empty {
  border: 2px dashed rgba(11, 38, 62, 0.22);
  box-shadow: none;
}

.empty-result {
  color: rgba(38, 48, 58, 0.62);
  font-size: 16px;
  font-weight: 900;
  text-align: center;
}

.cover-mount.is-generating::after {
  content: "Generating...";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(11, 38, 62, 0.78);
  color: var(--warm-cream);
  font-size: 18px;
  font-weight: 900;
}

.cover-mount.has-error::after {
  content: attr(data-error);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(11, 38, 62, 0.86);
  color: var(--warm-cream);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
}

.status-row {
  width: min(78vh, calc(100vw - 500px));
  max-width: 760px;
  min-width: 320px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-top: 12px;
  color: rgba(38, 48, 58, 0.72);
  font-size: 12px;
  font-weight: 700;
}

.generated-cover {
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-panel {
    min-height: auto;
  }

  .cover-mount,
  .status-row {
    width: min(92vw, 720px);
  }
}

@media (max-width: 560px) {
  .control-panel,
  .preview-panel {
    padding: 16px;
  }

  .form-grid,
  .actions,
  .template-grid {
    grid-template-columns: 1fr;
  }
}
