:root {
  --ink: #161412;
  --muted: #746f69;
  --soft: #a49b94;
  --paper: #ffffff;
  --canvas: #f4f2ef;
  --panel: #fbfaf8;
  --line: #e6e0da;
  --accent: #0d6f4f;
  --accent-dark: #064b37;
  --accent-soft: #e6f3ed;
  --rose: #d94c78;
  --rose-soft: #fff0f4;
  --shadow: 0 18px 46px rgba(27, 24, 21, 0.08);
  --tight-shadow: 0 10px 24px rgba(27, 24, 21, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
  background: var(--canvas);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 0;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: var(--canvas);
}

.sidebar,
.workspace {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 100vh;
  padding: 26px 20px;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: #fbfaf8;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(13, 111, 79, 0.22);
  border-radius: 50%;
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.92), transparent 30%),
    linear-gradient(145deg, var(--rose-soft), var(--accent-soft));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72), 0 8px 18px rgba(27, 24, 21, 0.08);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  fill: var(--rose);
}

.brand-icon circle {
  fill: var(--accent);
}

.brand-icon-smile {
  fill: none;
  stroke: var(--accent-dark);
  stroke-width: 4;
  stroke-linecap: round;
}

.brand-mark strong {
  font-size: 1.05rem;
}

.side-nav {
  display: grid;
  gap: 8px;
  margin-top: 44px;
}

.side-nav::before,
.sidebar-note::before {
  content: "Menu";
  margin: 0 0 8px 8px;
  color: var(--soft);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-nav a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 780;
  text-decoration: none;
}

.side-nav a.active,
.side-nav a:hover {
  color: var(--ink);
  background: var(--accent-soft);
}

.sidebar-note {
  display: grid;
  gap: 7px;
  margin-top: auto;
  padding: 14px;
  border-radius: 18px;
  color: #ffffff;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.14), rgba(255,255,255,0)),
    linear-gradient(135deg, #073725, #0d6f4f);
}

.sidebar-note::before {
  margin: 0;
  color: rgba(255, 255, 255, 0.64);
}

.sidebar-note strong {
  font-size: 0.98rem;
}

.sidebar-note span {
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.82rem;
  line-height: 1.35;
}

.workspace {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 100vh;
  padding: 18px 22px 30px;
}

.topbar,
.hero-panel,
.source-panel,
.ai-panel,
.results-section,
.compare-section,
.detail-panel {
  border: 1px solid rgba(230, 224, 218, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.search-field {
  position: relative;
  flex: 1 1 420px;
  max-width: 520px;
}

.search-field span {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
}

.search-field input {
  width: 100%;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fbfaf8;
  outline: none;
}

.search-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(13, 111, 79, 0.1);
}

.topbar-actions,
.generation-actions,
.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 28px 30px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 860;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  font-weight: 860;
  line-height: 0.95;
}

h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.15;
}

h3 {
  margin: 0;
  font-size: 1.12rem;
}

.hero-panel p {
  max-width: 690px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.48;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(88px, 1fr));
  gap: 10px;
  min-width: 330px;
}

.hero-metrics div {
  min-height: 92px;
  padding: 14px;
  border-radius: 18px;
  background: #fbfaf8;
  box-shadow: var(--tight-shadow);
}

.hero-metrics div:first-child {
  color: #ffffff;
  background: linear-gradient(135deg, #064b37, #16845f);
}

.hero-metrics strong {
  display: block;
  font-size: 1.55rem;
  line-height: 1;
}

.hero-metrics span {
  display: block;
  margin-top: 8px;
  color: inherit;
  font-size: 0.78rem;
  opacity: 0.72;
}

.control-deck {
  display: grid;
  grid-template-columns: minmax(320px, 0.58fr) minmax(0, 1fr);
  gap: 14px;
}

.source-panel,
.ai-panel,
.results-section,
.compare-section {
  padding: 16px;
}

.compare-section {
  max-width: 920px;
}

.panel-heading,
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}

