:root {
  --bg: #f6efe6;
  --bg-strong: #f1e4d6;
  --panel: rgba(255, 251, 247, 0.86);
  --panel-strong: #fffaf5;
  --text: #251713;
  --muted: #6d5550;
  --line: rgba(111, 76, 68, 0.16);
  --berry: #ab314f;
  --berry-deep: #7f1f39;
  --cocoa: #5b332a;
  --gold: #c38a45;
  --shadow: 0 18px 60px rgba(71, 32, 39, 0.14);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --sidebar: 304px;
  --max: 1240px;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(195, 138, 69, 0.2), transparent 28%),
    radial-gradient(circle at 10% 20%, rgba(171, 49, 79, 0.16), transparent 24%),
    linear-gradient(180deg, #f7f1ea 0%, #efe3d3 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background: transparent;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 100vh;
  padding: 1.5rem;
  background: rgba(83, 38, 40, 0.88);
  color: #fdf2eb;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(24px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, #f4c07b, #cc496d);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-copy strong {
  font-family: var(--serif);
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}

.brand-copy span {
  color: rgba(255, 244, 235, 0.76);
  font-size: 0.92rem;
}

.sidebar-nav {
  display: grid;
  gap: 0.45rem;
}

.sidebar-nav a,
.recent-item {
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 0.82rem 0.95rem;
  color: rgba(255, 245, 238, 0.84);
  transition: background 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active,
.recent-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
  transform: translateX(2px);
}

.sidebar-card,
.story-sidebar-card,
.chat-context-card {
  background: rgba(255, 248, 243, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.profile-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
}

.profile-card h3,
.story-sidebar-card h3,
.chat-context-card h3 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}

.profile-card p {
  margin: 0;
  color: rgba(255, 244, 235, 0.72);
}

.avatar-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(244, 192, 123, 0.95), rgba(195, 138, 69, 0.95));
  color: #43231c;
  font-weight: 700;
}

.avatar-badge.large {
  width: 70px;
  height: 70px;
  border-radius: 24px;
  font-size: 1.35rem;
}

.sidebar-recents {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 0;
}

.recent-list {
  display: grid;
  gap: 0.55rem;
}

.recent-item {
  display: flex;
  flex-direction: column;
  gap: 0.16rem;
}

.recent-item-type {
  text-transform: uppercase;
  font-size: 0.71rem;
  letter-spacing: 0.12em;
  color: rgba(255, 244, 235, 0.56);
}

.recent-item strong {
  color: #fff4ef;
}

.recent-item span:last-child {
  color: rgba(255, 244, 235, 0.68);
  font-size: 0.92rem;
}

.muted-copy {
  margin: 0;
  color: rgba(255, 245, 238, 0.72);
}

.app-main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 1.25rem 1.5rem 0;
  backdrop-filter: blur(12px);
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  max-width: 720px;
  padding: 0.75rem;
  margin: 0 auto;
  background: rgba(255, 250, 245, 0.84);
  border: 1px solid rgba(97, 58, 53, 0.12);
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(88, 44, 45, 0.12);
}

.search-form input,
.search-form button,
.authoring-form input,
.authoring-form textarea,
.composer textarea {
  border: none;
  background: transparent;
  color: var(--text);
}

.search-form input:focus,
.authoring-form input:focus,
.authoring-form textarea:focus,
.composer textarea:focus {
  outline: none;
}

.search-form button,
.button-primary,
.button-secondary,
.button-ghost {
  border-radius: 999px;
  border: none;
  padding: 0.82rem 1.2rem;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.search-form button,
.button-primary {
  background: linear-gradient(135deg, var(--berry), var(--berry-deep));
  color: #fff8f6;
  box-shadow: 0 10px 24px rgba(127, 31, 57, 0.26);
}

.search-form button:hover,
.button-primary:hover,
.button-secondary:hover,
.button-ghost:hover {
  transform: translateY(-1px);
}

.button-secondary,
.button-ghost {
  background: rgba(91, 51, 42, 0.08);
  color: var(--cocoa);
}

.button-ghost {
  padding-inline: 0.9rem;
}

.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.hero-panel,
.story-card,
.story-panel,
.profile-hero,
.error-panel,
.story-header,
.authoring-form,
.chat-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 1.6rem;
  padding: 2rem;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(244, 192, 123, 0.26), transparent 22%),
    radial-gradient(circle at bottom right, rgba(171, 49, 79, 0.18), transparent 34%),
    rgba(255, 250, 246, 0.86);
}

.hero-copy h1,
.story-header h1,
.page-intro h1,
.profile-hero h1,
.error-panel h1,
.chat-header h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 4.3rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
}

.hero-copy p,
.page-intro p,
.story-panel p,
.story-card p,
.profile-hero p,
.error-panel p,
.chat-context-card p,
.message-bubble,
.authoring-form label span,
.composer-footer p {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.6rem;
  color: var(--berry);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  font-weight: 700;
}

.hero-actions,
.metric-row,
.meta-line,
.tag-row,
.card-footer,
.section-heading.inline,
.composer-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.hero-actions {
  margin-top: 1.2rem;
}

.hero-metric-grid {
  display: grid;
  gap: 1rem;
}

.hero-metric-grid article {
  padding: 1.15rem 1.2rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 252, 248, 0.86);
  border: 1px solid rgba(111, 76, 68, 0.12);
}

.hero-metric-grid strong {
  display: block;
  font-size: 1.85rem;
  font-family: var(--serif);
}

.section-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 0.75rem;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 2.8vw, 2.25rem);
}

.section-heading p,
.section-heading a,
.text-link {
  margin: 0;
  color: var(--muted);
}

.card-grid,
.mini-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

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

