/* Tangleberry UI-01 — clean SaaS look: light surfaces, charcoal type, lilac accents, no gradients.
   Top navigation only, no sidebar (D-023 / I07). Mobile-first responsive. */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1c1c22;
  background: #f6f6f8;
  line-height: 1.5;
  padding-bottom: 3rem;
}

/* ---- top navigation ---- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  padding: 0.6rem 1.1rem;
  background: #ffffff;
  border-bottom: 1px solid #e4e4ea;
}
.topnav-brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #1c1c22;
}
.brand-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  background: #8b7cc7;
  display: inline-block;
}
.topnav-links { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.navlink {
  background: transparent;
  color: #4a4a55;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.38rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.navlink:hover { background: #f1eefb; color: #5b4b9e; }
.navlink.active { background: #eae4f8; color: #5b4b9e; border-color: #d9cfef; font-weight: 600; }
.navlink:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid #8b7cc7;
  outline-offset: 2px;
}
.topnav-tools { display: flex; align-items: center; gap: 0.55rem; margin-left: auto; }
.project-picker select {
  max-width: 42vw;
  border-radius: 8px;
  border: 1px solid #d4d4dc;
  background: #fff;
  color: #1c1c22;
  padding: 0.35rem 0.55rem;
  margin: 0;
}
.badge {
  font-size: 0.75rem;
  background: #efeef4;
  color: #4a4a55;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  white-space: nowrap;
}
.badge.on { background: #e7f2e9; color: #2c6e3a; }

/* ---- layout ---- */
#main { max-width: 64rem; margin: 0 auto; padding: 1.1rem 0.9rem; }
.panel { display: block; }
.panel.narrow { max-width: 26rem; margin: 2.5rem auto; }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.hidden { display: none !important; }
h1 { font-size: 1.35rem; margin: 0 0 0.75rem; letter-spacing: -0.01em; }
.panel-head h1 { margin: 0; }
h2 { font-size: 1.02rem; margin: 0.25rem 0 0.7rem; }
.hint { color: #6b6b76; font-size: 0.88rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.card {
  background: #fff;
  border: 1px solid #e4e4ea;
  border-radius: 12px;
  padding: 1.05rem 1.15rem;
  margin-bottom: 0.85rem;
}
.card.dim { background: #fafafc; }
.cards { list-style: none; margin: 0; padding: 0; }
.cards li {
  background: #fff;
  border: 1px solid #e4e4ea;
  border-radius: 12px;
  padding: 0.85rem 1.05rem;
  margin-bottom: 0.65rem;
  cursor: pointer;
}
.cards li:hover { border-color: #b9a8e3; }
.cards li.selected { border-color: #8b7cc7; box-shadow: 0 0 0 1px #8b7cc7; }
.cards .meta { color: #7a7a86; font-size: 0.8rem; margin-top: 0.25rem; }
.cards .body { margin-top: 0.4rem; color: #3c3c46; font-size: 0.92rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 0.45rem 0; border-bottom: 1px solid #eeeef2; }
.list li.disabled { color: #a0a0ac; }

.empty {
  background: #fff;
  border: 1px dashed #d4d4dc;
  border-radius: 12px;
  padding: 1.6rem 1.2rem;
  text-align: center;
  margin-bottom: 0.85rem;
}
.empty p { margin: 0.3rem 0; }

.toolbar { margin-bottom: 0.8rem; }
.toolbar input { margin: 0; }

/* ---- forms ---- */
input, textarea, select, button {
  font: inherit;
  width: 100%;
  margin: 0.25rem 0 0.8rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #d4d4dc;
  border-radius: 8px;
  background: #fff;
  color: #1c1c22;
}
label { display: block; font-size: 0.88rem; font-weight: 600; color: #3c3c46; }
.row { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.row > div { flex: 1 1 8rem; }
button { width: auto; cursor: pointer; font-weight: 600; }
button.primary { background: #6f5bb5; color: #fff; border-color: #6f5bb5; padding: 0.6rem 1.2rem; }
button.primary:hover { background: #5b4b9e; }
button.danger { background: #fff; color: #a83232; border: 1px solid #d9a5a5; padding: 0.6rem 1.2rem; }
button.danger:hover { background: #fdf1f1; }
button.ghost { background: #fff; color: #4a4a55; border: 1px solid #d4d4dc; padding: 0.55rem 1rem; }
button.ghost:hover { background: #f4f4f7; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.readonly {
  border: 1px solid #e4e4ea;
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  background: #fafafc;
  margin-bottom: 0.8rem;
}
.readonly code { font-size: 0.8rem; word-break: break-all; color: #5b4b9e; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.9rem; margin: 0.35rem 0; }
.kv dt { font-size: 0.8rem; color: #7a7a86; }
.kv dd { margin: 0; font-size: 0.85rem; }

/* ---- pills / status ---- */
.pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.14rem 0.6rem;
  background: #efeef4;
  color: #4a4a55;
  margin-right: 0.35rem;
}
.pill.pending { background: #fdf3d8; color: #8a6d1c; }
.pill.rejected { background: #fbe4e4; color: #a83232; }
.pill.accepted { background: #e7f2e9; color: #2c6e3a; }
.pill.rev { background: #eae4f8; color: #5b4b9e; }

/* ---- timeline ---- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.2rem; border-left: 2px solid #e4e4ea; }
.timeline li { position: relative; padding: 0 0 1rem 1rem; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -1.53rem;
  top: 0.45rem;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: #8b7cc7;
  border: 2px solid #fff;
}
.timeline .meta { color: #7a7a86; font-size: 0.78rem; margin-top: 0.15rem; }
.timeline .desc { margin-top: 0.3rem; font-size: 0.92rem; }
.timeline .kind { font-size: 0.72rem; font-weight: 600; color: #5b4b9e; text-transform: uppercase; letter-spacing: 0.04em; }
.timeline li.diff-holder { padding-top: 0; padding-bottom: 0.8rem; }
.timeline li.diff-holder::before { display: none; }

/* ---- expandable technical details ---- */
details.tech {
  margin-top: 0.45rem;
  border: 1px solid #e4e4ea;
  border-radius: 8px;
  background: #fafafc;
}
details.tech > summary {
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  color: #6b6b76;
  user-select: none;
}
details.tech[open] > summary { border-bottom: 1px solid #e4e4ea; }
details.tech pre {
  margin: 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.78rem;
  overflow-x: auto;
  color: #4a4a55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- revision diff table ---- */
.diff-table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.82rem; }
.diff-table th, .diff-table td {
  border: 1px solid #e4e4ea;
  padding: 0.35rem 0.55rem;
  text-align: left;
  vertical-align: top;
}
.diff-table th { background: #f4f2fb; color: #5b4b9e; font-size: 0.75rem; }
.diff-old { background: #fdf1f1; color: #7c2626; }
.diff-new { background: #f2f7f2; color: #2c6e3a; }

/* ---- handoff ---- */
.handoff-actions button { margin-top: 0; }
.handoff-preview {
  background: #fafafc;
  border: 1px solid #e4e4ea;
  border-radius: 8px;
  padding: 1rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 32rem;
  overflow-y: auto;
  color: #2a2a33;
  margin: 0;
}
.panel-head .actions { margin: 0; }

/* ---- feedback ---- */
.error { color: #a83232; font-size: 0.88rem; min-height: 1.2em; }
.conflict {
  background: #fdf1f1;
  border: 1px solid #d9a5a5;
  color: #7c2626;
  border-radius: 8px;
  padding: 0.8rem 0.95rem;
  margin: 0.5rem 0;
}
.receipt {
  background: #f2f7f2;
  border: 1px solid #b7d8bc;
  border-radius: 8px;
  padding: 0.8rem 0.95rem;
  margin-top: 0.75rem;
  font-size: 0.88rem;
}
.receipt code { word-break: break-all; color: #2c6e3a; }
.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1c22;
  color: #fff;
  border-radius: 8px;
  padding: 0.65rem 1.2rem;
  font-size: 0.9rem;
  z-index: 50;
}
.foot { text-align: center; color: #9a9aa6; font-size: 0.78rem; padding: 1.2rem; }

/* ---- write lease bar (UI-04) ---- */
.leasebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1.1rem;
  background: #f4f2fb;
  border-bottom: 1px solid #e4e4ea;
  font-size: 0.88rem;
}
.leasebar .lease-actions { display: flex; gap: 0.45rem; margin-left: auto; }
.leasebar .lease-actions button { margin: 0; padding: 0.42rem 0.85rem; font-size: 0.84rem; }
.lease-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.14rem 0.6rem;
  margin-right: 0.35rem;
}
.lease-pill.free { background: #e7f2e9; color: #2c6e3a; }
.lease-pill.mine { background: #eae4f8; color: #5b4b9e; }
.lease-pill.busy { background: #fdf3d8; color: #8a6d1c; }

/* ---- auth screen ---- */
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 1.35rem;
  margin-bottom: 1rem;
  color: #1c1c22;
}
.auth-tabs {
  display: flex;
  gap: 0.35rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  border-bottom: 1px solid #e4e4ea;
}
.auth-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: #6b6b76;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  margin: 0;
}
.auth-tab.active { color: #5b4b9e; border-bottom-color: #8b7cc7; }
.auth-tab:hover { background: #f1eefb; }
.pw-row { display: flex; gap: 0.5rem; align-items: flex-start; }
.pw-row input { flex: 1; margin-right: 0; }
.pw-toggle {
  white-space: nowrap;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  padding: 0.55rem 0.75rem;
}
button.wide { width: 100%; margin-top: 0.4rem; }

/* ---- responsive ---- */
@media (max-width: 640px) {
  .topnav { padding: 0.55rem 0.65rem; }
  .topnav-brand { width: 100%; }
  .topnav-tools { width: 100%; margin-left: 0; }
  .project-picker { flex: 1; }
  .project-picker select { max-width: 100%; margin: 0; }
  .navlink { flex: 1 1 30%; text-align: center; padding: 0.5rem 0.35rem; font-size: 0.83rem; }
  h1 { font-size: 1.15rem; }
  .actions button { flex: 1 1 45%; }
  .row > div { flex: 1 1 100%; }
}

/* Live preview additions reuse existing cards, typography and lilac accents. */
#timeEvents code, #snapList pre, .kv dd { overflow-wrap: anywhere; word-break: break-word; }
#snapList pre { white-space: pre-wrap; max-height: 24rem; overflow: auto; }
#snapList textarea { width: 100%; }
#snapList button { min-height: 44px; }
@media (max-width: 540px) { .topnav-tools { flex-wrap: wrap; width: 100%; margin-left: 0; } .badge { max-width: 100%; overflow-wrap: anywhere; white-space: normal; } .topnav-links { width: 100%; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

@media (max-width: 640px) {
  .topnav-links { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; min-width: 0; padding-bottom: .3rem; }
  .topnav-links .navlink { flex: 0 0 auto; min-height: 44px; white-space: nowrap; padding-inline: .7rem; }
}
#memoryList pre, #timeEvents pre { white-space: pre-wrap; overflow-wrap: anywhere; }
