/* Agent journal as a flight recorder: day strip → pair tape with a playhead → the frame under it. */

.al {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding-bottom: calc(var(--s-8) + env(safe-area-inset-bottom, 0px));
}

/* ---------- Top bar ---------- */
.al-top {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.al-top__inner {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-height: calc(64px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
}
.al-top__right { margin-left: auto; }
.al-top__inner,
.al-main { max-width: calc(1080px + 2 * var(--gutter)); }
.al-main { padding-top: var(--s-6); }

.al-foot {
  max-width: 62ch;
  margin-top: var(--s-6);
  color: var(--text-3);
  font-size: var(--fs-14);
  line-height: 1.6;
}

/* ---------- Shared bits ---------- */
.bx .tabular { font-variant-numeric: tabular-nums; }
.bx ol,
.bx ul { margin: 0; padding: 0; list-style: none; }

/* Tone: one colour per outcome, used by dots, marks, rows and state lines. */
.bx-tone--ok   { --tone: var(--success); }
.bx-tone--warn { --tone: var(--warning); }
.bx-tone--bad  { --tone: var(--danger); }
.bx-tone--info { --tone: var(--text-3); }
.bx-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--tone, var(--text-3));
}

/* Segments of time: recorded is solid accent, missed is a warning hatch, no agent a danger hatch. */
.bx-seg--rec    { background: var(--accent); }
.bx-seg--missed { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--warning) 55%, transparent) 0 3px, transparent 3px 7px), color-mix(in srgb, var(--warning) 10%, transparent); }
.bx-seg--absent { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--danger) 55%, transparent) 0 3px, transparent 3px 7px), color-mix(in srgb, var(--danger) 8%, transparent); }
.bx-seg--idle,
.bx-seg--future { background: var(--surface-2); }
.bx-seg--future { opacity: .6; }
.bx-seg {
  position: absolute;
  top: 0;
  bottom: 0;
}
.bx-key {
  display: inline-block;
  flex: none;
  width: 14px;
  height: 10px;
  border-radius: 3px;
}

/* ---------- Heading ---------- */
.bx-headline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--s-2) var(--s-4);
  margin-bottom: var(--s-5);
}
.bx-title {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.bx-days {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.bx-days__label {
  min-width: 6.5em;
  text-align: center;
  font-weight: 600;
}
.bx-days .icon-btn[disabled] { opacity: .35; pointer-events: none; }
.bx-sum {
  grid-column: 1 / -1;
  color: var(--text-2);
}

/* ---------- Day strip ---------- */
.bx-deck {
  padding: var(--s-4) var(--s-4) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-inset);
}
.bx-day { position: relative; }
.bx-day__scale {
  position: relative;
  height: 16px;
  margin-bottom: var(--s-1);
}
.bx-day__hour {
  position: absolute;
  transform: translateX(-50%);
  color: var(--text-3);
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
}
.bx-day__lane {
  position: relative;
  height: 36px;
  border-radius: var(--r-sm);
  background: repeating-linear-gradient(90deg, var(--border) 0 1px, transparent 1px calc(100% / 12));
}
.bx-day__pair {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 18px;
  overflow: hidden;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.bx-day__pair:hover { transform: translateY(-1px); }
.bx-day__pair.is-on { outline-color: var(--text); }
.bx-day__pair:focus-visible { outline-color: var(--accent); }
.bx-day__code {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 10px;
  line-height: 1.4;
}
.bx-day__loose,
.bx-day__now {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  transform: translateX(-1px);
  pointer-events: none;
}
.bx-day__loose { background: var(--text-3); opacity: .5; }
.bx-day__now { background: var(--live); box-shadow: 0 0 0 1px var(--bg); }

/* ---------- The pair tape ---------- */
.bx-deck__tape {
  margin-top: var(--s-4);
  padding: var(--s-4) var(--s-4) var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}
.bx-deck__label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-18);
}
.bx-deck__label .pixel {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: var(--fs-12);
}

