:root {
  color-scheme: dark;
  /* Color scheme matched to the moody foggy forest + moon image */
  --paper: #111a28;
  --paper-deep: #0c121c;
  --ink: #e8eef7;
  --muted: #8899b3;
  --rule: rgba(232, 238, 247, 0.12);
  --accent: #a8bdd9;
  --accent-soft: rgba(168, 189, 217, 0.12);
  --panel: rgba(14, 20, 32, 0.82);
  --panel-strong: rgba(10, 16, 26, 0.95);
  --field: rgba(8, 13, 22, 0.6);
  --shadow: rgba(0, 0, 0, 0.55);
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--sans);
  background-color: var(--paper-deep);
  /* Clean solid background so poems are easy to read.
     Subtle noise texture kept for atmosphere matching the image. */
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 4rem; /* less top padding now that hero banner is first */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Masthead */

.masthead {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
  animation: rise 0.7s var(--ease) both;
  /* Lighter shadow now that content sits on solid background */
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
}

.kicker {
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.85rem;
  opacity: 0.92;
}

.masthead h1 {
  font-family: var(--serif);
  font-size: clamp(2.5rem, 9vw, 3.75rem);
  font-weight: 400;
  margin: 0;
  letter-spacing: 0.02em;
  line-height: 1.05;
}

.masthead-ornament {
  width: 3rem;
  height: 1px;
  margin: 1.25rem auto;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  position: relative;
}

.masthead-ornament::before,
.masthead-ornament::after {
  content: "◆";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.45rem;
  color: var(--accent);
  line-height: 1;
}

.masthead-ornament::before { left: -0.65rem; }
.masthead-ornament::after { right: -0.65rem; }

.lede {
  max-width: 30rem;
  margin: 0 auto;
  color: var(--muted);
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.65;
}

.lede a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.lede a:hover {
  border-bottom-color: var(--accent);
}

/* Hero banner — the image now sits at the top (not full background)
   so the poems below are easy to read on a clean surface. */
.hero {
  margin: -0.5rem -1.5rem 2rem;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 14px 52px var(--shadow);
  border: 1px solid var(--rule);
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(12, 18, 28, 0.15) 0%, rgba(12, 18, 28, 0.45) 100%);
  pointer-events: none;
}

.hero-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 460px;
  object-fit: cover;
  object-position: 50% 35%; /* focus on moon and misty trees */
  filter: saturate(0.92) contrast(1.02);
}

/* Content navigation */

.content-nav,
.submissions-nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.content-tab {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.content-tab:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.content-tab.active {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.submissions-nav {
  margin-bottom: 1.25rem;
}

/* Search & Filter Bar */

.search-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

#catalog-search {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.92rem;
  box-shadow: 0 4px 16px var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#catalog-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.clear-search-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
}

.clear-search-btn:hover {
  color: var(--ink);
}

.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tag-pill {
  padding: 0.25rem 0.65rem;
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 12px;
  font-size: 0.76rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--sans);
}

.tag-pill:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.tag-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.stanza {
  white-space: pre-line;
  margin: 0 0 1.35rem;
}

.admin-breakdown {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.prose-body {
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.75;
}

.prose-paragraph {
  margin: 0 0 1.25rem;
  text-align: left;
}

.prose-paragraph:last-child {
  margin-bottom: 0;
}

/* Auth */

.auth-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 2.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: 0 8px 32px var(--shadow);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  animation: rise 0.7s var(--ease) 0.08s both;
}

.auth-bar.hidden { display: none; }

.auth-loading {
  margin: 0;
  padding: 0;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1.25rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: 0 4px 16px var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-google:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--shadow);
}

.google-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.auth-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.auth-user {
  text-align: center;
}

.auth-name {
  display: block;
  font-weight: 600;
  font-size: 1rem;
}

.auth-email {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.15rem;
}

