:root {
  --bg: #efe4d3;
  --panel: rgba(255, 250, 242, 0.78);
  --panel-strong: rgba(255, 248, 237, 0.95);
  --ink: #24170f;
  --muted: #6f5745;
  --line: rgba(64, 38, 20, 0.12);
  --accent: #b24c27;
  --accent-2: #1e4d41;
  --shadow: 0 20px 60px rgba(53, 24, 5, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(178, 76, 39, 0.18), transparent 30%),
    radial-gradient(circle at 85% 10%, rgba(30, 77, 65, 0.18), transparent 24%),
    linear-gradient(135deg, #f6efe4 0%, #ead8bd 45%, #e9e4db 100%);
}

body.reference-modal-open .page-shell,
body.image-modal-open .page-shell {
  pointer-events: none;
}

body.reference-modal-open .image-modal,
body.image-modal-open .image-modal {
  pointer-events: auto;
}

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

.page-shell {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  padding: 40px 24px 56px;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.02)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='%23634b38' fill-opacity='0.08'%3E%3Ccircle cx='26' cy='48' r='1'/%3E%3Ccircle cx='80' cy='18' r='1'/%3E%3Ccircle cx='108' cy='124' r='1'/%3E%3Ccircle cx='147' cy='86' r='1'/%3E%3Ccircle cx='60' cy='144' r='1'/%3E%3C/g%3E%3C/svg%3E");
}

.hero,
.workspace {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
}

.hero {
  display: block;
  margin-bottom: 28px;
}

.hero-copy h1 {
  margin: 10px 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.75rem, 3.2vw, 2.9rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.hero-text {
  max-width: 760px;
  margin: 18px 0 0;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--muted);
}

.hero-card,
.panel,
.result-card {
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 560px) minmax(320px, 1fr);
  gap: 24px;
}

.panel {
  border-radius: 32px;
  background: var(--panel);
  padding: 28px;
}

.panel-head h2 {
  margin: 10px 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 2.4rem;
  line-height: 1;
}

.control-form {
  margin-top: 26px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.field span {
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(54, 31, 17, 0.12);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.95);
  padding: 14px 16px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(178, 76, 39, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(178, 76, 39, 0.12);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 48px;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(36, 23, 15, 0.72) 50%),
    linear-gradient(135deg, rgba(36, 23, 15, 0.72) 50%, transparent 50%);
  background-position:
    calc(100% - 24px) calc(50% - 3px),
    calc(100% - 18px) calc(50% - 3px);
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
}

textarea {
  resize: none;
  min-height: 148px;
}

.prompt-shell {
  position: relative;
  border: 1px solid rgba(54, 31, 17, 0.12);
  border-radius: 24px;
  background: rgba(255, 252, 247, 0.95);
  overflow: hidden;
}

.prompt-shell textarea {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  min-height: 180px;
  padding: 18px 18px 10px;
}

.prompt-shell textarea:focus {
  transform: none;
  border-color: transparent;
  box-shadow: none;
}

.upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 16px 0;
}

.upload-divider {
  height: 1px;
  margin: 12px 16px 0;
  background: rgba(64, 38, 20, 0.1);
}

.upload-item {
  position: relative;
  display: inline-grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  max-width: 210px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: rgba(244, 235, 224, 0.78);
  border: 1px solid rgba(54, 31, 17, 0.08);
  transition: background 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
}

.upload-item:hover {
  background: rgba(232, 219, 203, 0.96);
  border-color: rgba(54, 31, 17, 0.14);
}

.upload-thumb {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}

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

.upload-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.2;
}

.upload-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(23, 20, 18, 0.92);
  box-shadow: 0 8px 18px rgba(20, 12, 8, 0.24);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.upload-item:hover .upload-remove {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.upload-remove:hover {
  transform: scale(1.06);
  background: rgba(0, 0, 0, 0.96);
}

.prompt-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 16px 16px;
  flex-wrap: wrap;
}

.toolbar-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(54, 31, 17, 0.1);
  background: rgba(244, 235, 224, 0.84);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.86rem;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.chip-icon {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(36, 23, 15, 0.08);
  color: rgba(36, 23, 15, 0.78);
  font-size: 0.7rem;
  line-height: 1;
}

.chip-icon-ratio {
  font-size: 0.62rem;
  letter-spacing: -0.08em;
}

.chip-select {
  padding-right: 16px;
}