.bx-tape {
  --band: 44px;
  position: relative;
  padding-top: 30px;           /* room for the playhead flag above the scale labels */
  touch-action: pan-y;
  cursor: ew-resize;
  user-select: none;
}
.bx-tape__scale {
  position: relative;
  height: 18px;
}
.bx-tape__tick {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 5px;
  background: var(--border-strong);
}
.bx-tape__tick.is-major { height: 9px; background: var(--text-3); }
.bx-tape__tick span {
  position: absolute;
  bottom: 11px;
  left: 0;
  transform: translateX(-50%);
  color: var(--text-3);
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Steps stand on the band like pins: a stem and a head in the step's tone. */
.bx-tape__marks {
  position: relative;
  height: 30px;
}
.bx-mark {
  position: absolute;
  bottom: 0;
  width: 22px;
  height: 30px;
  margin-left: -11px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.bx-mark::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 18px;
  background: var(--tone);
  opacity: .6;
}
.bx-mark__dot {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  background: var(--tone);
  box-shadow: 0 0 0 2px var(--surface-raised);
  transform: translateX(-50%);
  transition: transform var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out);
}
.bx-mark:hover .bx-mark__dot { transform: translateX(-50%) scale(1.3); }
.bx-mark.is-current .bx-mark__dot {
  transform: translateX(-50%) scale(1.5);
  box-shadow: 0 0 0 2px var(--surface-raised), 0 0 0 4px color-mix(in srgb, var(--tone) 45%, transparent);
}

.bx-tape__band {
  position: relative;
  height: var(--band);
  overflow: visible;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--surface-2) 50%, transparent);
}
.bx-tape__band > .bx-seg:first-child { border-radius: 0; }
.bx-tape__edge {
  position: absolute;
  top: -4px;
  bottom: -18px;
  width: 0;
  border-left: 1px dashed var(--text-3);
}
.bx-tape__edge span {
  position: absolute;
  bottom: 0;
  left: 4px;
  color: var(--text-3);
  font-size: var(--fs-12);
  white-space: nowrap;
}
.bx-tape__edge.is-end span { left: auto; right: 4px; }

/* The playhead: a hairline across the whole tape with the time on a flag. One owner of `left`: this rule. */
.bx-head-line {
  position: absolute;
  top: 0;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
  background: var(--text);
  transition: left var(--dur-step) var(--ease-out);
  outline: none;
  z-index: 2;
}
.bx-tape.is-dragging .bx-head-line { transition: none; }
.bx-head-line__flag {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-12);
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  cursor: grab;
}
.bx-head-line:focus-visible .bx-head-line__flag { box-shadow: var(--focus-ring); }

/* ---------- Transport ---------- */
.bx-transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-5);
}
.bx-transport__keys {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.bx-transport .icon-btn[disabled] { opacity: .35; pointer-events: none; }
.bx-play {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 40px;
  padding: 0 var(--s-4) 0 var(--s-3);
  border: 0;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease-out);
}
.bx-play:hover { background: var(--accent-hover); }
.bx-play:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.bx-play svg { width: 16px; height: 16px; }
.bx-transport__count { color: var(--text-3); font-size: var(--fs-14); white-space: nowrap; }
.bx-legend {
  display: flex;
  gap: var(--s-4);
  color: var(--text-3);
  font-size: var(--fs-12);
}
.bx-legend li { display: flex; align-items: center; gap: 6px; }

/* ---------- Frame + pair panel ---------- */
.bx-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: var(--s-4);
  margin-top: var(--s-4);
}
.bx-frame,
.bx-side,
.bx-log {
  padding: var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.bx-frame { display: grid; align-content: start; gap: var(--s-4); }
.bx-frame__top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-2) var(--s-4);
}
.bx-frame__clock {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 7vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.bx-frame__state {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-2);
}
.bx-frame__state .bx-dot { width: 10px; height: 10px; }
.bx-tone--ok.bx-frame__state .bx-dot { animation: bx-rec 1.6s var(--ease-in-out) infinite; }
@keyframes bx-rec { 50% { opacity: .35; } }

.bx-step {
  display: grid;
  gap: var(--s-1);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--tone) 9%, var(--surface-raised));
  animation: bx-in var(--dur-state) var(--ease-out);
}
@keyframes bx-in { from { opacity: 0; transform: translateY(4px); } }
.bx-step__when { color: var(--text-3); font-size: var(--fs-14); }
.bx-step__title {
  font-family: var(--font-display);
  font-size: var(--fs-24);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-wrap: balance;
}
.bx-step__detail { color: var(--text-2); }
.bx-step__empty { color: var(--text-2); }

