:root {
  --ink: #1f1a15;
  --paper: #f8f2e7;
  --paper-deep: #efe3cf;
  --accent: #b45f06;
  --accent-soft: #f2bb7c;
  --card: rgba(255, 251, 242, 0.82);
  --shadow: 0 18px 50px rgba(96, 57, 16, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #ffe2b8 0%, transparent 35%),
    radial-gradient(circle at 80% 80%, #f3cf97 0%, transparent 34%),
    linear-gradient(130deg, #fff8eb, #f5e6cd 55%, #eccc9c 100%);
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  filter: blur(30px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

.bg-shape-a {
  width: 260px;
  height: 260px;
  background: #ffd39a;
  top: -70px;
  left: -40px;
  border-radius: 45% 55% 66% 34% / 33% 45% 55% 67%;
}

.bg-shape-b {
  width: 300px;
  height: 300px;
  background: #f8b56f;
  right: -70px;
  bottom: -80px;
  border-radius: 60% 40% 54% 46% / 40% 62% 38% 60%;
}

.layout {
  position: relative;
  z-index: 1;
  width: min(940px, calc(100vw - 2rem));
  margin: 2rem auto;
  display: grid;
  gap: 1rem;
  animation: riseIn 0.7s ease both;
}

.hero {
  padding: 1.6rem 1.8rem;
  background: var(--card);
  border: 1px solid rgba(180, 95, 6, 0.18);
  border-radius: 20px;
  backdrop-filter: blur(5px);
  box-shadow: var(--shadow);
}

.kicker {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: #7d4310;
}

.hero h1 {
  margin: 0.5rem 0 0;
  font-family: 'Fraunces', serif;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  line-height: 1.1;
}

.subhead {
  margin: 0.8rem 0 0;
  max-width: 60ch;
  color: #4d3827;
}

.panel {
  background: var(--card);
  border: 1px solid rgba(180, 95, 6, 0.18);
  border-radius: 20px;
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  gap: 0.65rem;
}

label {
  font-weight: 700;
}

select,
textarea,
button {
  font: inherit;
  border-radius: 12px;
}

input {
  font: inherit;
  border-radius: 12px;
}

select,
textarea,
input {
  border: 1px solid #d8b48a;
  background: #fffdf8;
  color: var(--ink);
  padding: 0.7rem 0.8rem;
}

textarea:focus,
select:focus,
input:focus {
  outline: 2px solid #d98b3a;
  border-color: transparent;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.search-meta {
  margin: 0;
  font-size: 0.9rem;
  color: #6e4f35;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr 110px auto;
  gap: 0.5rem;
  align-items: center;
}

#adminLogOutput {
  margin: 0.7rem 0 0;
  white-space: pre-wrap;
  line-height: 1.4;
  font-size: 0.9rem;
  color: #2f2115;
  background: #fffaf2;
  border: 1px solid #ebd3b2;
  border-radius: 14px;
  padding: 0.8rem;
  max-height: 340px;
  overflow-y: auto;
}

button.ghost {
  background: #f1dfc7;
  color: #5b3b1f;
}

button {
  border: 0;
  padding: 0.8rem 1rem;
  font-weight: 800;
  background: linear-gradient(120deg, #bc650f, #e38a2e);
  color: #fff9ef;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(158, 88, 20, 0.35);
}

button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.response-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.response-head h2 {
  margin: 0;
  font-family: 'Fraunces', serif;
}

#storyBadge {
  font-size: 0.9rem;
  color: #6e4f35;
  background: #f6e4cb;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
}

#response {
  margin: 0.7rem 0 0;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 1rem;
  color: #332416;
}

#storyReadText {
  margin: 0.7rem 0 0;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 0.95rem;
  color: #2f2115;
  background: #fffaf2;
  border: 1px solid #ebd3b2;
  border-radius: 14px;
  padding: 0.8rem;
  max-height: 320px;
  overflow-y: auto;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .layout {
    width: min(940px, calc(100vw - 1rem));
    margin: 1rem auto;
  }

  .panel,
  .hero {
    border-radius: 16px;
    padding: 1rem;
  }

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

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

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