@font-face {
  font-family: 'Struve';
  src: url('/static/font/Struve-Light.otf') format('opentype');
  font-weight: 300;
  font-style: normal;
}
@font-face {
  font-family: 'Struve';
  src: url('/static/font/Struve-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'Struve';
  src: url('/static/font/Struve-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: 'Struve';
  src: url('/static/font/Struve-Semibold.otf') format('opentype');
  font-weight: 600;
  font-style: normal;
}
@font-face {
  font-family: 'Struve';
  src: url('/static/font/Struve-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
}

:root {
  --ink: #15130f;
  --ink-2: #2a251d;
  --ink-inverse: #fffaf3;
  --muted: #6f6961;
  --paper: #f6f1eb;
  --panel: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.56);
  --soft: #f5f2ee;
  --line: rgba(21, 19, 15, 0.11);
  --line-strong: rgba(21, 19, 15, 0.18);
  --orange: #ff6b2c;

  --control-height: 44px;
  --control-small-height: 34px;
  --control-radius: 13px;
  --control-font-size: 16px;
  --control-font-weight: 540;
  --control-pad-x: 18px;
  --control-border: rgba(21, 19, 15, 0.12);
  --control-border-hover: rgba(21, 19, 15, 0.22);
  --control-shadow: 0 1px 0 rgba(21, 19, 15, 0.04);

  --radius-panel: 26px;
  --radius-section: 20px;
  --radius-field: 14px;
  --radius-thumb: 10px;

  --shadow-panel: 0 18px 60px rgba(31, 25, 18, 0.055);
  --shadow-card: 0 12px 34px rgba(31, 25, 18, 0.055);
  --shadow-accent: 0 8px 24px rgba(255, 107, 44, 0.28);

  --modal-pad-x: 26px;
  --modal-pad-y: 24px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── Reset ── */

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Struve', sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; letter-spacing: 0; }

[hidden] { display: none !important; }

/* ── Buttons ── */

.btn {
  height: var(--control-height);
  min-height: var(--control-height);
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--control-radius);
  border: 1px solid transparent;
  padding: 0 var(--control-pad-x);
  font-size: var(--control-font-size);
  font-weight: var(--control-font-weight);
  line-height: 1;
  cursor: pointer;
  transition: transform 220ms var(--ease), background 220ms var(--ease), border-color 220ms var(--ease), color 220ms var(--ease);
}

.btn:hover { transform: translateY(-2px); }

.btn-secondary {
  border: 1px solid var(--control-border);
  background: var(--panel);
  color: rgba(21, 19, 15, 0.68);
  box-shadow: var(--control-shadow);
}

.btn-secondary:hover { border-color: var(--control-border-hover); color: var(--ink); }

.btn-primary {
  border-color: transparent;
  background: var(--ink);
  color: var(--ink-inverse);
}

.btn-primary:hover { background: var(--ink-2); }

.btn-small {
  height: var(--control-small-height);
  min-height: var(--control-small-height);
  border-radius: 999px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: var(--control-font-weight);
}

.btn-icon {
  width: var(--control-small-height);
  height: var(--control-small-height);
  min-height: var(--control-small-height);
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
}

.btn svg { flex: 0 0 auto; }

a.btn { text-decoration: none; }

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

/* ── Logo ── */

.wordmark {
  display: inline-flex;
  align-items: center;
  height: var(--control-height);
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: block;
  height: 80px;
  width: auto;
}

/* ════════════════════════════════════════
   Start page
   ════════════════════════════════════════ */

body.page-start {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 107, 44, 0.075), transparent 36%),
    var(--paper);
}

.shell {
  width: min(1460px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 22px clamp(18px, 3vw, 42px) 42px;
}

.shell .topbar {
  display: flex;
  justify-content: flex-start;
}

.shell main {
  display: grid;
  justify-items: center;
  align-items: start;
  padding-top: clamp(32px, 5vw, 64px);
}

.modal {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: rgba(255, 255, 255, 0.48);
  box-shadow: var(--shadow-panel);
  padding: var(--modal-pad-y) var(--modal-pad-x) 26px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  animation: modalIn 620ms var(--ease) forwards;
}

.modal-header {
  display: block;
  padding: 0 0 18px;
}

.modal-title { min-width: 0; }

.modal h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.08;
  font-weight: 760;
  letter-spacing: 0;
}

.modal-title p {
  margin: 7px 0 0;
  max-width: 380px;
  color: var(--muted);
  font-size: 14px;
}

