/* ============================================================
   OpenLetter — Design System
   Editorial warmth meets modern craft.
   Inspired by good-ship.co.uk & techfreedom.eu
   ============================================================ */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

ul, ol {
  list-style: none;
}

/* 2. Custom Properties
   ------------------------------------------------------------ */
:root {
  /* Typography — Fraunces (display) + DM Sans (body) */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Colors — warm cream + deep navy + amber accent */
  --ink: #1B2A4A;
  --ink-light: #3D4A5C;
  --ink-muted: #636B78;
  --paper: #F7F5F0;
  --paper-warm: #F0EDE5;
  --paper-dim: #E8E5DD;
  --border: rgba(26, 42, 74, 0.1);
  --border-light: rgba(26, 42, 74, 0.06);
  --accent: #2D8B7A;
  --accent-hover: #247A6A;
  --accent-light: rgba(45, 139, 122, 0.12);
  --accent-subtle: rgba(45, 139, 122, 0.05);
  --amber: #D4A843;
  --amber-hover: #C49A38;
  --amber-light: rgba(212, 168, 67, 0.15);
  --error: #9b2c2c;
  --error-light: #fde8e8;
  --success: #2D8B7A;
  --info: #2B6AB0;
  --info-light: #e8eef5;
  --pending-bg: #fef3cd;
  --pending-text: #7a5a05;

  /* Spacing — fluid with clamp */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: clamp(1.5rem, 1rem + 2vw, 2.5rem);
  --space-2xl: clamp(2rem, 1.5rem + 3vw, 4rem);
  --space-3xl: clamp(2.5rem, 2rem + 4vw, 6rem);

  /* Fluid type */
  --text-sm: 0.8125rem;
  --text-base: clamp(0.9375rem, 0.9rem + 0.15vw, 1rem);
  --text-md: clamp(1rem, 0.95rem + 0.2vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.4vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  --text-3xl: clamp(2rem, 1.5rem + 2vw, 2.75rem);
  --text-4xl: clamp(2.25rem, 1.5rem + 3vw, 3.5rem);

  /* Misc */
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 3px rgba(27, 42, 74, 0.05);
  --shadow-md: 0 4px 12px rgba(27, 42, 74, 0.08);
  --shadow-lg: 0 8px 30px rgba(27, 42, 74, 0.12);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* 3. Base Typography
   ------------------------------------------------------------ */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--paper);
  min-height: 100vh;
}

/* Grain texture overlay — adds paper-like warmth */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  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");
  background-repeat: repeat;
  background-size: 200px 200px;
}

::selection {
  background: var(--accent);
  color: var(--paper);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 300;
  line-height: 1.2;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 72;
}

h1 {
  font-size: var(--text-4xl);
  font-variation-settings: 'opsz' 144;
}
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); font-variation-settings: 'opsz' 48; }
h4 { font-size: var(--text-lg); }

p {
  margin-bottom: var(--space-md);
  max-width: 65ch;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--transition);
}

a:hover {
  color: var(--ink);
}

a:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: var(--radius);
}

strong { font-weight: 600; }

small { font-size: var(--text-sm); color: var(--ink-light); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--paper-warm);
  padding: 0.15em 0.35em;
  border-radius: var(--radius);
}

pre {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--paper-warm);
  padding: var(--space-md);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: var(--space-md);
}

pre code {
  background: none;
  padding: 0;
}

blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-lg);
  margin: var(--space-lg) 0;
  color: var(--ink-light);
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-xl) 0;
}

/* 4. Scroll Reveal Animation
   ------------------------------------------------------------ */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s cubic-bezier(0.23, 1, 0.32, 1),
              transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* 5. Skip Link & Layout
   ------------------------------------------------------------ */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--accent);
  color: var(--paper);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  z-index: 9999;
  transition: top var(--transition);
}