.chip-select select {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-chip {
  cursor: pointer;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.toolbar-chip:hover {
  background: rgba(232, 219, 203, 0.96);
  border-color: rgba(54, 31, 17, 0.14);
}

.upload-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-chip.is-disabled {
  opacity: 0.45;
  background: rgba(220, 212, 203, 0.8);
  cursor: not-allowed;
}

.upload-chip.is-disabled input {
  pointer-events: none;
}

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

.primary-btn,
.ghost-btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.primary-btn {
  color: #fff8f1;
  background: linear-gradient(135deg, #9e3817, #c96333);
  box-shadow: 0 14px 28px rgba(170, 78, 33, 0.28);
}

.ghost-btn {
  color: var(--accent-2);
  background: rgba(30, 77, 65, 0.08);
}

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

.primary-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.waiting-card {
  margin-top: 26px;
  display: grid;
  gap: 18px;
  padding: 18px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 249, 240, 0.92), rgba(255, 250, 244, 0.74)),
    radial-gradient(circle at top left, rgba(178, 76, 39, 0.1), transparent 40%);
  border: 1px solid var(--line);
}

.waiting-frame {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 30% 30%, rgba(178, 76, 39, 0.2), transparent 24%),
    radial-gradient(circle at 70% 35%, rgba(30, 77, 65, 0.22), transparent 22%),
    radial-gradient(circle at 50% 80%, rgba(189, 133, 91, 0.18), transparent 18%),
    linear-gradient(135deg, rgba(244, 232, 213, 0.9), rgba(255, 248, 238, 0.65));
}

.waiting-glow {
  position: absolute;
  inset: -20%;
  background: linear-gradient(
    115deg,
    transparent 20%,
    rgba(255, 255, 255, 0.28) 35%,
    rgba(255, 255, 255, 0.56) 50%,
    rgba(255, 255, 255, 0.18) 65%,
    transparent 80%
  );
  transform: translateX(-60%) rotate(8deg);
  animation: shimmer 2.6s linear infinite;
}

.waiting-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
  mix-blend-mode: screen;
  animation: float 4.8s ease-in-out infinite;
}

.orb-a {
  width: 180px;
  height: 180px;
  left: 14%;
  top: 18%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 241, 228, 0.95), rgba(178, 76, 39, 0.18));
}

.orb-b {
  width: 210px;
  height: 210px;
  right: 12%;
  top: 10%;
  background: radial-gradient(circle at 35% 35%, rgba(231, 247, 241, 0.95), rgba(30, 77, 65, 0.18));
  animation-delay: -1.2s;
}

.orb-c {
  width: 260px;
  height: 260px;
  left: 36%;
  bottom: -6%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 247, 236, 0.96), rgba(194, 134, 90, 0.16));
  animation-delay: -2.3s;
}

.timer-card {
  display: inline-flex;
  align-items: baseline;
  gap: 14px;
  width: fit-content;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.76);
  border: 1px solid rgba(54, 31, 17, 0.08);
}

.timer-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.timer-card strong {
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: 0.02em;
}

.waiting-copy {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.waiting-copy strong {
  font-size: 1.15rem;
}

.waiting-copy p {
  margin: 0;
  max-width: 420px;
  color: var(--muted);
  line-height: 1.7;
}

.result-card {
  margin-top: 20px;
  border-radius: 28px;
  padding: 16px;
  background: var(--panel-strong);
}

.result-preview-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.result-card img {
  display: block;
  width: 100%;
  border-radius: 20px;
  max-height: 620px;
  object-fit: contain;
  background: rgba(86, 62, 44, 0.08);
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19, 12, 8, 0.62);
  backdrop-filter: blur(10px);
}

.image-modal-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 18px;
  width: min(92vw, 1040px);
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  padding: 18px;
  border-radius: 28px;
  background: rgba(255, 250, 242, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.image-modal-dialog-compact {
  width: min(88vw, 760px);
}

.image-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-modal-body {
  overflow: auto;
  border-radius: 22px;
  background: rgba(86, 62, 44, 0.06);
}

.image-modal-body img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 220px);
  object-fit: contain;
}

.image-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(30, 77, 65, 0.08);
  color: var(--accent-2);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(30, 24, 18, 0.9);
  color: #fff8f1;
  font-size: 0.95rem;
  box-shadow: 0 18px 34px rgba(18, 10, 6, 0.24);
}

.hidden {
  display: none;
}

@keyframes shimmer {
  0% {
    transform: translateX(-60%) rotate(8deg);
  }
  100% {
    transform: translateX(70%) rotate(8deg);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-14px) scale(1.03);
  }
}

@media (max-width: 960px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 20px 14px 36px;
  }

  .panel {
    padding: 20px;
    border-radius: 24px;
  }

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

  .waiting-copy,
  .image-modal-actions {
    grid-template-columns: 1fr;
    display: grid;
  }
}
