:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #141416;
  --panel-soft: #1b1b1f;
  --border: #2c2c31;
  --text: #f5f5f5;
  --muted: #a7a7ad;
  --muted-2: #73737a;
  --accent: #e33b2f;
  --accent-hover: #f04b3f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(227, 59, 47, 0.12), transparent 34rem),
    linear-gradient(135deg, #070708, #111114);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

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

.workspace {
  padding: 56px clamp(28px, 6vw, 88px);
}

.hero {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 700px;
  font-size: clamp(42px, 6vw, 76px);
  line-height: 0.92;
  letter-spacing: -0.06em;
}

.intro {
  max-width: 640px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.generator-card,
.latest-result {
  max-width: 820px;
  margin-top: 36px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(20, 20, 22, 0.9);
  box-shadow: var(--shadow);
}

.generator-card label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.input-row {
  display: flex;
  gap: 12px;
}

input {
  flex: 1;
  min-width: 0;
  height: 56px;
  padding: 0 18px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #0d0d0f;
  outline: none;
}

input:focus {
  border-color: rgba(227, 59, 47, 0.85);
  box-shadow: 0 0 0 4px rgba(227, 59, 47, 0.14);
}

button {
  border: 0;
  cursor: pointer;
}

#generate-button {
  height: 56px;
  padding: 0 24px;
  border-radius: 18px;
  color: white;
  background: var(--accent);
  font-weight: 800;
}

#generate-button:hover {
  background: var(--accent-hover);
}

#generate-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.status {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--muted);
}

.status.error {
  color: #ff877e;
}

.latest-result h2 {
  margin: 0 0 18px;
  font-size: 20px;
}

.image-preview-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border-radius: 22px;
  background: var(--panel-soft);
}

.image-preview-button img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
}

.result-copy {
  margin-top: 18px;
}

.result-copy h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.result-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.history-panel {
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: 24px;
  border-left: 1px solid var(--border);
  background: rgba(12, 12, 14, 0.88);
  backdrop-filter: blur(22px);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.history-header h2 {
  margin: 0;
  font-size: 20px;
}

.history-header span {
  min-width: 30px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-empty {
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 22px;
  color: var(--muted-2);
  text-align: center;
}

.history-item {
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.history-item img {
  width: 98px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  background: #09090a;
}

.history-title {
  margin: 2px 0 6px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-desc {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(0, 0, 0, 0.86);
}

.modal-content {
  width: min(1200px, 100%);
}

.modal img {
  display: block;
  width: 100%;
  max-height: 74vh;
  border-radius: 24px;
  object-fit: contain;
  background: #080809;
  box-shadow: var(--shadow);
}

.modal-copy {
  margin-top: 18px;
}

.modal-copy h2 {
  margin: 0 0 8px;
}

.modal-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.close-modal {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  color: white;
  background: rgba(255, 255, 255, 0.14);
  font-size: 34px;
  line-height: 1;
}

.hidden {
  display: none !important;
}

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

  .history-panel {
    height: auto;
    min-height: 40vh;
    position: static;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .input-row {
    flex-direction: column;
  }

  #generate-button {
    width: 100%;
  }
}
