@font-face {
  font-family: 'Cabinet Grotesk';
  src: url('fonts/CabinetGrotesk-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cabinet Grotesk';
  src: url('fonts/CabinetGrotesk-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cabinet Grotesk';
  src: url('fonts/CabinetGrotesk-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #3a3a3a;
  --bg-alt: #2f2f2f;
  --text: #ffffff;
  --text-muted: #a0a0a0;
  --accent: #e91e8c;
  --accent-hover: #f0309a;
  --input-bg: #4a4a4a;
  --input-border: #5a5a5a;
}

body {
  font-family: 'Cabinet Grotesk', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2.5rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: transparent;
}

header .logo {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text);
  text-decoration: none;
}

nav {
  display: flex;
  gap: 2rem;
}

nav a {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

nav a:hover {
  color: var(--text);
}

/* Hero / Home */
#home-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.hero {
  text-align: center;
  width: min(1100px, 100%);
}

.hero h1 {
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-weight: 400;
}

.hero-content {
  width: min(760px, 100%);
  margin: 0 auto;
}

.word-form {
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-form {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
}

.upload-card {
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 16px;
  background: var(--bg);
  padding: 1rem;
}

.poem-textarea-wrap {
  position: relative;
}

.poem-highlight {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  pointer-events: none;
}

.poem-highlight .seed-word {
  color: var(--accent);
  font-weight: 700;
}

.instructions-trigger {
  position: absolute;
  top: 0.55rem;
  right: 0.6rem;
  z-index: 5;
  border: none;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  padding: 0.28rem 0.65rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.instructions-trigger:hover,
.instructions-trigger[aria-expanded='true'] {
  color: var(--text);
  background: var(--bg-alt);
}

.inline-instructions {
  position: absolute;
  inset: 0;
  z-index: 4;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: rgba(47, 47, 47, 0.94);
  color: #d7d7d7;
  padding: 2.25rem 4rem 0.9rem 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  overflow: auto;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.poem-textarea-wrap:not(:focus-within) .instructions-trigger:hover + .inline-instructions {
  opacity: 1;
  transform: translateY(0);
}

.inline-instructions-title {
  color: var(--text-muted);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.inline-instructions p {
  margin-bottom: 0.35rem;
}

.inline-instructions ul {
  list-style: disc;
  padding-left: 1rem;
}

.poem-textarea {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.7;
  padding: 0.9rem 1rem;
}

.poem-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.poem-textarea::placeholder {
  color: var(--text-muted);
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.9rem;
}

.upload-status {
  margin-top: 0.7rem;
  min-height: 1.4rem;
  font-size: 0.9rem;
  color: #94d3a2;
}

.upload-status.error {
  color: #ff9da4;
}

.pill-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  background: var(--input-bg);
  padding: 0.35rem 0.35rem 0.35rem 1.4rem;
  transition: border-color 0.2s, background 0.2s;
}

.pill-box:focus-within {
  border-color: var(--accent);
  background: var(--bg-alt);
}

.word-form input {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 0;
  border: none;
  background: transparent;
  color: var(--text);
  min-width: 140px;
  flex: 1;
}

.word-form input::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

.word-form input:focus {
  outline: none;
}

.btn-begin {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-begin:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-begin:active {
  transform: translateY(0);
}

@media (max-width: 768px) {
  header {
    padding: 1rem 1rem;
  }

  nav {
    gap: 1.1rem;
  }

  #home-view {
    align-items: flex-start;
    padding: 5.25rem 0.85rem 1.1rem;
  }

  .hero {
    width: 100%;
    max-width: 100%;
  }

  .subtitle {
    margin-bottom: 1.2rem;
  }

  .upload-form,
  .upload-card {
    width: 100%;
  }

  .upload-card {
    border-radius: 14px;
    padding: 0.8rem;
  }

  .hero-content {
    width: 100%;
  }

  .poem-textarea {
    min-height: clamp(180px, 38vh, 280px);
    font-size: 16px;
    line-height: 1.65;
    padding: 0.85rem 0.9rem;
  }

  .poem-highlight {
    font-size: 16px;
    line-height: 1.65;
    padding: 0.85rem 0.9rem;
  }

  .upload-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: 0.75rem;
    margin-left: -0.2rem;
    margin-right: -0.2rem;
    padding: 0.65rem 0.2rem calc(0.65rem + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 72%, rgba(58, 58, 58, 0));
  }

  .btn-begin,
  .btn-gallery {
    min-height: 44px;
    padding: 0.7rem 1.25rem;
    font-size: 0.98rem;
  }

  .upload-status {
    margin-top: 0.55rem;
    font-size: 0.88rem;
  }

  .instructions-trigger {
    top: 0.5rem;
    right: 0.55rem;
    font-size: 0.82rem;
    min-height: 36px;
    padding: 0.28rem 0.72rem;
  }

  .inline-instructions {
    font-size: 0.86rem;
    padding: 2rem 3rem 0.8rem 0.85rem;
  }
}

@media (max-width: 640px) {
  .inline-instructions {
    padding-right: 0.9rem;
  }
}

/* Poetry view */
#poetry-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 6rem 2rem 4rem;
}

#poetry-view.hidden {
  display: none;
}

.poem-container {
  max-width: 560px;
  width: 100%;
}

.poem-output {
  font-size: 1.35rem;
  line-height: 1.9;
  color: var(--text);
  min-height: 4em;
  margin-bottom: 1.5rem;
  max-width: 46ch;
  white-space: pre-wrap;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.poem-output .word {
  opacity: 1;
}

.poem-output .seed-word {
  color: var(--accent);
  font-weight: 700;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1.4rem;
}

.poem-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.4rem;
}

.suggestion-btn {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.42rem 1.1rem;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.suggestion-btn:hover {
  border-color: var(--accent);
  background: rgba(233, 30, 140, 0.12);
}

.btn-save,
.btn-gallery {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, opacity 0.2s;
}

.btn-save:hover,
.btn-gallery:hover {
  border-color: var(--accent-hover);
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.25);
}

.btn-save:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-new {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-new:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* Gallery page */
.page-gallery .gallery-page {
  padding: 5rem 2rem 9rem;
}

.gallery-controls {
  max-width: 640px;
  margin: 0 auto 0.85rem;
  padding: 0 2rem;
}

.gallery-admin-row {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.gallery-admin-row:hover,
.gallery-admin-row:focus-within {
  opacity: 1;
}

.gallery-admin-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
}

.gallery-admin-btn:hover {
  color: var(--text);
}

.gallery-admin-status {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
  pointer-events: auto;
  padding: 0;
}

.gallery-search-label {
  display: block;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.gallery-search-input {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.95rem;
}

.gallery-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.gallery-search-status {
  min-height: 1.2rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.page-about .about-page {
  padding: 5rem 2rem 4rem;
}

.gallery-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.7rem;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 2rem;
}

.poem-stack {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 2rem 0;
}

.poem-stack::before,
.poem-stack::after {
  content: '';
  display: block;
}

.poem-stack::before {
  height: 36vh;
}

.poem-stack::after {
  height: 36vh;
}

.poem-block {
  min-height: auto;
  display: flex;
  align-items: flex-start;
  padding: 1.1rem 2rem;
  transition: opacity 0.35s ease;
}

.poem-block--deletable {
  position: relative;
  padding-right: 5.2rem;
}

.poem-block.is-active {
  opacity: 1;
}

.poem-block.is-dimmed {
  opacity: 0.34;
}

.poem-block.is-hidden {
  display: none;
}

.poem-block p {
  font-size: 1.2rem;
  line-height: 1.8;
  color: var(--text);
  transition: color 0.3s ease;
  text-wrap: balance;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

.poem-block .seed-word {
  color: var(--accent);
  font-weight: inherit;
  transition: color 0.3s ease;
}

.poem-delete-btn {
  position: absolute;
  top: 1rem;
  right: 2rem;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.28rem 0.62rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  display: none;
}

.is-admin-unlocked .poem-delete-btn {
  display: inline-flex;
}

.poem-delete-btn:hover {
  border-color: #ff6f7f;
  color: #ffd3d8;
  background: rgba(255, 64, 87, 0.22);
}

.poem-delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.poem-block.is-dimmed .seed-word {
  color: var(--text);
}

nav a.active {
  color: var(--text);
}

/* Gallery & About */
.section {
  min-height: 50vh;
  padding: 6rem 2rem 4rem;
  max-width: 640px;
  margin: 0 auto;
}

.section.hidden {
  display: none;
}

.section h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  text-wrap: balance;
}

.page-about .section p {
  font-size: 1.1rem;
  line-height: 1.8;
  color: #b8b8b8;
  margin-bottom: 1rem;
  max-width: 58ch;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.page-about .section p:first-of-type {
  max-width: none;
  white-space: nowrap;
}

.page-about .about-copyright {
  margin-top: 2rem;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .page-about .section p:first-of-type {
    white-space: normal;
  }
}

.gallery-poems {
  list-style: none;
  padding: 0;
  margin: 0;
}

.gallery-poems li {
  font-size: 1.1rem;
  line-height: 1.7;
  color: #b8b8b8;
  margin-bottom: 1.5rem;
}

.gallery-poems .seed-word {
  color: var(--accent);
  font-weight: 600;
}

/* Utils */
.hidden {
  display: none !important;
}
