/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #06060e;
  --sidebar-bg:   #09091a;
  --surface:      #0e0e1e;
  --surface-2:    rgba(255, 255, 255, 0.03);
  --border:       rgba(255, 255, 255, 0.07);
  --border-soft:  rgba(255, 255, 255, 0.04);
  --accent:       #c9a84c;
  --accent-light: #e2c468;
  --accent-dim:   rgba(201, 168, 76, 0.07);
  --accent-glow:  rgba(201, 168, 76, 0.14);
  --text:         #eee8d5;
  --text-2:       #968e7c;
  --text-muted:   #545472;
  --text-dim:     #252540;
  --error:        #d95f5f;
  --error-bg:     rgba(217, 95, 95, 0.07);
  --radius:       14px;
  --radius-sm:    8px;
  --ease:         cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbars ── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}
*::-webkit-scrollbar { width: 4px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }

/* ── App shell ── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
.sidebar {
  width: 296px;
  min-width: 296px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 32px 22px 28px;
  position: relative;
}

/* Top gold accent strip */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 40%, rgba(201,168,76,0.3) 100%);
}

/* Logo */
.logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 30px;
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 0;
  flex-shrink: 0;
  margin-bottom: 6px;
}
.logo-v { color: var(--accent); font-style: italic; }

.logo-tag {
  font-family: 'Inter', sans-serif;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 24px;
  display: block;
}

/* Sidebar divider */
.sidebar-divider {
  height: 1px;
  background: linear-gradient(90deg, var(--border) 0%, transparent 100%);
  margin-bottom: 24px;
  flex-shrink: 0;
}

/* Section label */
.section-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 16px;
  flex-shrink: 0;
}

/* Form */
#poem-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

label {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.label-hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  opacity: 0.65;
}

/* Inputs */
input[type="text"],
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 9px 13px;
  width: 100%;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
  outline: none;
}
input[type="text"]::placeholder,
textarea::placeholder { color: var(--text-dim); }

input[type="text"]:focus,
textarea:focus {
  border-color: rgba(201, 168, 76, 0.5);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Select */
.select-wrap { position: relative; }
.select-wrap::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 9px 32px 9px 13px;
  width: 100%;
  cursor: pointer;
  outline: none;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
select:focus {
  border-color: rgba(201, 168, 76, 0.5);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
select option { background: #12121e; }

/* Range slider with gold fill */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--track-fill, 17%),
    rgba(255,255,255,0.1) var(--track-fill, 17%),
    rgba(255,255,255,0.1) 100%
  );
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--sidebar-bg);
  box-shadow: 0 0 0 2px rgba(201,168,76,0.3), 0 2px 6px rgba(0,0,0,0.4);
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
  cursor: grab;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.18);
  box-shadow: 0 0 0 4px rgba(201,168,76,0.2), 0 2px 8px rgba(0,0,0,0.5);
}
input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; }
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--sidebar-bg);
}

/* Buttons */
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, #d4ae50 0%, #b8922e 100%);
  color: #1c1205;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  flex: 1;
  transition: all 0.2s var(--ease);
  box-shadow: 0 2px 12px rgba(201,168,76,0.18), inset 0 1px 0 rgba(255,255,255,0.1);
  letter-spacing: 0.01em;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #e8c76b 0%, #c9a84c 100%);
  box-shadow: 0 4px 20px rgba(201,168,76,0.32), inset 0 1px 0 rgba(255,255,255,0.15);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 10px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-ghost:hover {
  color: var(--accent);
  border-color: rgba(201,168,76,0.35);
  background: var(--accent-dim);
}

.btn-action {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 7px 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s var(--ease);
}
.btn-action:hover {
  color: var(--accent);
  border-color: rgba(201,168,76,0.35);
  background: var(--accent-dim);
}
.btn-action.copied {
  color: #6dba88;
  border-color: rgba(109,186,136,0.4);
  background: rgba(109,186,136,0.06);
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.btn-link:hover { color: var(--error); }

/* ── History ── */
.history-section {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.history-list { display: flex; flex-direction: column; gap: 6px; }

.history-card {
  background: transparent;
  border: 1px solid var(--border-soft);
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), border-left-color 0.2s;
}
.history-card:hover {
  border-color: var(--border);
  border-left-color: var(--accent);
  background: var(--accent-dim);
}
.history-card-theme {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-card-excerpt {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-card-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   MAIN
═══════════════════════════════════════════ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 44px 52px;
  gap: 28px;
  /* Subtle warm spotlight behind poem area */
  background: radial-gradient(ellipse 70% 50% at 50% 30%, rgba(201,168,76,0.025) 0%, transparent 70%);
}

/* ── Poem section ── */
.poem-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 340px;
}

.poem-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 52px 60px;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
  overflow: hidden;
}

