:root {
  --paper: #f1f3ee;
  --paper-deep: #e6eae3;
  --ink: #16211b;
  --ink-soft: #5a6862;
  --rule: #cbd3cc;
  --tide: #1f6f5c;
  --signal: #c96a16;
  --sepia: #f3ece0;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Newsreader", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --rail: 46px;
  --step: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

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

.mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- shell ---------- */

.app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  margin: 0;
}
.wordmark span { color: var(--tide); }

.topbar .spacer { flex: 1; }

.who { display: flex; align-items: center; gap: 8px; }

.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  object-fit: cover;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
  flex: none;
}

.link-btn {
  background: none; border: 0; padding: 0;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-soft); cursor: pointer;
  border-bottom: 1px solid transparent;
}
.link-btn:hover { color: var(--ink); border-bottom-color: var(--rule); }

.main { flex: 1; display: flex; min-height: 0; }

/* ---------- wave list ---------- */

.sidebar {
  width: 264px; flex: none;
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  padding: 16px 0 40px;
}

.sidebar h2 { margin: 0 20px 10px; }

.wave-item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0;
  border-left: 3px solid transparent;
  padding: 10px 20px; cursor: pointer;
}
.wave-item:hover { background: var(--paper-deep); }
.wave-item[aria-current="true"] {
  border-left-color: var(--tide);
  background: var(--paper-deep);
}
.wave-item .t { display: block; font-weight: 600; line-height: 1.3; }
.wave-item .m { display: block; margin-top: 3px; }

.new-wave {
  margin: 4px 20px 16px;
  display: flex; gap: 8px;
}
.new-wave input {
  flex: 1; min-width: 0;
  background: transparent;
  border: 0; border-bottom: 1px solid var(--rule);
  padding: 6px 0;
}
.new-wave input::placeholder { color: var(--ink-soft); }

.btn {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--ink); color: var(--paper);
  border: 0; border-radius: 2px;
  padding: 7px 12px; cursor: pointer;
}
.btn:hover { background: var(--tide); }
.btn.ghost {
  background: none; color: var(--ink-soft);
  border: 1px solid var(--rule);
}
.btn.ghost:hover { background: var(--paper-deep); color: var(--ink); }

/* ---------- wave ---------- */

.wave-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.wave-head {
  padding: 22px 28px 14px;
  border-bottom: 1px solid var(--rule);
}
.wave-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(24px, 3.4vw, 36px);
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0 0 10px;
  background: none; border: 0;
  width: 100%;
}

.roster { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.roster .avatar.live { border-color: var(--tide); box-shadow: 0 0 0 2px rgba(31,111,92,0.18); }
.roster .add {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px dashed var(--rule); background: none;
  color: var(--ink-soft); cursor: pointer; line-height: 1;
}
.roster .add:hover { border-color: var(--tide); color: var(--tide); }

/* the signature element: a time rail down the left edge */
.wave-body { flex: 1; display: flex; min-height: 0; }

.rail {
  width: var(--rail); flex: none;
  border-right: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}
.rail::before {
  content: ""; position: absolute;
  left: 50%; top: 12px; bottom: 12px;
  width: 1px; background: var(--rule);
}
.tick {
  position: absolute; left: 50%;
  width: 9px; height: 1px;
  transform: translateX(-50%);
  background: var(--rule);
}
.tick.mine { background: var(--tide); width: 15px; }
.rail-label {
  position: absolute; left: 0; right: 0; text-align: center;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em;
  color: var(--ink-soft);
}
.rail-label.top { top: 0; }
.rail-label.bottom { bottom: 0; }

.scroll { flex: 1; overflow-y: auto; padding: 26px 28px 120px; }

/* ---------- blips ---------- */

.blip { position: relative; padding-left: var(--step); }
.blip.depth-0 { padding-left: 0; }
.blip > .stem {
  position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 1px; background: var(--rule);
}
.blip.depth-0 > .stem { display: none; }

.blip-card { padding: 6px 0 4px; }

.blip-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 2px;
}
.blip-meta .name {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--tide); font-weight: 600;
}
.blip-meta .when { font-family: var(--mono); font-size: 10px; color: var(--ink-soft); }
.blip-meta .typing {
  font-family: var(--mono); font-size: 10px; color: var(--signal);
}