.drop {
  position: relative;
  margin: 0;
  min-height: 286px;
  border: 1px dashed rgba(21, 19, 15, 0.18);
  border-radius: var(--radius-section);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.36)),
    var(--soft);
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 240ms var(--ease), background 240ms var(--ease), transform 240ms var(--ease);
}

.drop:hover,
.drop.is-hot {
  border-color: rgba(255, 107, 44, 0.72);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.42)),
    rgba(255, 107, 44, 0.055);
  transform: scale(0.997);
}

.drop-inner {
  display: grid;
  justify-items: center;
  gap: 16px;
  text-align: center;
  width: min(360px, 100%);
}

.image-stage {
  display: flex;
  justify-content: center;
  align-items: center;
}

.image-card {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.asset-thumb {
  width: 128px;
  height: 128px;
  object-fit: contain;
  display: block;
  rotate: -7deg;
}

.drop-copy strong {
  display: block;
  font-size: 22px;
  line-height: 1.16;
  font-weight: 700;
}

.drop-copy span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.browse {
  min-width: 140px;
}

.queue {
  display: none;
  padding: 12px 0 14px;
  gap: 10px;
}

.queue.has-files { display: grid; }

.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  padding: 0 2px;
}

.file-row {
  display: grid;
  grid-template-columns: 46px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  background: var(--panel-soft);
  opacity: 0;
  transform: translateY(8px);
  animation: rowIn 420ms var(--ease) forwards;
}

.thumb {
  width: 46px;
  height: 46px;
  border-radius: calc(var(--radius-thumb) - 2px);
  overflow: hidden;
  background: var(--soft);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-meta { min-width: 0; }

.file-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 570;
}

.progress {
  position: relative;
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(21, 19, 15, 0.08);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
  width: var(--progress);
  animation: fill 900ms var(--ease) both;
}

.status {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.modal-footer {
  display: none;
  justify-content: flex-end;
  padding: 0;
}

.modal-footer.is-visible { display: flex; }

/* ── Generate progress ── */

.btn-primary.is-generating {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 400ms var(--ease);
}

.generate-progress {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    max-height 560ms var(--ease),
    opacity 400ms var(--ease),
    margin-top 560ms var(--ease);
  margin-top: 0;
}

.generate-progress.is-visible {
  max-height: 52px;
  opacity: 1;
  margin-top: 18px;
}

.generate-track {
  height: 2px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.generate-fill {
  height: 100%;
  background: var(--orange);
  border-radius: inherit;
  width: 0%;
  transition: width 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.generate-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 32px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55));
  border-radius: inherit;
}

.generate-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
}

.generate-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
  animation: generatePulse 1.6s ease-in-out infinite;
}

.generate-label {
  font-size: 12px;
  color: var(--muted);
  transition: opacity 260ms var(--ease);
  letter-spacing: 0.01em;
}

.generate-label.is-fading { opacity: 0; }

@keyframes generatePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.28; transform: scale(0.6); }
}

@keyframes modalIn {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes rowIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fill {
  from { width: 18%; }
  to { width: var(--progress); }
}

@media (max-width: 560px) {
  .shell { padding-inline: 14px; }
  .modal { border-radius: 24px; padding: 20px 18px 18px; }
  .modal-header { padding: 0 0 16px; }
  .drop { min-height: 272px; }
  .modal-footer .btn { width: 100%; }
}

/* ════════════════════════════════════════
   Direction panel (moodboard page)
   ════════════════════════════════════════ */

/* Dark modifier — only color overrides, structure from .brief-panel */
.brief-panel.brief-panel--dark {
  background: var(--ink);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--ink-inverse);
}

.direction-badge {
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 250, 243, 0.55);
  margin-bottom: 14px;
}

.direction-name {
  margin: 0 0 10px;
  font-size: clamp(28px, 3.2vw, 42px);
  font-weight: 760;
  line-height: 1.08;
}

.direction-metaphor {
  margin: 0 0 22px;
  font-size: 15px;
  color: rgba(255, 250, 243, 0.55);
  max-width: 680px;
  line-height: 1.5;
}

/* Dark fields — same card structure as light panel, dark-themed colors */
.brief-panel.brief-panel--dark .read-field {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Dark color overrides for shared field typography */
.brief-panel.brief-panel--dark .read-field span { color: rgba(255, 250, 243, 0.38); }
.brief-panel.brief-panel--dark .read-field p    { color: rgba(255, 250, 243, 0.82); }

/* ════════════════════════════════════════
   Results page
   ════════════════════════════════════════ */

.app {
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: 22px clamp(18px, 3vw, 42px) 56px;
}

.app .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
}