.bx-fix {
  display: grid;
  gap: var(--s-3);
  margin-top: var(--s-3);
}
.bx-fix__row { display: flex; gap: var(--s-2); }
.bx-fix__why {
  color: var(--text-2);
  font-size: var(--fs-14);
  line-height: 1.5;
}
.bx-step .bx-fix__why { margin-top: var(--s-2); }
.bx-fix__btn {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: var(--s-2);
  margin-top: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  background: var(--surface-raised);
  color: var(--text);
  font-weight: 600;
  font-size: var(--fs-14);
  cursor: pointer;
  transition: border-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.bx-fix__btn:hover { border-color: var(--accent); color: var(--accent-text); }
.bx-fix__btn:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.bx-fix__btn svg { width: 16px; height: 16px; }
a.bx-fix__btn { text-decoration: none; }

/* Links the agent saved from the pair's chat (ROADMAP-26.09 §31). */
.bx-side__sub { margin-top: var(--s-2); color: var(--text-3); font-size: var(--fs-12); font-weight: 600; }
.bx-links { display: grid; gap: var(--s-1); margin: 0; padding: 0; list-style: none; }
.bx-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s-2);
  padding: var(--s-1) 0;
  color: var(--text-2);
  font-size: var(--fs-14);
  text-decoration: none;
}
.bx-link__time { color: var(--text-3); }
.bx-link__url { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--accent-text); }
.bx-link:hover .bx-link__url { text-decoration: underline; }

.bx-frame__next {
  display: block;
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
}
.bx-frame__next:hover { color: var(--accent-text); }
.bx-frame__next svg { display: inline-block; width: 16px; height: 16px; margin-left: var(--s-1); vertical-align: -3px; }

.bx-side { display: grid; align-content: start; gap: var(--s-3); }
.bx-side__title {
  font-size: var(--fs-18);
  line-height: 1.25;
}
.bx-side__meta { color: var(--text-2); font-size: var(--fs-14); }
.bx-parts,
.bx-calls { display: grid; gap: 2px; }
.bx-part {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  padding: 6px var(--s-2);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  font-size: var(--fs-14);
  text-align: left;
  cursor: pointer;
}
.bx-part:hover { background: var(--spot); }
.bx-part__why { color: var(--text-2); }
.bx-call {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-14);
}
.bx-side__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ---------- All steps ---------- */
.bx-log { margin-top: var(--s-4); }
.bx-log__title {
  margin-bottom: var(--s-3);
  font-size: var(--fs-18);
}
.bx-rows { display: grid; }
.bx-row {
  display: grid;
  grid-template-columns: 5.5em auto minmax(0, 1fr);
  align-items: baseline;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  text-align: left;
}
button.bx-row { cursor: pointer; }
button.bx-row:hover { background: var(--spot); }
button.bx-row:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.bx-row.is-current { background: var(--accent-soft); }
.bx-row .bx-dot { transform: translateY(-1px); }
.bx-row__time { color: var(--text-3); font-size: var(--fs-14); }
.bx-row__body { display: grid; gap: 2px; }
.bx-row__title { font-weight: 600; }
.bx-row__detail { color: var(--text-2); font-size: var(--fs-14); }

/* ---------- Empty day ---------- */
.bx-empty {
  display: grid;
  justify-items: center;
  gap: var(--s-4);
  padding: var(--s-8) var(--s-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  color: var(--text-2);
  text-align: center;
}

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  .bx-grid { grid-template-columns: minmax(0, 1fr); }
  .bx-headline { grid-template-columns: minmax(0, 1fr); }
  .bx-days { justify-self: start; }
  .bx-deck { padding: var(--s-3); }
  .bx-deck__tape { padding: var(--s-3) var(--s-3) var(--s-2); }
  .bx-frame, .bx-side, .bx-log { padding: var(--s-4); }
  .bx-legend { display: none; }
  .bx-row { grid-template-columns: 3.4em auto minmax(0, 1fr); gap: var(--s-2); padding: var(--s-2); }
}

@media (prefers-reduced-motion: reduce) {
  .bx-head-line { transition: none; }
  .bx-step { animation: none; }
  .bx-tone--ok.bx-frame__state .bx-dot { animation: none; }
}
