@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Newsreader:opsz,wght@6..72,400;6..72,500&display=swap');

:root {
  color-scheme: light;
  --ink: #23231f;
  --muted: #777269;
  --paper: #f5f2eb;
  --paper-deep: #e9e4d9;
  --accent: #d95d39;
  --line: rgba(35, 35, 31, 0.14);
  --serif: 'Newsreader', Georgia, serif;
  --mono: 'DM Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 13% 9%, rgba(255, 255, 255, 0.8), transparent 29%),
    var(--paper-deep);
  font-family: var(--serif);
}

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

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='.18'/%3E%3C/svg%3E");
  z-index: 10;
}

.shell {
  width: calc(100% - 32px);
  margin: 0 auto;
  padding: 14px 0 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
}

.presence {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.presence-dot {
  width: 7px;
  height: 7px;
  background: #aaa398;
  border-radius: 50%;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.presence.online .presence-dot {
  background: #5f8c61;
  box-shadow: 0 0 0 4px rgba(95, 140, 97, 0.12);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 22px;
}

.workspace {
  width: 100%;
  margin-top: 12px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h2 { margin: 0; font-weight: 400; }
h2 { font-size: 34px; letter-spacing: -0.025em; }

.text-button, .close-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.text-button {
  padding: 7px 0;
  border-bottom: 1px solid currentColor;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.text-button:hover { color: var(--accent); }

.editor-wrap {
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(35, 35, 31, 0.09);
  border-radius: 2px;
  box-shadow: 0 24px 60px rgba(57, 49, 37, 0.09), 0 2px 4px rgba(57, 49, 37, 0.05);
}

#editor {
  display: block;
  width: 100%;
  min-height: calc(100vh - 124px);
  max-height: none;
  resize: vertical;
  padding: clamp(28px, 5vw, 58px);
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--serif);
  font-size: clamp(19px, 2vw, 23px);
  line-height: 1.62;
  caret-color: var(--accent);
}

#editor::placeholder { color: #aaa59a; font-style: italic; }
#editor:disabled { opacity: 0.55; }

.editor-footer {
  display: flex;
  justify-content: space-between;
  padding: 13px clamp(18px, 3vw, 30px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.modal {
  width: min(440px, calc(100% - 32px));
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(31, 27, 21, 0.25);
}

.modal::backdrop { background: rgba(35, 32, 27, 0.54); backdrop-filter: blur(3px); }
.modal-symbol { display: block; margin-bottom: 34px; color: var(--accent); font-size: 30px; }
.modal p:not(.eyebrow, .error, .history-hint) { margin: 10px 0 25px; color: var(--muted); font-size: 17px; }

.modal input {
  width: 100%;
  padding: 13px 0;
  border: 0;
  border-bottom: 1px solid var(--ink);
  outline: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 13px;
}

.modal input:focus { border-color: var(--accent); }
.error { min-height: 18px; margin: 8px 0; color: #a83b2a; font-family: var(--mono); font-size: 10px; }

.primary-button {
  width: 100%;
  margin-top: 15px;
  padding: 14px 18px;
  border: 1px solid var(--ink);
  color: var(--paper);
  background: var(--ink);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.primary-button:hover { background: var(--accent); border-color: var(--accent); }

.history-modal { width: min(560px, calc(100% - 32px)); }
.history-header { display: flex; align-items: start; justify-content: space-between; }
.close-button { padding: 0; color: var(--muted); font-size: 29px; line-height: 1; }
.history-list { display: grid; gap: 8px; max-height: 42vh; margin-top: 28px; overflow-y: auto; }
.history-empty { padding: 30px 0; color: var(--muted); font-style: italic; }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.history-item:hover { color: var(--accent); }
.history-item span { font-family: var(--mono); font-size: 11px; }
.history-item small { color: var(--muted); font-family: var(--mono); font-size: 9px; }
.history-hint { margin: 22px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

@media (max-width: 600px) {
  .shell { width: calc(100% - 16px); padding-top: 8px; }
  .topbar { height: 40px; padding-bottom: 8px; }
  .topbar-actions { gap: 12px; }
  .presence { font-size: 9px; }
  .workspace { margin-top: 8px; }
  #editor { min-height: calc(100vh - 112px); padding: 24px 20px; }
  .modal { padding: 28px 24px; }
  .editor-footer { padding-inline: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