/* Subtle top-edge glow when active */
.poem-card.state-active {
  border-color: rgba(201, 168, 76, 0.18);
  box-shadow: 0 0 0 1px rgba(201,168,76,0.05) inset,
              0 1px 80px rgba(201,168,76,0.04);
  align-items: flex-start;
  justify-content: flex-start;
  max-height: 62vh;
  overflow-y: auto;
}
.poem-card.state-active::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(201,168,76,0.5) 40%, rgba(201,168,76,0.1) 100%);
}

/* Empty state */
.empty-state { text-align: center; }
.empty-icon {
  font-size: 22px;
  color: var(--text-dim);
  margin-bottom: 18px;
  opacity: 0.6;
  user-select: none;
}
.empty-state p {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.8;
  color: var(--text-dim);
  max-width: 280px;
}

/* Loading state */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.03em;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 1.5px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Poem title */
.poem-title-loading {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
}
.poem-title-loading span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.3;
  animation: titleDot 1.3s ease-in-out infinite;
}
.poem-title-loading span:nth-child(2) { animation-delay: 0.22s; }
.poem-title-loading span:nth-child(3) { animation-delay: 0.44s; }
@keyframes titleDot {
  0%, 80%, 100% { opacity: 0.15; transform: scale(0.75); }
  40%           { opacity: 0.9;  transform: scale(1); }
}

.poem-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.75rem;
  font-weight: 300;
  font-style: italic;
  color: var(--accent);
  margin-bottom: 32px;
  letter-spacing: 0.02em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.55s var(--ease), transform 0.55s var(--ease);
  line-height: 1.3;
}
.poem-title.visible { opacity: 1; transform: translateY(0); }

/* Poem text — stanza-aware */
.poem-text {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 300;
  line-height: 2.05;
  color: var(--text);
  letter-spacing: 0.018em;
  width: 100%;
}
.poem-text p {
  margin-bottom: 1.6em;
}
.poem-text p:last-child { margin-bottom: 0; }

/* Streaming cursor on last paragraph */
.poem-text.streaming p:last-child::after {
  content: '|';
  color: var(--accent);
  opacity: 0.8;
  animation: blink 0.85s step-end infinite;
  margin-left: 1px;
}
/* Fallback for plain text during streaming */
.poem-text.streaming:not(:has(p))::after {
  content: '|';
  color: var(--accent);
  animation: blink 0.85s step-end infinite;
  margin-left: 1px;
}
@keyframes blink { 0%, 100% { opacity: 0.8; } 50% { opacity: 0; } }

/* Action bar */
.poem-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}
.action-btns { display: flex; gap: 8px; }


/* Error */
.error-msg {
  background: var(--error-bg);
  border: 1px solid rgba(217, 95, 95, 0.18);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 12px;
  padding: 10px 14px;
  margin-top: 8px;
  animation: fadeSlideIn 0.2s var(--ease);
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Analyze section ── */
.analyze-section {
  border-top: 1px solid var(--border-soft);
  padding-top: 26px;
}

.analyze-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  width: 100%;
  transition: color 0.15s;
}
.analyze-toggle:hover { color: var(--accent-light); }
.analyze-toggle .chevron { margin-left: auto; transition: transform 0.22s var(--ease); }
.analyze-toggle.open .chevron { transform: rotate(180deg); }

.analyze-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

textarea {
  resize: vertical;
  min-height: 150px;
  font-size: 13px;
  line-height: 1.65;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
}

.analyze-or {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
}
.analyze-or::before,
.analyze-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}
.upload-label {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  transition: color 0.15s;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--text-dim);
  white-space: nowrap;
}
.upload-label:hover { color: var(--accent); text-decoration-color: var(--accent); }

.analyze-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 28px;
  margin-top: 4px;
  animation: fadeSlideIn 0.25s var(--ease);
}
.analyze-result pre {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
  margin-top: 10px;
}

/* ── Revision bar ── */
.revision-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 0 4px;
  animation: fadeSlideIn 0.2s var(--ease);
}
.revision-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-right: 4px;
}
.btn-revise {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  padding: 5px 13px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.btn-revise:hover {
  color: var(--accent);
  border-color: rgba(201,168,76,0.35);
  background: var(--accent-dim);
}
.btn-revise:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Fullscreen poem ── */
.poem-card.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 200;
  border-radius: 0;
  max-height: 100vh;
  padding: 10vh 15vw;
  background: var(--bg);
  border: none;
  box-shadow: none;
  overflow-y: auto;
}
.poem-card.fullscreen::before { display: none; }
.poem-card.fullscreen .poem-title { font-size: 2.2rem; }
.poem-card.fullscreen .poem-text { font-size: 1.55rem; line-height: 2.2; }

