:root {
  --ink: #27231f;
  --muted: #756e64;
  --paper: #f7f3e9;
  --cream: #eee6d5;
  --white: #fffdf7;
  --forest: #2e5142;
  --forest-dark: #1e3a2f;
  --terracotta: #b75c3d;
  --line: rgba(39, 35, 31, 0.15);
  --shadow: 0 28px 80px rgba(56, 45, 33, 0.13);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

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

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--terracotta);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

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

.public-board {
  background:
    radial-gradient(circle at 8% 12%, rgba(183, 92, 61, 0.08), transparent 28rem),
    radial-gradient(circle at 95% 88%, rgba(46, 81, 66, 0.1), transparent 30rem),
    var(--paper);
}

.board-page {
  display: grid;
  min-height: 100vh;
  padding: clamp(1rem, 4vw, 3.5rem);
  place-items: center;
}

.board {
  position: relative;
  width: min(100%, 52rem);
  min-height: min(44rem, calc(100vh - 2rem));
  padding: clamp(2rem, 7vw, 5rem);
  overflow: hidden;
  background: var(--white);
  border: 1px solid rgba(39, 35, 31, 0.12);
  border-radius: 1.2rem;
  box-shadow: var(--shadow);
}

.board::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0.38rem;
  content: "";
  background: var(--forest);
}

.board__header {
  padding-bottom: clamp(2rem, 6vw, 4rem);
  border-bottom: 1px solid var(--line);
}

.cafe-name {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  font-style: italic;
}

.today {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.stale-note {
  padding: 0.85rem 1rem;
  margin: 1.5rem 0 -0.25rem;
  color: var(--forest-dark);
  background: #e8efe8;
  border-radius: 0.55rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.board__message { padding: clamp(2.2rem, 7vw, 4.8rem) 0; }

.board__message h1 {
  max-width: 15ch;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.45rem, 8vw, 5rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1.04;
  text-wrap: balance;
}

.board-details {
  display: grid;
  gap: 0;
  max-width: 38rem;
  margin: clamp(2.4rem, 7vw, 4rem) 0 0;
}

.board-detail {
  display: grid;
  grid-template-columns: minmax(6.5rem, 0.32fr) 1fr;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.board-detail dt {
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.board-detail dd {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  line-height: 1.45;
}

.board-detail dd p { margin: 0 0 0.35rem; }
.board-detail dd p:last-child { margin-bottom: 0; }

.board__footer {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.live-dot {
  width: 0.48rem;
  height: 0.48rem;
  background: var(--forest);
  border-radius: 50%;
}

.editor, .sign-in {
  background:
    linear-gradient(rgba(39, 35, 31, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 2rem;
}

.editor-page {
  width: min(100% - 2rem, 58rem);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 5rem) 0 6rem;
}

.editor-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
}

.editor-header h1, .history h2, .sign-in-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 6vw, 3.9rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.04;
}

.editor-date {
  margin: 0.75rem 0 0;
  color: var(--muted);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 0.2rem;
  font-size: 0.84rem;
  white-space: nowrap;
}

.editor-actions form { margin: 0; }

.editor-actions a, .text-button {
  padding: 0;
  color: var(--forest);
  background: none;
  border: 0;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.editor-card, .sign-in-card {
  padding: clamp(1.25rem, 5vw, 2.5rem);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 18px 50px rgba(56, 45, 33, 0.08);
}

.board-form, .sign-in-form {
  display: grid;
  gap: 1.25rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field label {
  font-size: 0.82rem;
  font-weight: 800;
}

.field input, .field textarea {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.8rem 0.9rem;
  color: var(--ink);
  background: #fffefa;
  border: 1px solid rgba(39, 35, 31, 0.3);
  border-radius: 0.55rem;
  outline: none;
  resize: vertical;
}

.field textarea { line-height: 1.4; }

.field--headline textarea {
  min-height: 6.1rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.field input:focus, .field textarea:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(46, 81, 66, 0.13);
}

.save-button, .template-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.4rem;
  padding: 0.85rem 1.25rem;
  color: white;
  background: var(--forest);
  border: 0;
  border-radius: 0.55rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.save-button:hover, .template-button:hover { background: var(--forest-dark); }

.flash, .form-errors {
  padding: 0.9rem 1rem;
  margin: 0 0 1rem;
  border-radius: 0.55rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.flash--notice, .flash--template {
  color: var(--forest-dark);
  background: #dfebdf;
  border: 1px solid #bfd2c0;
}

.flash--alert, .form-errors {
  color: #702d22;
  background: #f9e6df;
  border: 1px solid #edc3b5;
}

.form-errors p, .form-errors ul { margin: 0; }
.form-errors ul { padding-left: 1.2rem; margin-top: 0.35rem; }

.history { margin-top: clamp(3.5rem, 9vw, 6rem); }

.history__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: 1.3rem;
  border-bottom: 1px solid var(--line);
}

.history h2 { font-size: clamp(1.9rem, 5vw, 2.7rem); }

.history__header > p {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.history-board {
  display: flex;
  flex-direction: column;
  align-items: start;
  min-width: 0;
  padding: 1.25rem;
  background: rgba(255, 253, 247, 0.76);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}

.history-board__date {
  margin: 0 0 0.7rem;
  color: var(--terracotta);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-board h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.25;
}

.history-board dl {
  width: 100%;
  margin: 1rem 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.history-board dl div {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
}

.history-board dt { font-weight: 800; }
.history-board dd, .history-board dd p { margin: 0; }

.template-button {
  width: 100%;
  min-height: 2.7rem;
  margin-top: auto;
  color: var(--forest-dark);
  background: transparent;
  border: 1px solid var(--forest);
  font-size: 0.82rem;
}

.template-button:hover { color: white; }

.empty-history {
  padding: 2rem;
  margin: 1rem 0 0;
  color: var(--muted);
  text-align: center;
  border: 1px dashed rgba(39, 35, 31, 0.25);
  border-radius: 0.75rem;
}

.sign-in-page {
  display: grid;
  min-height: 100vh;
  padding: 1rem;
  place-items: center;
}

.sign-in-card { width: min(100%, 27rem); }
.sign-in-card h1 { font-size: clamp(2.3rem, 10vw, 3.3rem); }

.sign-in-card__intro {
  margin: 1rem 0 1.6rem;
  color: var(--muted);
  line-height: 1.5;
}

.back-link {
  display: inline-block;
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-underline-offset: 0.2em;
}

@media (max-width: 640px) {
  .board-page { display: block; padding: 0; }

  .board {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .board-detail { grid-template-columns: 1fr; gap: 0.35rem; }

  .editor-page {
    width: min(100% - 1.25rem, 58rem);
    padding-top: 1.5rem;
  }

  .editor-header, .history__header {
    align-items: start;
    flex-direction: column;
    gap: 1rem;
  }

  .editor-actions { width: 100%; justify-content: space-between; }
  .editor-card { padding: 1rem; }
  .history-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  .board { animation: arrive 420ms ease-out both; }

  @keyframes arrive {
    from { opacity: 0; transform: translateY(0.5rem); }
  }
}