.top-actions { display: flex; align-items: center; gap: 8px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin: 0 0 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brief-panel {
  margin: clamp(18px, 3vw, 34px) 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: rgba(255, 255, 255, 0.48);
  box-shadow: var(--shadow-panel);
  padding: clamp(18px, 2.2vw, 28px);
}

.brief-panel h1,
.page-head h1 {
  margin: 0;
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1;
  font-weight: 760;
}

.page-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.profile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.profile-panel { padding: 0; }

.profile-top strong {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

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

.read-field {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  background: var(--panel-soft);
  padding: 12px;
}

.read-field span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.read-field p {
  margin: 0;
  font-size: 14px;
  line-height: 1.42;
}

.profile-edit { display: grid; gap: 10px; }

.field { min-width: 0; }

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field textarea,
.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  font-size: 14px;
  outline: none;
  resize: none;
}

.field textarea:focus,
.field input:focus { border-color: var(--line-strong); }

.field textarea { min-height: 84px; }

.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}

.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 16px;
}

.tabs { display: flex; flex-wrap: wrap; gap: 2px; }

.tab {
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  background: transparent;
  color: rgba(21, 19, 15, 0.5);
  cursor: pointer;
  font-size: 13px;
}

.tab[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--control-shadow); }

.meta { color: rgba(21, 19, 15, 0.45); font-size: 13px; white-space: nowrap; }

.board {
  columns: 5 220px;
  column-gap: 14px;
}

.card {
  position: relative;
  break-inside: avoid;
  display: block;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  overflow: hidden;
  background: var(--soft);
  cursor: pointer;
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  animation: cardIn 620ms var(--ease) forwards;
  animation-delay: calc(var(--i) * 42ms);
  box-shadow: var(--shadow-card);
  will-change: opacity, transform;
}

.card img {
  width: 100%;
  display: block;
  filter: saturate(0.96) contrast(0.99);
  transition: transform 520ms var(--ease), filter 520ms var(--ease);
}

.card:hover img { transform: scale(1.035); filter: saturate(1.05) contrast(1.02); }

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 52%, rgba(0, 0, 0, 0.64));
  opacity: 0;
  transition: opacity 260ms var(--ease);
}

.card:hover::after { opacity: 1; }

.card-info {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-inverse);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 260ms var(--ease), transform 260ms var(--ease);
}

.card:hover .card-info { opacity: 1; transform: translateY(0); }

.card-info span {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
  font-size: 11px;
}

.side-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 40;
  width: min(500px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 90px rgba(21, 19, 15, 0.18);
  transform: translateX(102%);
  transition: transform 320ms var(--ease);
  display: grid;
  grid-template-rows: auto 1fr;
}

.side-panel.is-open { transform: translateX(0); }

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 560;
}

.breadcrumbs span:first-child { color: var(--ink); }

.side-body { overflow: auto; padding: 18px; }

.source {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.source-media {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-section);
  border: 1px solid var(--line);
  background: var(--soft);
}

.source-media img { width: 100%; display: block; }

.source-media::after,
.similar-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.48));
  pointer-events: none;
}

.source-badge {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 2;
  border-radius: 10px;
  padding: 8px 11px;
  background: rgba(21, 19, 15, 0.88);
  color: var(--ink-inverse);
  font-size: 12px;
  font-weight: 720;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.similar-title {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 22px 0 12px;
  color: rgba(21, 19, 15, 0.54);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.similar-title::before,
.similar-title::after {
  content: "";
  height: 1px;
  background: var(--line);
}

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

.similar-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  overflow: hidden;
  background: var(--soft);
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: transform 220ms var(--ease), border-color 220ms var(--ease);
}

.similar-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.similar-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.match-score {
  position: absolute;
  z-index: 2;
  bottom: 10px;
  left: 10px;
  border-radius: 9px;
  padding: 7px 9px;
  background: var(--orange);
  color: var(--ink-inverse);
  box-shadow: var(--shadow-accent);
  font-size: 12px;
  font-weight: 720;
  line-height: 1;
}

@keyframes cardIn { to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 900px) {
  .page-head { display: block; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-view { grid-template-columns: 1fr; }
  .filters { align-items: flex-start; flex-direction: column; }
  .meta { white-space: normal; }
}

@media (max-width: 620px) {
  .brand-logo { height: 65px; }
  .top-actions .btn-secondary { display: none; }
  .board { columns: 2 150px; column-gap: 10px; }
  .card { margin-bottom: 10px; }
  .side-panel { width: 100vw; }
}