.fullscreen-hint {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 201;
  background: rgba(0,0,0,0.6);
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  pointer-events: none;
  animation: fadeSlideIn 0.3s var(--ease);
}

/* ── Formatted analysis ── */
.analyze-rows { display: flex; flex-direction: column; gap: 10px; }
.analysis-row {
  display: flex;
  gap: 12px;
  font-size: 13px;
  line-height: 1.6;
}
.analysis-key {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  width: 110px;
  min-width: 110px;
  padding-top: 2px;
}
.analysis-val { color: var(--text); }
.analysis-plain {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ── Mobile header ── */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.mobile-menu-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 7px 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
}
.mobile-menu-btn:hover { color: var(--accent); border-color: rgba(201,168,76,0.35); }

.mobile-logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 300;
  color: var(--text);
  letter-spacing: 0.04em;
}
.mobile-logo .logo-v { color: var(--accent); font-style: italic; }

/* Mobile overlay */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
  backdrop-filter: blur(2px);
}
.mobile-overlay.visible { display: block; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease);
    border-right: 1px solid var(--border);
    width: 290px;
    min-width: 290px;
    max-height: 100vh;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }

  .main { padding: 20px 18px; }
  .poem-card { padding: 28px 24px; }
  .poem-card.fullscreen { padding: 8vh 6vw; }
  .action-row { flex-wrap: wrap; }
}

/* ── Two-row action layout ── */
.poem-actions {
  flex-direction: column;
  align-items: flex-start;
}
.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.action-row-sm .btn-action {
  font-size: 11px;
  padding: 5px 10px;
  opacity: 0.75;
}
.action-row-sm .btn-action:hover { opacity: 1; }

/* ── Star / Save button ── */
.btn-action.starred {
  color: var(--accent);
  border-color: rgba(201,168,76,0.45);
  background: var(--accent-dim);
}

/* ── Read / Stop button ── */
.btn-action.speaking {
  color: #6dba88;
  border-color: rgba(109,186,136,0.4);
  background: rgba(109,186,136,0.06);
  animation: pulseRead 2s ease-in-out infinite;
}
@keyframes pulseRead {
  0%, 100% { box-shadow: 0 0 0 0 rgba(109,186,136,0); }
  50%       { box-shadow: 0 0 0 4px rgba(109,186,136,0.12); }
}

/* ── Revision bar restructured ── */
.revision-bar {
  flex-direction: column;
  gap: 10px;
}
.revision-presets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.revision-custom {
  display: flex;
  gap: 8px;
  width: 100%;
}
.revision-custom input {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 5px 14px;
  outline: none;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.revision-custom input::placeholder { color: var(--text-dim); }
.revision-custom input:focus {
  border-color: rgba(201,168,76,0.45);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.revision-send-btn {
  padding: 5px 14px;
  flex-shrink: 0;
  font-size: 14px;
}

/* ── Favorites section ── */
.favorites-card-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Occasion presets ── */
.occasion-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}
.occasion-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s var(--ease);
}
.occasion-btn:hover {
  color: var(--accent);
  border-color: rgba(201,168,76,0.35);
  background: var(--accent-dim);
}
.occasion-btn.active {
  color: var(--accent);
  border-color: rgba(201,168,76,0.5);
  background: var(--accent-dim);
}

/* ── Poem meta row (stats + font controls) ── */
.poem-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px;
  animation: fadeSlideIn 0.25s var(--ease);
}
.font-controls { display: flex; gap: 4px; }
.btn-font {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  user-select: none;
}
.btn-font:hover { color: var(--accent); border-color: rgba(201,168,76,0.35); }
.btn-font:disabled { opacity: 0.25; cursor: not-allowed; }

/* ── Shortcuts modal ── */
.shortcuts-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  animation: fadeSlideIn 0.18s var(--ease);
}
.shortcuts-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: 360px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.shortcuts-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}
.shortcuts-close:hover { color: var(--text); }
.shortcuts-list { display: flex; flex-direction: column; }
.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-2);
}
.shortcut-row:last-child { border-bottom: none; padding-bottom: 0; }
.kbd-group { display: flex; gap: 4px; }
kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 3px 7px;
  color: var(--accent);
  white-space: nowrap;
}

/* ── Shortcuts FAB ── */
.shortcuts-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
}
.shortcuts-fab:hover {
  color: var(--accent);
  border-color: rgba(201,168,76,0.4);
  background: var(--accent-dim);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 70px;
  right: 24px;
  z-index: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 8px 14px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  pointer-events: none;
  white-space: nowrap;
}
.toast.visible { opacity: 1; transform: translateY(0); }

