:root {
  color-scheme: light;
  --bg: #e8edf5;
  --surface: #fffefe;
  --surface-2: #f4f1ee;
  --text: #76685d;
  --heading: #847365;
  --muted: #a09186;
  --line: #d9d1ca;
  --accent: #d9b8b1;
  --accent-dark: #8a7668;
  --warm: #c9a989;
  --danger: #a96b68;
  --shadow: 0 18px 45px rgba(106, 91, 78, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
}

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
}

.auth-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card img {
  display: block;
  width: min(320px, 90%);
  margin: 0 auto 22px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-message {
  min-height: 1.5em;
  margin-bottom: 0;
  color: var(--danger);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 22px;
  background: #fffefe;
  color: var(--heading);
  border-right: 1px solid var(--line);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark__symbol {
  display: grid;
  place-items: center;
  width: 48px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: #f3e5e2;
  color: var(--heading);
  font-weight: 800;
  font-family: "Times New Roman", serif;
}

.eyebrow {
  margin: 0 0 5px;
  color: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0.68;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 2.5vw, 2.4rem);
  line-height: 1.15;
  color: var(--heading);
  font-style: italic;
  letter-spacing: 0.08em;
}

h3 {
  margin-bottom: 0;
  color: var(--heading);
  font-size: 1.08rem;
  font-style: italic;
  letter-spacing: 0.08em;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 44px;
  border: 0;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #f7efed;
  color: var(--heading);
}

.user-panel {
  display: grid;
  gap: 8px;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.user-panel button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.hero-view {
  display: grid;
  place-items: center;
  min-height: clamp(300px, 48vh, 560px);
  margin: -28px -28px 28px;
  padding: 32px 28px;
  background: #fffefe;
  border-bottom: 1px solid var(--line);
}

.hero-view img {
  display: block;
  width: min(760px, 88%);
  max-height: min(480px, 42vh);
  object-fit: contain;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar .eyebrow,
.section-heading .eyebrow,
.preview-toolbar .eyebrow {
  color: var(--muted);
}

.topbar-actions,
.preview-toolbar,
.prompt-box__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent-dark);
  color: #fff;
}

.secondary-button {
  background: var(--heading);
  color: #fff;
}

.ghost-button {
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(360px, 1fr) minmax(230px, 300px);
  gap: 18px;
  align-items: start;
}

.default-panel {
  max-width: 760px;
}

.saved-panel {
  max-width: 980px;
}

.control-panel,
.preview-stage,
.gallery-panel {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  display: grid;
  gap: 17px;
  padding: 18px;
}

.defaults-form {
  gap: 20px;
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-row {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 12px;
}

label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  padding: 11px 12px;
  background: #fffefe;
  color: var(--text);
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 184, 177, 0.26);
}

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

.segmented label,
.tile-options label {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fffefe;
  color: var(--text);
}

.segmented input,
.tile-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label:has(input:checked),
.tile-options label:has(input:checked) {
  border-color: var(--accent-dark);
  background: #f7efed;
}

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

.color-code-grid,
.brand-color-grid {
  display: grid;
  gap: 8px;
}

.color-code-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.brand-color-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.color-code-grid input,
.brand-color-grid input {
  min-width: 0;
  border-bottom: 5px solid var(--color-preview, var(--line));
  padding: 10px 8px;
  text-align: center;
  text-transform: uppercase;
}

.image-dropzone {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbf7f6;
  overflow: hidden;
  outline: 0;
}

.image-dropzone:focus,
.image-dropzone.is-dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 184, 177, 0.26);
}

.image-dropzone img {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  background: #fffefe;
}

.image-dropzone__empty {
  display: grid;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.image-dropzone__empty strong {
  color: var(--heading);
}

.image-dropzone__empty span {
  color: var(--muted);
  line-height: 1.7;
}

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

.image-actions input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  padding: 0 16px;
  background: #fffefe;
  color: var(--text);
  font-weight: 700;
}

.compact-button {
  min-height: 42px;
}

.preview-stage {
  min-width: 0;
  padding: 18px;
}

.canvas-wrap {
  width: 100%;
  margin: 18px 0;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 8px;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.prompt-box,
.appeal-box,
.generated-image-box,
.resume-box {
  border: 1px solid var(--line);
  background: #fffefe;
  border-radius: 8px;
  overflow: hidden;
}

.prompt-box__header {
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

#copyStatus {
  color: var(--accent-dark);
}

#promptOutput {
  border: 0;
  min-height: 156px;
}

.appeal-box {
  margin-top: 14px;
}

.generated-image-box,
.resume-box {
  margin-top: 14px;
}

.generated-image-box img {
  display: block;
  width: 100%;
  background: #fbf7f6;
}

.resume-box iframe {
  display: block;
  width: 100%;
  min-height: 520px;
  border: 0;
  background: #fff;
}

.appeal-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.appeal-item {
  border-left: 4px solid var(--accent);
  padding: 10px 12px;
  background: #fbf7f6;
}

.appeal-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--heading);
}

.appeal-item p {
  margin-bottom: 0;
  line-height: 1.7;
}

.gallery-panel {
  padding: 18px;
}

.section-heading {
  margin-bottom: 14px;
}

.gallery-grid {
  display: grid;
  gap: 12px;
}

.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.variation-card {
  border: 1px solid var(--line);
  background: #fffefe;
  border-radius: 8px;
  overflow: hidden;
}

.variation-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.variation-card__body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

.variation-card__body span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.variation-card__body button {
  border: 1px solid var(--line);
  background: transparent;
  padding: 6px 9px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
}

.saved-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fffefe;
}

.saved-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #fbf7f6;
}

.saved-card__body {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.saved-card__body strong {
  color: var(--heading);
}

.saved-card__body small {
  color: var(--muted);
}

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

  .sidebar {
    min-height: auto;
  }

  .layout-grid {
    grid-template-columns: 1fr 1fr;
  }

  .gallery-panel {
    grid-column: 1 / -1;
  }

  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .hero-view {
    min-height: 300px;
    margin: -18px -18px 22px;
    padding: 28px 18px;
  }

  .hero-view img {
    width: min(440px, 94%);
    max-height: 250px;
  }

  .topbar,
  .topbar-actions {
    display: grid;
  }

  .layout-grid,
  .field-row,
  .gallery-grid,
  .color-code-grid,
  .brand-color-grid {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}