.skip-link:focus {
  top: var(--space-sm);
  color: var(--paper);
}

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container--wide {
  max-width: 1080px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.stack--lg {
  gap: var(--space-lg);
}

.stack--xl {
  gap: var(--space-xl);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
}

main {
  padding: var(--space-2xl) 0;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.dashboard-header h1 {
  margin: 0;
}

.error-page {
  text-align: center;
  padding: var(--space-3xl) 0;
}

.error-page h1 {
  margin-bottom: var(--space-md);
}

.error-page p {
  color: var(--ink-muted);
  margin-bottom: var(--space-xl);
}

/* 6. Navigation — glass morphism
   ------------------------------------------------------------ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 245, 240, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-light);
  padding: 0 var(--space-lg);
  transition: background var(--transition-slow), box-shadow var(--transition-slow);
}

.nav.scrolled {
  background: rgba(247, 245, 240, 0.95);
  box-shadow: 0 1px 8px rgba(27, 42, 74, 0.06);
}

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 300;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 48;
}

.nav-logo svg {
  flex-shrink: 0;
}

.nav-logo:hover {
  color: var(--ink);
  opacity: 0.8;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.nav-email {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.nav-link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-light);
  text-decoration: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover {
  color: var(--ink);
  background: var(--paper-dim);
}

.nav-link:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* Public-facing nav (no auth) */
.nav-public {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 245, 240, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-light);
  padding: 0 var(--space-lg);
}

.nav-public .nav-inner {
  height: 60px;
}

.nav-public .nav-cta {
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 0.4rem 1rem;
  background: var(--amber);
  color: var(--ink);
  border-radius: var(--radius);
  text-decoration: none;
  transition: background var(--transition), transform var(--transition);
}

.nav-public .nav-cta:hover {
  background: var(--amber-hover);
  transform: translateY(-1px);
  color: var(--ink);
}

/* 7. Buttons
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.55rem 1.4rem;
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  min-height: 2.75rem;
}

.btn:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--paper);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(45, 139, 122, 0.25);
}

.btn-amber {
  background: var(--amber);
  color: var(--ink);
  border-color: var(--amber);
}

.btn-amber:hover {
  background: var(--amber-hover);
  border-color: var(--amber-hover);
  color: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(212, 168, 67, 0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--paper-warm);
  border-color: var(--ink-muted);
}

.btn-success {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}

.btn-success:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--paper);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-light);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--paper-warm);
  color: var(--ink);
}

.btn-icon {
  padding: 0.5rem;
  width: 2.75rem;
  height: 2.75rem;
  min-height: 2.75rem;
}

.btn-danger {
  background: var(--error);
  color: var(--paper);
  border-color: var(--error);
}

.btn-danger:hover {
  background: #862525;
  border-color: #862525;
  color: var(--paper);
}

.btn-lg {
  padding: 0.75rem 2.25rem;
  font-size: var(--text-md);
  min-height: 3.25rem;
  border-radius: var(--radius);
}

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: var(--text-sm);
  min-height: 2.25rem;
}

/* 8. Forms
   ------------------------------------------------------------ */
input[type="text"],
input[type="email"],
input[type="date"],
input[type="password"],
input[type="url"],
textarea,
select {
  display: block;
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 2.75rem;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: var(--space-xs);
  color: var(--ink);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.form-group small {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.form-row {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
}

.form-row > * {
  flex: 1;
}

.checkbox-group,
.radio-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.checkbox-group label,
.radio-group label,
.checkbox-label,
.radio-label {
  font-weight: 400;
  margin-bottom: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.checkbox-group input[type="checkbox"],
.radio-group input[type="radio"],
.checkbox-label input[type="checkbox"],
.radio-label input[type="radio"] {
  width: auto;
  min-height: auto;
  display: inline-block;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.input-error {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px rgba(155, 44, 44, 0.1) !important;
}

.input-readonly {
  padding: 0.6rem 0.85rem;
  background: var(--paper-warm);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: var(--text-base);
  color: var(--ink-muted);
}

/* 9. Cards
   ------------------------------------------------------------ */
.letter-card {
  display: block;
  padding: var(--space-lg);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--ink);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.letter-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(45, 139, 122, 0.2);
  color: var(--ink);
}

.letter-card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 300;
  margin-bottom: var(--space-sm);
  letter-spacing: -0.01em;
}

.letter-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin-top: var(--space-sm);
}

/* Stat cards */
.stat-row {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  flex: 1;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 300;
  line-height: 1;
  color: var(--ink);
}

.stat-card-label {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* 10. Badges
   ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.7em;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  border-radius: 999px;
  text-transform: capitalize;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge-draft {
  background: var(--paper-warm);
  color: var(--ink-muted);
}

.badge-published {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-closed {
  background: var(--paper-warm);
  color: var(--ink-muted);
}

.badge-verified {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-pending {
  background: var(--pending-bg);
  color: var(--pending-text);
}

/* 11. Tables
   ------------------------------------------------------------ */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  background: var(--paper-warm);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:nth-child(even) td {
  background: var(--accent-subtle);
}

.table-actions {
  display: flex;
  gap: var(--space-xs);
  justify-content: flex-end;
}

/* 12. Pagination
   ------------------------------------------------------------ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: var(--space-xl);
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0 0.5rem;
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink-light);
  transition: all var(--transition);
}

.pagination a:hover {
  background: var(--paper-warm);
  border-color: var(--ink-muted);
  color: var(--ink);
}

.pagination .active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

.pagination .disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* 13. Modal / Dialog
   ------------------------------------------------------------ */
dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 480px;
  width: calc(100% - var(--space-xl));
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  background: var(--paper);
}

dialog::backdrop {
  background: rgba(27, 42, 74, 0.45);
  backdrop-filter: blur(4px);
}

dialog .dialog-close,
dialog .modal-close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--ink-muted);
  cursor: pointer;
  padding: var(--space-sm);
  line-height: 1;
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}

dialog .dialog-close:hover,
dialog .modal-close:hover {
  color: var(--ink);
  background: var(--paper-warm);
}

dialog .dialog-close:focus-visible,
dialog .modal-close:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* 14. Toast
   ------------------------------------------------------------ */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  min-width: 280px;
  max-width: 420px;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  color: var(--paper);
  box-shadow: var(--shadow-lg);
  animation: slideIn 300ms ease forwards;
  z-index: 1000;
  transition: opacity var(--transition-slow);
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--error);
}

