:root {
  --bg: #090a0e;
  --paper: #e7e2d6;
  --muted: #a39e93;
  --faint: #7d7870;
  --gold: #e7d7b1;
  --rose: #d7a097;
  --line: rgba(231, 226, 214, 0.1);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Songti SC", "STSong", "Noto Serif CJK SC", "WenQuanYi Micro Hei", serif;
  --sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "WenQuanYi Micro Hei", "Microsoft YaHei", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(ellipse at 38% 42%, #141820 0%, transparent 46%),
    var(--bg);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

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

button { cursor: pointer; }

::selection { background: rgba(231, 215, 177, 0.28); }

.booting {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  margin: 0;
  letter-spacing: 0.42em;
  color: var(--muted);
  font-family: var(--serif);
}

.booting button {
  margin-top: 18px;
  background: transparent;
  border: 1px solid rgba(231, 215, 177, 0.4);
  color: var(--gold);
  border-radius: 999px;
  padding: 8px 18px;
  letter-spacing: 0.28em;
}

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  position: relative;
  padding: 32px 20px;
}

.gate canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.gate-glow {
  position: absolute;
  width: min(420px, 80vw);
  height: min(420px, 80vw);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(231, 215, 177, 0.2), rgba(231, 215, 177, 0.04) 42%, transparent 70%);
  transform: translateY(-36px);
  animation: glow 8s ease-in-out infinite;
  pointer-events: none;
}

.gate form {
  position: relative;
  z-index: 1;
  width: min(320px, 88vw);
  text-align: center;
}

.gate h1,
#shell h1,
.stream h2 {
  font-family: var(--serif);
  font-weight: 400;
}

.gate h1 {
  margin: 0;
  font-size: 44px;
  letter-spacing: 0.58em;
  text-indent: 0.58em;
}

.lede {
  margin: 14px 0 36px;
  color: var(--muted);
  letter-spacing: 0.28em;
  font-size: 13px;
}

.pw { display: block; }

.pw span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.pw input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(231, 226, 214, 0.32);
  text-align: center;
  padding: 12px 0;
  letter-spacing: 0.28em;
  outline: none;
  border-radius: 0;
}

.pw input:focus { border-bottom-color: var(--gold); }

.pw input::placeholder {
  color: rgba(231, 226, 214, 0.34);
  letter-spacing: 0.32em;
}

.gate button[type="submit"] {
  margin-top: 28px;
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(231, 215, 177, 0.45);
  border-radius: 999px;
  padding: 8px 28px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
}

.gate button[type="submit"]:disabled { opacity: 0.45; }

.err {
  min-height: 1.4em;
  margin: 18px 0 0;
  color: var(--rose);
  font-size: 13px;
  letter-spacing: 0.08em;
}

#shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "head head"
    "stage stream";
}

header {
  grid-area: head;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 22px 28px 6px;
}

header h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.46em;
  line-height: 1;
}

.sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.24em;
}

.sample {
  margin-left: 10px;
  color: var(--gold);
  letter-spacing: 0.2em;
}

.clockblock {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

#clock {
  margin: 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  font-size: 14px;
}

.tz {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.16em;
}

#quiet-note { color: #b7c0d4; }

.linkish {
  margin-top: 4px;
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--muted);
  letter-spacing: 0.22em;
}

.linkish:hover { color: var(--paper); }

#stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ring-label {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  color: rgba(231, 226, 214, 0.62);
  font-size: 11px;
  letter-spacing: 0.14em;
  white-space: nowrap;
  z-index: 1;
}

.ring-label time {
  display: block;
  color: var(--faint);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}

.ring-label.is-quiet { color: rgba(183, 192, 212, 0.7); }
.ring-label.is-off { opacity: 0.35; }
.ring-label.is-soon { color: var(--gold); }

.node {
  position: absolute;
  z-index: 2;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink, var(--paper));
}

.node[data-id="brainzh"] { z-index: 3; width: 84px; height: 84px; }

.disc {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background: radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.28) 72%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 42%, transparent);
}

.node[data-id="brainzh"] .disc {
  width: 84px;
  height: 84px;
  background: radial-gradient(circle, rgba(231, 215, 177, 0.2), rgba(231, 215, 177, 0.04) 64%, transparent 74%);
  box-shadow: inset 0 0 0 1px rgba(231, 215, 177, 0.5);
}

.halo {
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--ink) 48%, transparent), transparent 68%);
  opacity: 0.22;
  z-index: -1;
  animation: rest 8.5s ease-in-out infinite;
}

.node[data-id="brainzh"] .halo { inset: -28px; opacity: 0.55; }

.node[data-status="working"] .halo {
  animation-name: work;
  animation-duration: 3.6s;
  opacity: 0.7;
}

.node[data-id="claude"][data-status="working"] .halo { animation-duration: 6.2s; }
.node[data-id="hermes"][data-status="working"] .halo { animation-duration: 1.15s; }
.node[data-id="codex"][data-status="working"] .halo { animation-duration: 2.8s; }
.node[data-id="cursor"][data-status="working"] .glyph { animation: caret 1.2s steps(1, end) infinite; }