.blip-text {
  width: 100%;
  background: none; border: 0;
  resize: none; overflow: hidden;
  font-family: var(--body); font-size: 17px; line-height: 1.55;
  padding: 0; margin: 0;
}
.blip-text::placeholder { color: var(--ink-soft); font-style: italic; }
.blip-text:read-only { cursor: default; }

.blip-actions { display: flex; gap: 12px; margin-top: 4px; }
.blip:not(:hover) .blip-actions .link-btn { opacity: 0; }
.blip-actions .link-btn:focus-visible { opacity: 1; }

.empty {
  max-width: 34ch;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- admin ---------- */

.admin {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 80px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.admin-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(24px, 3.4vw, 34px);
  letter-spacing: -0.025em;
  margin: 0 0 6px;
}
.admin-note { margin: 0 0 20px; color: var(--ink-soft); max-width: 52ch; }
.admin-error { color: var(--signal); min-height: 1.2em; margin: 8px 0 0; font-size: 15px; }

.invite-row { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-row input {
  flex: 1; min-width: 200px;
  background: transparent; border: 0;
  border-bottom: 1px solid var(--rule); padding: 8px 0;
}
.invite-row select {
  background: transparent; border: 1px solid var(--rule);
  border-radius: 2px; padding: 7px 8px;
}

.people { margin-top: 22px; border-top: 1px solid var(--rule); }
.person {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--rule);
}
.person-who { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.person-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-state { font-size: 10px; }
.person-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.chip {
  border: 1px solid var(--rule); border-radius: 2px;
  padding: 2px 7px; font-size: 10px; color: var(--tide);
}

/* ---------- playback ---------- */

.playback {
  border-top: 1px solid var(--rule);
  padding: 12px 28px;
  display: flex; align-items: center; gap: 14px;
  background: var(--paper);
}
.playback input[type="range"] { flex: 1; accent-color: var(--signal); }
.playback .stamp { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); min-width: 15ch; }

.app.rewound { --paper: var(--sepia); }
.app.rewound .scroll { background: var(--sepia); }
.app.rewound .blip-meta .name { color: var(--signal); }
.app.rewound .rail::before { background: var(--signal); opacity: 0.45; }
.app.rewound .tick { background: var(--signal); opacity: 0.5; }

/* ---------- sign in ---------- */

.gate {
  max-width: 460px; margin: 0 auto; padding: 14vh 24px 40px;
}
.gate h1 {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(38px, 7vw, 62px);
  letter-spacing: -0.035em; line-height: 0.98; margin: 0 0 14px;
}
.gate h1 span { color: var(--tide); }
.gate p { margin: 0 0 26px; max-width: 40ch; }
.gate .btn { padding: 11px 18px; }
.gate hr { border: 0; border-top: 1px solid var(--rule); margin: 28px 0 18px; }
.gate .dev { display: flex; gap: 8px; }
.gate .dev input {
  flex: 1; background: none; border: 0;
  border-bottom: 1px solid var(--rule); padding: 8px 0;
}

.notice {
  margin-top: 14px; padding: 10px 12px;
  border-left: 2px solid var(--signal);
  background: var(--paper-deep);
  font-size: 15px;
}

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 9px 14px; border-radius: 2px;
  font-family: var(--mono); font-size: 12px;
  z-index: 50;
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .app.browsing .sidebar { display: block; width: 100%; border-right: 0; }
  .app.browsing .wave-pane { display: none; }
  .rail { display: none; }
  .scroll { padding: 20px 16px 100px; }
  .wave-head { padding: 16px 16px 12px; }
  .playback { padding: 10px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