.toast-info {
  background: var(--ink);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* 15. Editor
   ------------------------------------------------------------ */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  margin-bottom: var(--space-sm);
}

.editor-toolbar .btn svg {
  display: inline-block;
  vertical-align: middle;
}

.editor-container {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 500px;
}

.editor-pane {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.editor-pane--preview {
  border-left: 1px solid var(--border);
  transition: flex var(--transition-slow), opacity var(--transition-slow);
}

.editor-pane--preview.collapsed {
  flex: 0 0 0%;
  overflow: hidden;
  opacity: 0;
  border-left: none;
}

.editor-pane--preview.collapsed .editor-preview {
  display: none;
}

/* When preview is collapsed, editor takes full width */
.editor-container.preview-collapsed .editor-pane--editor {
  flex: 1 1 100%;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  border: none;
  padding: var(--space-lg);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.7;
  resize: none;
  min-height: 500px;
  background: var(--paper);
}

.editor-textarea:focus {
  outline: none;
  box-shadow: none;
}

.editor-preview {
  flex: 1;
  padding: var(--space-lg);
  overflow-y: auto;
  background: var(--paper-warm);
  font-size: 1rem;
  line-height: 1.7;
}

.editor-preview h1,
.editor-preview h2,
.editor-preview h3 {
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

.editor-preview p {
  margin-bottom: var(--space-md);
}

.editor-preview ul,
.editor-preview ol {
  margin: var(--space-md) 0;
  padding-left: var(--space-xl);
  list-style: revert;
}

/* Cheat sheet dialog */
.cheatsheet-dialog {
  max-width: 640px;
}

.cheatsheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-top: var(--space-md);
}

.cheatsheet-section h4 {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: var(--space-sm);
}

.cheatsheet-table {
  width: 100%;
  border: none;
}

.cheatsheet-table td {
  padding: 0.35rem 0.5rem;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-light);
  background: none;
}

.cheatsheet-table tr:last-child td {
  border-bottom: none;
}

.cheatsheet-table td:first-child {
  white-space: nowrap;
  width: 55%;
}

@media (max-width: 480px) {
  .cheatsheet-grid {
    grid-template-columns: 1fr;
  }
}

/* Editor page extras */
.authors-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border);
}

.authors-section h3 {
  margin-bottom: var(--space-md);
}

.author-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-light);
}

.author-name {
  font-weight: 500;
}

.author-org {
  color: var(--ink-muted);
}

.author-add-form {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  align-items: flex-end;
}

.author-add-form input {
  flex: 1;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

/* 16. Public Letter
   ------------------------------------------------------------ */
.letter-header {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border);
}

.letter-stats {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin-top: var(--space-sm);
}

.letter-article {
  font-size: var(--text-md);
  line-height: 1.85;
  color: var(--ink-light);
  max-width: 640px;
  margin: 0 auto var(--space-2xl);
}

.letter-article p {
  margin-bottom: var(--space-lg);
}

.letter-article p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 3.8em;
  float: left;
  line-height: 0.78;
  margin-right: 0.06em;
  margin-top: 0.06em;
  color: var(--ink);
  font-weight: 300;
  font-variation-settings: 'opsz' 144;
}