.node[data-id="workbuddy"] .halo { animation: none; opacity: 0.12; }
.node[data-id="workbuddy"] { opacity: 0.62; }
.node[data-status="idle"] { opacity: 0.78; }
.node[data-id="workbuddy"][data-status="idle"] { opacity: 0.55; }
.node[data-status="working"],
.node[data-status="done"] { opacity: 1; }

.node svg { width: 22px; height: 22px; display: block; }
.node[data-id="brainzh"] svg { width: 30px; height: 30px; }

.meta {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  width: 168px;
  margin-left: -84px;
  text-align: center;
}

.node[data-side="n"] .meta {
  top: auto;
  bottom: calc(100% + 8px);
  display: flex;
  flex-direction: column-reverse;
}

.node[data-side="e"] .meta,
.node[data-side="w"] .meta {
  top: 50%;
  bottom: auto;
  margin-left: 0;
  width: 148px;
  transform: translateY(-50%);
}

.node[data-side="e"] .meta { left: calc(100% + 10px); text-align: left; }
.node[data-side="w"] .meta { left: auto; right: calc(100% + 10px); text-align: right; }

.name {
  display: block;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--paper);
}

.role {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.caption {
  display: none;
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: color-mix(in srgb, var(--ink) 78%, white);
}

.node[data-status="working"] .caption,
.node[data-status="done"] .caption {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.node.is-selected .disc {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 75%, transparent);
}

.node:focus-visible .disc,
.gate button:focus-visible,
.linkish:focus-visible,
.booting button:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 4px;
}

.stream {
  grid-area: stream;
  min-height: 0;
  overflow: auto;
  padding: 18px 26px 28px 8px;
  scrollbar-width: none;
}

.stream::-webkit-scrollbar { display: none; }

.reading { min-height: 96px; margin: 8px 0 26px; }

.reading .who {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.14em;
}

.reading .what {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.4;
  font-weight: 400;
}

.reading .more,
.reading .when {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.stream h2 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.36em;
  color: var(--muted);
}

.events {
  list-style: none;
  margin: 0;
  padding: 0;
}

.event {
  display: grid;
  grid-template-columns: 68px 1fr;
  column-gap: 8px;
  row-gap: 1px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  opacity: var(--fade, 1);
}

.event time {
  grid-row: 1 / span 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  padding-top: 2px;
}

.event .day { font-size: 11px; letter-spacing: 0.02em; }

.actor {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--actor, var(--paper));
}

.event .title { font-size: 14px; }
.event .detail { color: var(--muted); font-size: 12px; line-height: 1.45; }

.event.is-new { animation: drift 1s ease both; }

.notice {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.6;
}

.ribbon {
  display: none;
  grid-area: ribbon;
  padding: 4px 0 8px;
}

.ribbon ol {
  display: flex;
  gap: 18px;
  list-style: none;
  margin: 0;
  padding: 0 20px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.ribbon li {
  flex: 0 0 auto;
  min-width: 4.5em;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.ribbon time {
  display: block;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.ribbon .is-quiet { color: #b7c0d4; }
.ribbon .is-off { opacity: 0.4; }
.ribbon .is-soon { color: var(--gold); }

.signal {
  margin: 8px 0 0;
  color: var(--rose);
  font-size: 12px;
  letter-spacing: 0.08em;
}

@keyframes rest {
  0%, 100% { transform: scale(1); opacity: 0.28; }
  50% { transform: scale(1.06); opacity: 0.48; }
}

.node[data-id="brainzh"] .halo {
  animation-name: kernel;
}

@keyframes kernel {
  0%, 100% { transform: scale(1); opacity: 0.42; }
  50% { transform: scale(1.05); opacity: 0.7; }
}

@keyframes work {
  0%, 100% { transform: scale(0.96); opacity: 0.4; }
  50% { transform: scale(1.12); opacity: 0.85; }
}

@keyframes caret {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0.25; }
}

@keyframes drift {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: var(--fade, 1); transform: none; }
}

@keyframes glow {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@media (max-width: 860px) {
  body { overflow: auto; }

  #shell {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(560px, 74dvh) auto auto;
    grid-template-areas:
      "head"
      "stage"
      "ribbon"
      "stream";
  }

  header { padding: 18px 20px 4px; }
  header h1 { font-size: 24px; }

  .stream {
    padding: 8px 20px 36px;
    overflow: visible;
  }

  .ribbon { display: block; }

  .ring-label { display: none; }

  .node { width: 42px; height: 42px; }
  .node[data-id="brainzh"] { width: 70px; height: 70px; }
  .disc { width: 42px; height: 42px; }
  .node[data-id="brainzh"] .disc { width: 70px; height: 70px; }
  .meta { width: 112px; margin-left: -56px; }
  .node[data-side="e"] .meta,
  .node[data-side="w"] .meta { width: 108px; }
  .caption { font-size: 10px; }
}

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