.story-card,
.story-panel,
.story-sidebar-card,
.chat-context-card,
.authoring-form,
.profile-hero,
.error-panel {
  padding: 1.35rem;
}

.story-card h3,
.profile-hero h1,
.story-panel h2,
.story-sidebar-card h3,
.chat-header h1 {
  margin-top: 0;
}

.story-card h3 {
  margin-bottom: 0.35rem;
  font-family: var(--serif);
  font-size: 1.55rem;
}

.card-topline,
.story-tagline {
  color: var(--muted);
}

.story-tagline,
.tagline {
  font-size: 1.04rem;
}

.pill,
.tag-row span,
.tag-row a,
.suggestion-row span {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(171, 49, 79, 0.08);
  color: var(--berry-deep);
  font-size: 0.86rem;
}

.tag-row.large {
  gap: 0.85rem;
}

.card-footer {
  justify-content: space-between;
  margin-top: 1rem;
}

.mini-story-card,
.ranked-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 252, 248, 0.84);
  border: 1px solid rgba(111, 76, 68, 0.12);
  transition: transform 180ms ease, border-color 180ms ease;
}

.mini-story-card:hover,
.ranked-item:hover {
  transform: translateY(-1px);
  border-color: rgba(171, 49, 79, 0.22);
}

.mini-story-card {
  flex-direction: column;
}

.mini-story-card strong,
.ranked-item strong {
  font-family: var(--serif);
  font-size: 1.1rem;
}

.ranked-list {
  display: grid;
  gap: 0.75rem;
}

.spotlight-layout,
.story-layout,
.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.7fr);
  gap: 1rem;
}

.spotlight-profile {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.35rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 245, 0.86);
  border: 1px solid var(--line);
}

.story-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  padding: 1.5rem;
}

.story-layout {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(250px, 0.8fr);
}

.feature-list {
  margin: 0;
  padding-left: 1rem;
  color: var(--muted);
}

.chat-shell {
  padding: 1rem;
}

.chat-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 1rem;
  margin-bottom: 1rem;
}

.chat-layout {
  align-items: start;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 420px;
  padding: 0.5rem 0;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.message-user {
  align-items: flex-end;
}

.message-assistant {
  align-items: flex-start;
}

.message-label {
  font-size: 0.77rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.message-bubble {
  max-width: min(760px, 100%);
  padding: 1rem 1.15rem;
  border-radius: 18px;
  line-height: 1.6;
  white-space: pre-wrap;
  background: var(--panel-strong);
  border: 1px solid rgba(111, 76, 68, 0.12);
}

.message-user .message-bubble {
  background: linear-gradient(135deg, rgba(171, 49, 79, 0.12), rgba(195, 138, 69, 0.16));
}

.message.is-error .message-bubble {
  border-color: rgba(171, 49, 79, 0.35);
  background: rgba(171, 49, 79, 0.08);
}

.composer {
  position: sticky;
  bottom: 0;
  margin-top: 1rem;
  padding: 0.8rem 0 0;
  background: linear-gradient(180deg, transparent 0%, rgba(246, 239, 230, 0.92) 18%, rgba(246, 239, 230, 1) 100%);
}

.composer textarea {
  width: 100%;
  min-height: 118px;
  padding: 1rem 1.1rem;
  resize: vertical;
  background: rgba(255, 251, 247, 0.88);
  border: 1px solid rgba(111, 76, 68, 0.16);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 24px rgba(82, 45, 45, 0.08);
}

.composer-footer {
  justify-content: space-between;
  padding: 0.8rem 0.2rem 0;
}

.authoring-form {
  display: grid;
  gap: 1rem;
  max-width: 900px;
}

.authoring-form label {
  display: grid;
  gap: 0.45rem;
}

.authoring-form label span {
  font-size: 0.92rem;
  font-weight: 700;
}

.authoring-form input,
.authoring-form textarea {
  width: 100%;
  padding: 0.95rem 1rem;
  background: rgba(255, 251, 247, 0.9);
  border: 1px solid rgba(111, 76, 68, 0.14);
  border-radius: var(--radius-md);
}

.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.form-error {
  margin: 0;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(171, 49, 79, 0.08);
  color: var(--berry-deep);
}

.page-intro,
.profile-hero,
.error-panel {
  padding: 1.6rem;
}

.profile-hero,
.error-panel {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

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

.price {
  margin: 0.8rem 0 0.55rem;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.price small {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

.plan-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.plan-table th,
.plan-table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid rgba(111, 76, 68, 0.12);
  text-align: left;
}

.plan-table th {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.legal-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.legal-stack {
  display: grid;
  gap: 1rem;
}

.legal-list,
.feature-list {
  margin: 0;
  padding-left: 1rem;
}

.legal-list li,
.feature-list li {
  margin-bottom: 0.5rem;
}

.notice {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  background: rgba(195, 138, 69, 0.12);
  color: var(--cocoa);
}

.fine-print {
  margin-bottom: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.5rem 1.75rem;
}

.site-footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 245, 0.78);
  border: 1px solid rgba(111, 76, 68, 0.12);
  color: var(--muted);
  box-shadow: 0 12px 30px rgba(82, 45, 45, 0.08);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .sidebar {
    position: static;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .hero-panel,
  .spotlight-layout,
  .story-layout,
  .chat-layout,
  .chat-header,
  .legal-layout,
  .card-grid,
  .scene-grid,
  .mini-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page,
  .topbar {
    padding-inline: 1rem;
  }

  .search-form {
    grid-template-columns: 1fr;
    border-radius: 24px;
  }

  .story-header,
  .card-footer,
  .profile-hero,
  .error-panel,
  .site-footer-grid {
    flex-direction: column;
    align-items: stretch;
  }

  .site-footer {
    padding-inline: 1rem;
  }
}