.letter-article h2,
.letter-article h3 {
  color: var(--ink);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

.letter-article blockquote {
  font-size: var(--text-md);
}

.letter-article ul,
.letter-article ol {
  margin: var(--space-md) 0;
  padding-left: var(--space-xl);
  list-style: revert;
}

.letter-authors {
  font-size: var(--text-base);
  color: var(--ink-light);
  margin-bottom: var(--space-md);
}

.letter-date {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* Ornamental divider */
.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin: var(--space-2xl) 0;
  color: var(--ink-muted);
  opacity: 0.3;
}

.ornament::before,
.ornament::after {
  content: '';
  flex: 1;
  max-width: 100px;
  height: 1px;
  background: currentColor;
}

.letter-cta {
  text-align: center;
  padding: var(--space-2xl) 0;
  margin: var(--space-2xl) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.letter-cta h2 {
  margin-bottom: var(--space-sm);
}

.letter-cta p {
  color: var(--ink-muted);
  margin-bottom: var(--space-lg);
  margin-left: auto;
  margin-right: auto;
}

.signatories {
  margin-top: var(--space-xl);
  padding: var(--space-xl);
  background: var(--paper-warm);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.signatories-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.signatories-header h2 {
  margin-bottom: 0;
}

.signatories-count {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  font-weight: 400;
}

.signatories-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-sm);
}

.signatory {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-base);
  padding: var(--space-sm) var(--space-md);
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.signatory:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.signatory-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
  flex-shrink: 0;
  text-transform: uppercase;
}

.signatory-info {
  min-width: 0;
}

.signatory-name {
  font-weight: 600;
  color: var(--ink);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.signatory-detail {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Signed / Thank you page */
.signed-page {
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-3xl) 0;
}

.signed-icon {
  margin-bottom: var(--space-lg);
}

.signed-icon svg {
  display: inline-block;
}

.signed-page h1 {
  margin-bottom: var(--space-md);
}

.signed-page > p {
  margin-left: auto;
  margin-right: auto;
}

.share-box {
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  background: var(--paper-warm);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.share-label {
  font-weight: 500;
  font-size: var(--text-base);
  margin-bottom: var(--space-md);
  color: var(--ink);
}

.share-buttons {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.signed-redirect {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

.signed-redirect p {
  margin-bottom: var(--space-md);
  margin-left: auto;
  margin-right: auto;
}

/* 17. Landing Page
   ------------------------------------------------------------ */
.hero {
  padding: var(--space-3xl) 0 var(--space-2xl);
  max-width: 640px;
  position: relative;
}

.hero h1 {
  font-size: var(--text-4xl);
  line-height: 1.08;
  margin-bottom: var(--space-lg);
  font-weight: 300;
  font-variation-settings: 'opsz' 144;
}

.hero p {
  font-size: var(--text-lg);
  color: var(--ink-light);
  max-width: 480px;
  margin-bottom: var(--space-xl);
  line-height: 1.6;
}

/* Hero decorative SVG */
.hero-decoration {
  position: absolute;
  top: var(--space-xl);
  right: -160px;
  width: 280px;
  height: 280px;
  opacity: 0.08;
  pointer-events: none;
}

/* Wave section divider */
.wave-divider {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  color: var(--paper-warm);
}

.wave-divider--flip {
  transform: scaleY(-1);
  color: var(--paper);
}

/* Features */
.features-section {
  padding: var(--space-2xl) 0;
  background: var(--paper-warm);
  margin: 0 calc(-1 * var(--space-lg));
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

.features-section > .features-inner {
  max-width: 1080px;
  margin: 0 auto;
}

.features-section h2 {
  margin-bottom: var(--space-xl);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.feature-cell {
  background: var(--paper);
  padding: var(--space-xl) var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  transition: transform var(--transition), box-shadow var(--transition);
}

.feature-cell:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.feature-cell .feature-icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  color: var(--accent);
}

.feature-cell .feature-num {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 300;
  color: var(--amber);
  line-height: 1;
  margin-bottom: var(--space-sm);
  opacity: 0.6;
}

.feature-cell h3 {
  margin-bottom: var(--space-sm);
  font-size: var(--text-lg);
  font-weight: 400;
}

.feature-cell p {
  font-size: var(--text-sm);
  color: var(--ink-light);
  line-height: 1.6;
  margin-bottom: 0;
}

/* Recent letters */
.recent-letters {
  padding: var(--space-2xl) 0;
}

.recent-letters > h2 {
  margin-bottom: var(--space-xl);
}

.recent-letters .card {
  display: block;
  padding: var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--ink);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.recent-letters .card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(45, 139, 122, 0.2);
}

.recent-letters .card h3 {
  margin-bottom: var(--space-xs);
  font-weight: 400;
}

/* CTA section */
.cta-section {
  text-align: center;
  padding: var(--space-2xl);
  margin-top: var(--space-2xl);
  background: var(--ink);
  border-radius: var(--radius-lg);
  color: var(--paper);
  position: relative;
  overflow: hidden;
}

.cta-section::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.04;
  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)' fill='white'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  pointer-events: none;
}

.cta-section h2 {
  margin-bottom: var(--space-sm);
  color: var(--paper);
}

.cta-section p {
  color: rgba(247, 245, 240, 0.7);
  margin-bottom: var(--space-lg);
  margin-left: auto;
  margin-right: auto;
}

/* 18. Flash Messages
   ------------------------------------------------------------ */
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius);
  font-size: var(--text-base);
  margin-bottom: var(--space-lg);
  transition: opacity var(--transition-slow);
}