/* ── Poet preset chips ── */
.poet-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}
.preset-chip {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.preset-chip:hover {
  color: var(--accent);
  border-color: rgba(201,168,76,0.35);
  background: var(--accent-dim);
}
.preset-chip.active {
  color: var(--accent);
  border-color: rgba(201,168,76,0.5);
  background: var(--accent-dim);
}

/* ── Poem stats ── */
.poem-stats {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  padding: 2px 2px;
  animation: fadeSlideIn 0.25s var(--ease);
}

/* ── Undo button ── */
.btn-undo {
  color: rgba(201,168,76,0.7);
  border-color: rgba(201,168,76,0.2);
}
.btn-undo:hover {
  color: var(--accent);
  border-color: rgba(201,168,76,0.45);
  background: var(--accent-dim);
}

/* ── Print view ── */
@media print {
  .sidebar,
  .mobile-header,
  .mobile-overlay,
  .poem-actions,
  .revision-bar,
  .analyze-section,
  .fullscreen-hint { display: none !important; }

  body, html { background: #fff !important; color: #111 !important; }
  .app { display: block !important; }
  .main { padding: 0 !important; background: none !important; }

  .poem-card {
    background: #fff !important;
    border: none !important;
    box-shadow: none !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    min-height: 0 !important;
  }
  .poem-card::before { display: none !important; }

  .poem-title { color: #111 !important; font-size: 2rem !important; }
  .poem-text  { color: #111 !important; font-size: 1.2rem !important; line-height: 1.9 !important; }
  .poem-text p { margin-bottom: 1.4em !important; }
}

/* ── Response poem panel ── */
.response-section {
  border-top: 1px solid var(--border-soft);
  padding-top: 20px;
  margin-top: 8px;
  animation: fadeSlideIn 0.3s var(--ease);
}
.response-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.response-label {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 12px;
  font-style: italic;
  color: var(--accent);
  opacity: 0.65;
  letter-spacing: 0.06em;
}
.response-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.response-adopt-btn {
  font-size: 11px;
  color: var(--accent);
  border-color: rgba(201,168,76,0.3);
}
.response-adopt-btn:hover {
  background: var(--accent-dim);
  border-color: rgba(201,168,76,0.5);
}
.response-dismiss-btn {
  font-size: 13px;
  padding: 4px 10px;
  opacity: 0.5;
  min-height: 0;
}
.response-dismiss-btn:hover { opacity: 1; }
.response-card {
  min-height: 80px;
  max-height: 45vh;
  overflow-y: auto;
  align-items: flex-start;
  justify-content: flex-start;
  background: rgba(14,14,30,0.6);
  border-color: rgba(201,168,76,0.1);
  padding: 20px 24px;
}
.response-card .poem-text { display: block !important; }

/* ── Diff modal ── */
.diff-panel {
  max-width: 680px !important;
  width: 92vw !important;
  max-height: 78vh;
  overflow-y: auto;
}
.diff-content {
  padding: 4px 0 8px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.75;
}
.diff-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 1px 8px;
  border-radius: 3px;
}
.diff-line.add    { background: rgba(109,186,136,0.12); color: #7dcf9b; }
.diff-line.remove { background: rgba(217,95,95,0.09); color: rgba(217,95,95,0.55); text-decoration: line-through; }
.diff-line.same   { color: var(--text-dim); }
.diff-line-marker {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  opacity: 0.5;
  min-width: 12px;
  user-select: none;
}
.diff-empty {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 28px 0;
}

/* ── Cloud history modal ── */
.cloud-panel {
  max-width: 560px !important;
  width: 92vw !important;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.cloud-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
  padding: 4px 0 8px;
}
.cloud-item {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.cloud-item:hover {
  border-color: rgba(201,168,76,0.25);
  background: rgba(201,168,76,0.04);
}
.cloud-item-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1rem;
  font-style: italic;
  color: var(--accent);
  margin-bottom: 2px;
}
.cloud-item-excerpt {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.cloud-item-meta {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}
.cloud-empty {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 32px 0;
}

/* ── Cloud history sidebar button ── */
.cloud-history-btn {
  width: 100%;
  margin-top: 8px;
  font-size: 11px;
  justify-content: center;
  gap: 6px;
  opacity: 0.7;
}
.cloud-history-btn:hover { opacity: 1; }

/* ── Compare button ── */
.btn-compare {
  color: rgba(201,168,76,0.7);
  border-color: rgba(201,168,76,0.2);
}
.btn-compare:hover {
  color: var(--accent);
  border-color: rgba(201,168,76,0.45);
  background: var(--accent-dim);
}