.role-badge {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

.auth-actions a.btn-secondary {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

/* Site index (post-login page directory) */

.site-index {
  margin-bottom: 2.5rem;
  padding: 1.25rem 1.5rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: 0 8px 32px var(--shadow);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  animation: rise 0.7s var(--ease) 0.1s both;
}

.site-index.hidden { display: none; }

.site-index .panel-head {
  margin-bottom: 1rem;
}

.site-index-lede {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.75rem;
}

.site-index-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: inherit;
  text-decoration: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.site-index-card:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--rule));
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.site-index-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.site-index-card-blurb {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  padding: 0.6rem 1.1rem;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.btn-primary {
  background: color-mix(in srgb, var(--accent) 88%, white);
  color: var(--paper-deep);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent);
  border-color: var(--rule);
}

.btn-danger {
  background: transparent;
  color: #e8a0a0;
  border-color: color-mix(in srgb, #e8a0a0 30%, var(--rule));
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-danger:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

/* Editor */

.editor {
  margin-bottom: 2.5rem;
  padding: 1.5rem;
  background: var(--panel-strong);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: 0 8px 28px var(--shadow);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  animation: rise 0.4s var(--ease) both;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.editor-head h2 {
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 400;
  margin: 0;
}

.editor-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.editor-form {
  display: grid;
  gap: 1rem;
}

.editor-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.editor-form input,
.editor-form textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
}

.editor-form textarea {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.7;
  resize: vertical;
}

.editor-form input:focus,
.editor-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* Admin & submissions */

.admin-panel,
.submissions {
  margin-bottom: 2.5rem;
  padding: 1.5rem;
  background: var(--panel-strong);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: 0 8px 28px var(--shadow);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  animation: rise 0.4s var(--ease) both;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.panel-head h2 {
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 400;
  margin: 0;
}

.admin-stats {
  margin-bottom: 1.5rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.stat-card {
  padding: 1rem;
  text-align: center;
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.stat-card.stat-highlight {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--rule));
  background: var(--accent-soft);
}

.stat-num {
  display: block;
  font-family: var(--serif);
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-section {
  margin-top: 1.75rem;
}

.admin-section h3 {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 400;
  margin: 0 0 1rem;
}

.admin-list {
  display: grid;
  gap: 0.85rem;
}

.admin-empty {
  color: var(--muted);
  font-style: italic;
  margin: 0;
}

.admin-card {
  padding: 1rem 1.1rem;
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.admin-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.admin-card-head h4 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
}

.admin-card-meta {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.admin-card-excerpt {
  margin: 0 0 0.85rem;
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  line-height: 1.5;
}

.admin-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.status-badge {
  flex-shrink: 0;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pending {
  background: rgba(180, 130, 40, 0.15);
  color: #9a6b1a;
}

.status-published {
  background: rgba(40, 120, 70, 0.15);
  color: #2d6a4a;
}

.status-rejected {
  background: rgba(160, 50, 50, 0.12);
  color: #9a3333;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table th,
.admin-table td {
  padding: 0.65rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}

.admin-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

main { flex: 1; }

/* Catalog */

.catalog {
  display: grid;
  gap: 1rem;
  animation: rise 0.7s var(--ease) 0.1s both;
}

.poem-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1.35rem 1.5rem;
  cursor: pointer;
  box-shadow: 0 8px 28px var(--shadow);
  backdrop-filter: blur(14px) saturate(1.12);
  -webkit-backdrop-filter: blur(14px) saturate(1.12);
  transition:
    transform 0.25s var(--ease),
    border-color 0.25s ease,
    box-shadow 0.25s ease;
  color: inherit;
  font: inherit;
}

.poem-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--rule));
  box-shadow: 0 12px 32px var(--shadow);
}

.poem-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.poem-card h3 {
  font-family: var(--serif);
  font-size: 1.65rem;
  margin: 0 0 0.4rem;
  font-weight: 500;
  line-height: 1.2;
}

.poem-card .meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.85rem;
  letter-spacing: 0.02em;
}

.poem-card .excerpt {
  margin: 0;
  font-style: italic;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.55;
}

/* Poem view */

.hidden { display: none !important; }

.poem-view {
  animation: rise 0.5s var(--ease) both;
}

.back {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  margin: 0 0 2rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: opacity 0.15s ease;
}

.back:hover { opacity: 0.75; }

.poem-head {
  text-align: center;
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
}

.poem-date {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0 0 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.poem-title {
  font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 400;
  margin: 0;
  line-height: 1.15;
}

.poem-subtitle {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-style: italic;
  color: var(--muted);
  margin: 0.75rem 0 0;
  line-height: 1.4;
}

.poem-body {
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.8;
}

.stanza {
  margin: 0 0 1.75rem;
  white-space: pre-wrap;
  text-align: center;
}

.stanza:last-child { margin-bottom: 0; }

.poem-author {
  margin-top: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-style: italic;
}

.poem-tags {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  letter-spacing: 0.04em;
}

.poem-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* Companion */

.companion {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  animation: rise 0.7s var(--ease) 0.2s both;
}

.companion-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.85rem 1.25rem;
  box-shadow: 0 8px 24px var(--shadow);
  backdrop-filter: blur(14px) saturate(1.12);
  -webkit-backdrop-filter: blur(14px) saturate(1.12);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.companion-toggle:hover,
.companion-toggle[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--rule));
  box-shadow: 0 8px 24px var(--shadow);
}

.companion-toggle[aria-expanded="true"] {
  border-radius: 3px 3px 0 0;
  border-bottom-color: transparent;
  background: var(--panel);
}

.companion-toggle-icon {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.25s var(--ease);
}

.companion-toggle[aria-expanded="true"] .companion-toggle-icon {
  transform: rotate(-135deg) translateY(-2px);
}

.companion-panel {
  background: var(--panel-strong);
  border: 1px solid var(--rule);
  border-top: none;
  border-radius: 0 0 3px 3px;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: 0 8px 24px var(--shadow);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  animation: unfold 0.35s var(--ease) both;
}

.companion-head h2 {
  font-family: var(--serif);
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
  font-weight: 400;
}

.companion-head p {
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-weight: 300;
  font-size: 0.95rem;
  line-height: 1.55;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 1.25rem;
  padding-right: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.bubble {
  padding: 0.85rem 1.05rem;
  border-radius: 3px;
  max-width: 88%;
  font-size: 0.92rem;
  line-height: 1.6;
  animation: rise 0.35s var(--ease) both;
}

.bubble.user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 90%, white);
  color: var(--paper-deep);
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--field);
  border: 1px solid var(--rule);
}

