:root {
  --bg: #eef3f8;
  --bg-soft: #f8fbfe;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --surface-muted: #eef4f9;
  --text: #141c24;
  --muted: #647285;
  --muted-strong: #435165;
  --line: rgba(20, 28, 36, 0.08);
  --line-strong: rgba(20, 28, 36, 0.14);
  --accent: #1f4fd6;
  --accent-strong: #173da8;
  --accent-text: #ffffff;
  --success: #0e8a62;
  --success-bg: rgba(14, 138, 98, 0.12);
  --warn: #9a6a16;
  --warn-bg: rgba(154, 106, 22, 0.12);
  --danger: #b12c3f;
  --danger-bg: #fff0f3;
  --shadow: 0 24px 60px rgba(28, 45, 74, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(70, 121, 255, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(72, 206, 176, 0.1), transparent 24%),
    linear-gradient(180deg, #f9fbfd 0%, var(--bg) 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 14px 36px;
}

.app-header,
.surface {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.app-header {
  border-radius: 28px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent) 0%, #37b6d9 100%);
  color: var(--accent-text);
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 12px 24px rgba(31, 79, 214, 0.22);
}

.brand-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  max-width: 360px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.language-switch,
.segmented-control {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
}

.language-button,
.segment {
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--muted-strong);
  border-radius: 999px;
  padding: 9px 13px;
  font-weight: 700;
  font-size: 13px;
}

.language-button.active,
.segment.is-active {
  background: var(--accent);
  color: var(--accent-text);
}

.header-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted-strong);
  font-weight: 700;
  font-size: 14px;
}

.nav-link.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.generation-panel {
  display: none;
}

.generation-panel.is-active {
  display: block;
}

.hero-panel,
.section-panel,
.blocked-screen {
  border-radius: 30px;
  padding: 26px;
  margin-bottom: 18px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.8fr);
  gap: 18px;
}

.hero-side-card,
.inset-panel,
.aside-panel,
.info-tile {
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.hero-side-card {
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(245, 249, 253, 0.94) 100%);
}

.hero-side-copy,
.aside-copy {
  margin: 0;
  color: var(--muted-strong);
  line-height: 1.6;
}

.eyebrow,
.mini-label {
  margin: 0 0 10px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mini-label {
  color: var(--muted);
}

.hero-title {
  margin: 0 0 14px;
  max-width: 700px;
  font-size: clamp(34px, 5vw, 50px);
  line-height: 0.98;
  letter-spacing: -0.05em;
}

h2,
h3 {
  margin: 0 0 10px;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 28px;
}

h3 {
  font-size: 22px;
}

.hero-copy,
.section-copy,
.helper-copy,
.empty-state p,
.status-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.58;
}

.hero-actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 16px;
  padding: 12px 18px;
  border: 0;
  font-weight: 800;
}

.button-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.84);
  color: #1b2733;
  border: 1px solid var(--line);
}

.button-secondary span,
.upload-trigger span {
  color: #1b2733;
}

.button-compact {
  min-height: 40px;
  padding: 9px 14px;
}

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

.loading-copy {
  color: var(--muted);
}

.message {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid var(--line);
  background: rgba(38, 47, 57, 0.06);
  color: var(--muted-strong);
}

.message-error {
  background: var(--danger-bg);
  border-color: rgba(146, 35, 35, 0.16);
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.panel-grid {
  display: grid;
  gap: 16px;
}

.panel-grid-photo {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.34fr);
}

.panel-grid-text {
  grid-template-columns: minmax(0, 1fr);
}

.inset-panel,
.aside-panel {
  padding: 20px;
}

.upload-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.upload-trigger {
  position: relative;
  overflow: hidden;
}

.upload-trigger input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.file-name {
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 600;
}