.flash-success {
  background: var(--accent-light);
  color: var(--accent);
}

.flash-error {
  background: var(--error-light);
  color: var(--error);
}

.flash-info {
  background: var(--info-light);
  color: var(--info);
}

.flash-dismiss {
  background: none;
  border: none;
  font-size: 1.125rem;
  cursor: pointer;
  opacity: 0.6;
  padding: var(--space-xs) var(--space-sm);
  color: inherit;
  line-height: 1;
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.flash-dismiss:hover {
  opacity: 1;
}

/* 19. Empty State
   ------------------------------------------------------------ */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.3;
}

.empty-state h3 {
  margin-bottom: var(--space-sm);
}

.empty-state p {
  color: var(--ink-muted);
  max-width: 360px;
  margin: 0 auto var(--space-lg);
}

/* 20. Dashboard Tabs
   ------------------------------------------------------------ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-xl);
}

.tab {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
}

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

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* 21. Login
   ------------------------------------------------------------ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
}

.login-container {
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
}

.login-illustration {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-xl);
  color: var(--accent);
  opacity: 0.7;
}

.login-container h1 {
  margin-bottom: var(--space-sm);
  text-align: center;
}

.login-container > p {
  margin-bottom: var(--space-xl);
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

/* 22. Footer
   ------------------------------------------------------------ */
.site-footer {
  margin-top: auto;
  padding: var(--space-xl) var(--space-lg);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.site-footer .footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-footer .footer-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-weight: 300;
  color: var(--ink-muted);
  font-size: var(--text-base);
}

.site-footer .footer-links {
  display: flex;
  gap: var(--space-lg);
}

.site-footer .footer-links a {
  color: var(--ink-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.site-footer .footer-links a:hover {
  color: var(--ink);
}

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

.text-muted { color: var(--ink-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* 24. Responsive
   ------------------------------------------------------------ */
@media (max-width: 768px) {
  .hero {
    max-width: none;
  }

  .hero-decoration {
    display: none;
  }

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

  .editor-container {
    flex-direction: column;
  }

  .editor-pane--preview {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .editor-textarea {
    min-height: 300px;
  }

  .form-row {
    flex-direction: column;
  }

  .nav-email {
    display: none;
  }

  .signatories-list {
    grid-template-columns: 1fr;
  }

  .stat-row {
    flex-direction: column;
  }

  .author-add-form {
    flex-direction: column;
  }

  .action-buttons {
    flex-wrap: wrap;
  }

  .site-footer .footer-inner {
    flex-direction: column;
    gap: var(--space-md);
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 var(--space-md);
  }

  main {
    padding: var(--space-lg) 0;
  }

  .letter-card {
    padding: var(--space-md);
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    padding: var(--space-sm) var(--space-md);
  }

  .letter-article p:first-of-type::first-letter {
    font-size: 2.75em;
  }

  .features-section {
    margin: 0 calc(-1 * var(--space-md));
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
}

/* Admin & moderation */
.status-removed {
  background: var(--error-light);
  color: var(--error);
}

.btn-danger {
  background: var(--error);
  color: #fff;
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
}
.btn-danger:hover {
  opacity: 0.9;
}

.letter-removed {
  padding: var(--space-xl) 0;
}
.letter-removed h1 {
  font-family: var(--font-display);
  color: var(--ink);
  margin-bottom: var(--space-sm);
}