.bubble .sources {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid color-mix(in srgb, currentColor 20%, transparent);
  font-size: 0.75rem;
  opacity: 0.85;
  font-style: italic;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

.chat-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 3rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-form button {
  padding: 0.75rem 1.35rem;
  background: color-mix(in srgb, var(--accent) 88%, white);
  color: var(--paper-deep);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-form button:hover:not(:disabled) {
  opacity: 0.88;
  transform: translateY(-1px);
}

.chat-form button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.chat-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.85rem 0 0;
  font-style: italic;
  line-height: 1.5;
}

/* Footer */

footer {
  margin-top: 4rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

.loading {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 2rem 0;
}

/* Animations */

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

@keyframes unfold {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */

@media (max-width: 540px) {
  .page {
    padding-top: 0.75rem;
  }

  .masthead {
    margin-bottom: 2.25rem;
    padding-bottom: 1.75rem;
  }

  .poem-card {
    padding: 1.15rem 1.2rem;
  }

  .poem-head {
    text-align: left;
  }

  .stanza {
    text-align: left;
  }

  .poem-body {
    font-size: 1.2rem;
  }

  .bubble {
    max-width: 95%;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-form button {
    width: 100%;
  }

  .auth-actions,
  .editor-actions,
  .poem-actions {
    flex-direction: column;
  }

  .auth-actions button,
  .auth-actions a.btn-secondary,
  .editor-actions button,
  .poem-actions button,
  .admin-card-actions button {
    width: 100%;
  }

  .site-index-grid {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .admin-table {
    display: block;
    overflow-x: auto;
  }

  .hero {
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    margin-bottom: 1.75rem;
  }

  .hero-image {
    max-height: 280px;
  }
}