.photo-preview {
  min-height: 280px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  background:
    linear-gradient(180deg, #ffffff 0%, #eef4fa 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-preview.is-empty {
  padding: 0;
}

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

.empty-preview strong,
.empty-state strong {
  display: block;
  margin-bottom: 6px;
}

.field-group {
  margin-top: 18px;
}

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

.field-label {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
  font-size: 14px;
  color: #1b2733;
}

textarea,
.select-field {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.96);
  color: #17212b;
  caret-color: #17212b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

textarea {
  min-height: 120px;
  resize: vertical;
  padding: 14px 15px;
  font-weight: 500;
  line-height: 1.55;
}

.select-field {
  min-height: 48px;
  padding: 0 14px;
}

textarea::placeholder,
.select-field::placeholder {
  color: #6b7785;
  opacity: 1;
}

.helper-copy {
  color: #5b6776;
  font-size: 13px;
}

.choice-grid,
.selection-grid,
.results-grid,
.history-list {
  display: grid;
  gap: 12px;
}

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

.choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-card-ui,
.selection-card {
  display: block;
  width: 100%;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.choice-card-ui {
  padding: 16px;
}

.choice-card input:checked + .choice-card-ui {
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: var(--accent-text);
  box-shadow: 0 16px 28px rgba(38, 47, 57, 0.18);
}

.choice-card input:checked + .choice-card-ui .choice-copy {
  color: rgba(255, 255, 255, 0.78);
}

.choice-title,
.selection-card-title {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
}

.choice-copy,
.selection-card-copy {
  display: block;
  color: var(--muted);
  line-height: 1.55;
}

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

.selection-card {
  padding: 18px;
  text-align: left;
  min-height: 140px;
}

.selection-card.is-selected {
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: var(--accent-text);
  box-shadow: 0 18px 30px rgba(38, 47, 57, 0.18);
}

.selection-card.is-selected .selection-card-copy {
  color: rgba(255, 255, 255, 0.78);
}

.info-tile {
  min-height: 100%;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(242, 248, 253, 0.96) 100%);
}

.info-tile strong {
  display: block;
  margin-bottom: 8px;
  line-height: 1.4;
}

.status-panel {
  margin-bottom: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  padding: 18px;
  max-width: 520px;
}

.status-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.status-copy {
  max-width: 44ch;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(38, 47, 57, 0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.status-badge.is-success {
  background: var(--success-bg);
  color: var(--success);
}

.status-badge.is-warning {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-badge.is-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

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

.result-card,
.history-card {
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  overflow: hidden;
}

.result-card {
  position: relative;
}

.result-card.is-selected {
  border-color: rgba(31, 107, 74, 0.34);
  box-shadow: inset 0 0 0 2px rgba(31, 107, 74, 0.18);
}

.result-selected {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  min-height: 30px;
  border-radius: 999px;
  background: rgba(31, 107, 74, 0.96);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.result-preview {
  width: 100%;
  display: block;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
}

.result-preview img {
  width: 100%;
  aspect-ratio: 5 / 6;
  object-fit: cover;
  display: block;
  background: #edf3f9;
}

.result-body {
  padding: 14px 16px 16px;
}

.result-title {
  margin: 0;
  font-size: 18px;
}

.result-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  min-height: 48px;
}

.result-actions {
  display: flex;
  gap: 10px;
  padding: 0 16px 16px;
}

.history-list {
  margin-top: 10px;
}

.history-list.compact {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.history-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.history-list.compact .history-card {
  grid-template-columns: 1fr;
}

.history-thumb,
.history-thumb-empty {
  width: 92px;
  height: 92px;
  border-radius: 18px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #edf3f9;
}

.history-list.compact .history-thumb,
.history-list.compact .history-thumb-empty {
  width: 100%;
  height: 164px;
}

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

.history-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
}

.history-content {
  min-width: 0;
}

.history-meta,
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-meta {
  margin-bottom: 10px;
}

.history-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(38, 47, 57, 0.06);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
}

.history-title {
  margin: 0 0 8px;
  font-size: 18px;
}

.history-summary {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

.empty-state {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

body.preview-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(16, 21, 27, 0.76);
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  width: min(980px, 100%);
  max-height: 100%;
  overflow: auto;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 252, 247, 0.98);
  padding: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.32);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-image {
  width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
  border-radius: 20px;
  display: block;
  background: #edf3f9;
}

.app-shell.access-denied #app-main,
.app-shell.access-denied .header-nav {
  display: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(38, 47, 57, 0.26);
  outline-offset: 2px;
}

@media (max-width: 880px) {
  .hero-panel,
  .panel-grid-photo,
  .field-row,
  .selection-grid,
  .choice-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px 12px 28px;
  }

  .app-header,
  .hero-panel,
  .section-panel,
  .blocked-screen {
    padding: 18px;
    border-radius: 24px;
  }

  .hero-title {
    font-size: clamp(30px, 10vw, 40px);
  }

  h2 {
    font-size: 24px;
  }

  .header-nav {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .nav-link,
  .segment,
  .language-button,
  .button {
    white-space: nowrap;
  }

  .hero-actions,
  .action-row,
  .result-actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .history-card {
    grid-template-columns: 1fr;
  }

  .history-thumb,
  .history-thumb-empty {
    width: 100%;
    height: 172px;
  }

  .photo-preview {
    min-height: 210px;
  }

  .hero-side-card {
    padding: 16px;
  }

  .modal-card {
    padding: 16px;
    border-radius: 22px;
  }

  .modal-head {
    flex-direction: column;
  }

  .modal-image {
    max-height: calc(100vh - 240px);
  }
}