.pill.muted {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.default-source-card {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 112px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfaf8;
}

.default-source-card img {
  width: 86px;
  height: 92px;
  border-radius: 14px;
  object-fit: cover;
}

.default-source-card strong,
.default-source-card span {
  display: block;
}

.default-source-card strong {
  font-size: 0.95rem;
}

.default-source-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 100px;
  padding: 14px;
  border: 1px dashed #cfc6bd;
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  background: #ffffff;
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 6px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  font-size: 1.4rem;
  line-height: 1;
}

.upload-zone strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.upload-zone small {
  max-width: 340px;
  margin-top: 5px;
  font-size: 0.78rem;
  line-height: 1.4;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field span,
.consent-row {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

.field input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fbfaf8;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(13, 111, 79, 0.1);
}

.consent-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 12px 0;
  line-height: 1.45;
}

.consent-row input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.primary-button,
.secondary-button,
.ghost-button,
.mode-button {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  font-weight: 850;
  font-size: 0.88rem;
}

.primary-button {
  padding: 0 16px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 12px 22px rgba(13, 111, 79, 0.18);
}

.secondary-button,
.ghost-button {
  padding: 0 16px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.ghost-button {
  color: var(--ink);
  background: #fbfaf8;
  border: 1px solid var(--line);
}

.progress-shell {
  overflow: hidden;
  height: 7px;
  margin-top: 12px;
  border-radius: 999px;
  background: #e9e4de;
}

.progress-shell span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #5fbf96, var(--rose));
  transition: width 240ms ease;
}

.status-message {
  min-height: 28px;
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.section-note {
  max-width: 470px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.results-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
}

.result-card {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  color: #ffffff;
  background: #eee8e3;
  box-shadow: var(--tight-shadow);
  vertical-align: top;
}

.result-card canvas,
.result-card img {
  display: block;
  width: 100%;
  height: 315px;
  object-fit: cover;
}

.result-card.active {
  outline: 4px solid rgba(13, 111, 79, 0.46);
  outline-offset: -4px;
}

.result-meta {
  position: absolute;
  left: 10px;
  right: 72px;
  bottom: 10px;
  display: grid;
  gap: 2px;
  padding: 8px 9px;
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  text-align: left;
  backdrop-filter: blur(12px);
}

.result-meta strong {
  overflow: hidden;
  font-size: 0.76rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-meta span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 760;
}

.result-save {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 56px;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: var(--rose);
  box-shadow: 0 10px 24px rgba(155, 49, 90, 0.25);
  font-weight: 950;
  font-size: 0.82rem;
}

.compare-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  width: min(320px, 100%);
  padding: 5px;
  border-radius: 999px;
  background: #eee9e3;
}

.mode-button {
  color: var(--muted);
  background: transparent;
}

.mode-button.active {
  color: #ffffff;
  background: var(--accent);
}

.compare-grid {
  display: grid;
  grid-template-columns: minmax(300px, 460px) minmax(250px, 320px);
  align-items: start;
  gap: 14px;
}

.canvas-frame {
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(45deg, rgba(13, 111, 79, 0.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(13, 111, 79, 0.06) 25%, transparent 25%),
    #fbfaf8;
  background-size: 28px 28px;
}

#previewCanvas {
  display: block;
  width: 100%;
  height: 440px;
  object-fit: cover;
}

.detail-panel {
  min-height: 100%;
  padding: 14px;
  box-shadow: none;
}

.detail-panel p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 14px;
}

.tag-list span {
  padding: 6px 8px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.72rem;
  font-weight: 850;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr;
}

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

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

  .side-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 20px;
  }

  .sidebar-note {
    margin-top: 18px;
  }

  .hero-panel,
  .control-deck,
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .hero-metrics {
    min-width: 0;
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
    margin: 0;
  }

  .workspace {
    padding: 10px;
  }

  .topbar,
  .panel-heading,
  .section-heading {
    display: block;
  }

  .topbar-actions,
  .generation-actions {
    display: grid;
    margin-top: 10px;
  }

  .engine-grid,
  .hero-metrics {
    grid-template-columns: 1fr;
  }

  .results-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .result-card canvas,
  .result-card img {
    height: 292px;
  }

  #previewCanvas {
    height: 360px;
  }
}

@media (max-width: 520px) {
  .side-nav,
  .results-board {
    grid-template-columns: 1fr;
  }

  .default-source-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .default-source-card img {
    width: 72px;
    height: 82px;
  }
}
