:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #1d2433; --muted: #6b7280; --line: #e3e6eb;
  --accent: #e8a33d; --accent-ink: #8a5a12; --teal: #2f7f86; --dark: #12151c;
  --term-bg: #16181d; --term-ink: #d9dde4; --term-dim: #8b93a1; --claude: #d97757;
  --stage-w: 1675; --stage-h: 820;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
button { font: inherit; cursor: pointer; }
#app { height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr) 310px;
  grid-template-rows: 48px minmax(0, 1fr) 70px; grid-template-areas: "top top top" "nav main notes" "bar bar bar"; }
#app.noNav { grid-template-columns: 0 minmax(0, 1fr) 310px; }
#app.noNotes { grid-template-columns: 230px minmax(0, 1fr) 0; }
#app.noNav.noNotes { grid-template-columns: 0 minmax(0, 1fr) 0; }
#app.noNav #nav, #app.noNotes #notes { display: none; }

/* header */
#top { grid-area: top; display: flex; align-items: center; gap: 16px; padding: 0 14px; background: var(--panel);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.brand span { color: var(--muted); }
.tag { color: var(--muted); font-size: 12px; letter-spacing: .02em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; gap: 6px; }
.tools button, .tools a { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px;
  padding: 3px 11px; font-size: 12.5px; text-decoration: none; }
.tools button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* chapter list */
#nav { grid-area: nav; overflow: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 8px 0 20px; }
#nav .grp { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 12px 14px 4px; }
#nav button { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; width: 100%; border: 0;
  background: none; text-align: left; padding: 6px 12px 6px 14px; color: var(--ink); }
#nav button:hover { background: #f2f3f6; }
#nav button .n { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); font-size: 11px;
  display: grid; place-items: center; color: var(--muted); }
#nav button .d { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
#nav button.done .n { background: #eef6f6; color: var(--teal); border-color: #cfe5e6; }
#nav button.cur { background: #fff7ea; box-shadow: inset 3px 0 0 var(--accent); }
#nav button.cur .n { background: var(--ink); color: #fff; border-color: var(--ink); }

/* stage */
#main { grid-area: main; display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; }
#stageWrap { position: relative; overflow: hidden; display: grid; place-items: center; padding: 14px 14px 6px; }
#stage { position: absolute; width: calc(var(--stage-w) * 1px); height: calc(var(--stage-h) * 1px); transform-origin: 0 0;
  display: grid; grid-template-columns: 380px 1fr; grid-template-rows: minmax(0, 1fr); border-radius: 12px; overflow: hidden;
  box-shadow: 0 10px 40px rgba(16, 24, 40, .18), 0 0 0 1px rgba(16, 24, 40, .08); background: #fff; }

/* the replayed Claude Code terminal */
#stage.noTerm { grid-template-columns: 1fr; }
#stage.noTerm #term { display: none; }
#term { background: var(--term-bg); color: var(--term-ink); display: grid; grid-template-rows: 30px minmax(0, 1fr);
  font: 12px/1.5 "SF Mono", Menlo, Consolas, monospace; border-right: 1px solid #000; }
.tbar { display: flex; align-items: center; gap: 7px; padding: 0 12px; background: #23262d; color: #9aa3b2; font-size: 12px; }
.tbar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.tbar i:nth-child(2) { background: #febc2e; } .tbar i:nth-child(3) { background: #28c840; }
.tbar span { margin-left: 10px; }
#term, #appwin { min-height: 0; }
#tbody { min-height: 0; overflow: hidden; padding: 12px 14px 14px; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
#tbody .scroll { overflow: hidden; display: flex; flex-direction: column; }
#tbody .scroll > :first-child { margin-top: auto; }
.t-welcome { border: 1px solid var(--claude); border-radius: 6px; padding: 8px 12px; margin-bottom: 14px; color: var(--term-ink); }
.t-welcome b { color: var(--claude); }
.t-welcome div { color: var(--term-dim); font-size: 12px; }
.t-user { background: #2a2d34; border-radius: 4px; padding: 6px 10px; margin: 12px 0 10px; color: #f1f3f6; white-space: pre-wrap; }
.t-user::before { content: "> "; color: var(--term-dim); }
.t-user.from-app::after { content: "sent by the app"; display: block; color: var(--term-dim); font-size: 11px; margin-top: 2px; }
.t-line { position: relative; padding-left: 18px; margin: 6px 0; white-space: pre-wrap; word-wrap: break-word; }
.t-line::before { content: "⏺"; position: absolute; left: 0; color: var(--term-ink); font-size: 12px; }
.t-tool::before { color: #4fb37e; }
.t-tool.err::before { color: #e5534b; }
.t-tool .nm { font-weight: 600; }
.t-tool .args { color: var(--term-dim); }
.t-out { color: var(--term-dim); padding-left: 18px; margin-top: 1px; white-space: pre-wrap; }
.t-out::before { content: "⎿  "; }
.t-text b { color: #fff; }
.t-text code { color: #c9a0ff; }
.t-spin { color: var(--claude); margin: 8px 0 0; }
.t-done { color: var(--term-dim); font-size: 12px; margin-top: 8px; }
.t-prompt { border-top: 1px solid #3a3e47; border-bottom: 1px solid #3a3e47; margin-top: 12px; padding: 6px 2px; color: var(--term-dim); }
.t-prompt .typed { color: #f1f3f6; }
.t-prompt .caret { display: inline-block; width: 7px; height: 14px; background: #c8ccd4; vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* the app window */
#appwin { position: relative; background: #fff; overflow: hidden; }
#appscale { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#frame { width: 100%; height: 100%; border: 0; display: block; }
#fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#spot { position: absolute; border-radius: 8px; box-shadow: 0 0 0 3px var(--accent), 0 0 0 9999px rgba(15, 20, 30, .28);
  opacity: 0; transition: all .45s cubic-bezier(.3, .7, .2, 1); }
#spot.on { opacity: 1; }
#spotLabel { position: absolute; background: var(--accent); color: #2a1a00; font-weight: 600; font-size: 13px; padding: 3px 10px;
  border-radius: 6px; white-space: nowrap; opacity: 0; transition: opacity .3s, left .45s, top .45s; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
#spotLabel.on { opacity: 1; }
#cursor { position: absolute; left: 0; top: 0; transform: translate(-3px, -2px); transition: left .7s cubic-bezier(.4, .1, .2, 1), top .7s cubic-bezier(.4, .1, .2, 1);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); opacity: 0; }
#cursor.on { opacity: 1; }
#ripple { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 3px solid var(--accent); opacity: 0; }
#ripple.go { animation: ripple .55s ease-out; }
@keyframes ripple { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
#shield { position: absolute; inset: 0; cursor: not-allowed; }
#app.paused #shield { display: none; }
/* paused: the hint sits in the control bar, in place of the step's name, so it covers nothing of the app */
#pill { background: var(--ink); color: #fff; font-size: 12.5px; padding: 4px 12px; border-radius: 999px; display: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; margin-right: auto; }
#app.paused #pill { display: inline-block; }
#app.paused #where { display: none; }
#loading { position: absolute; inset: 0; background: rgba(255,255,255,.78); display: none; place-items: center; color: var(--muted); font-size: 15px; z-index: 3; }
#loading.on { display: grid; }

/* captions */
#caption { min-height: 64px; padding: 6px 28px 12px; text-align: center; font-size: 16.5px; line-height: 1.5; color: var(--ink); }
#caption b { color: var(--accent-ink); }
#app.noCap #caption { visibility: hidden; min-height: 10px; padding: 0; }

/* notes */
#notes { grid-area: notes; overflow: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 14px 16px 24px; }
#notes .chip { display: inline-block; border: 1px solid var(--line); border-radius: 999px; font-size: 11.5px; padding: 1px 9px; color: var(--muted); }
#notes h2 { font-size: 18px; margin: 8px 0 4px; }
#notes .sum { color: #374151; margin: 0 0 12px; }
#notes .card { background: #f7f8fa; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
#notes .card .k { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
#notes .card h3 { font-size: 15px; margin: 2px 0 6px; }
#notes .card ul { margin: 0; padding-left: 18px; color: #374151; }
#notes .card li { margin: 3px 0; }
#notes .tip { margin-top: 8px; font-size: 12.5px; background: #fff7ea; border: 1px solid #f5dcaf; border-radius: 8px; padding: 6px 9px; }
#notes .steps { margin-top: 14px; }
#notes .steps .k { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
#notes .steps button { display: grid; grid-template-columns: 20px 1fr; gap: 6px; width: 100%; text-align: left; border: 0; background: none;
  padding: 4px 6px; border-radius: 6px; color: var(--ink); font-size: 13px; }
#notes .steps button:hover { background: #f2f3f6; }
#notes .steps button .i { color: var(--muted); font-variant-numeric: tabular-nums; }
#notes .steps button.done .i::before { content: "✓"; color: var(--teal); }
#notes .steps button.done .i span { display: none; }
#notes .steps button.cur { background: #fff7ea; font-weight: 600; }

/* transport */
#bar { grid-area: bar; background: var(--panel); border-top: 1px solid var(--line); padding: 8px 16px 6px; }
#track { position: relative; height: 16px; cursor: pointer; }
#segs { position: absolute; inset: 5px 0; display: flex; gap: 3px; }
#segs div { background: #dfe2e8; border-radius: 3px; height: 6px; position: relative; }
#segs div:hover { background: #cdd2da; }
#fill { position: absolute; left: 0; top: 5px; height: 6px; background: var(--accent); border-radius: 3px; pointer-events: none;
  mix-blend-mode: multiply; }
#knob { position: absolute; top: 1px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #fff;
  border: 3px solid var(--accent); pointer-events: none; }
#hoverTip { position: absolute; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap; display: none; pointer-events: none; }
.ctl { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.ctl button { border: 0; background: none; color: var(--ink); font-size: 14px; padding: 4px 8px; border-radius: 6px; }
.ctl button:hover { background: #f2f3f6; }
.ctl .play { width: 38px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 14px; }
.ctl .play:hover { background: #000; }
#time { font-variant-numeric: tabular-nums; color: var(--muted); margin-left: 8px; font-size: 13px; }
#where { flex: 1; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#where span { color: var(--muted); }
#bSpeed { border: 1px solid var(--line) !important; border-radius: 999px !important; font-size: 12px !important; }

dialog#help { border: 0; border-radius: 12px; padding: 18px 22px; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog#help h3 { margin-top: 0; }
dialog#help li { margin: 6px 0; }
dialog#help button { border: 0; background: var(--ink); color: #fff; padding: 6px 16px; border-radius: 999px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 16px;
  border-radius: 8px; font-size: 13px; z-index: 50; max-width: 560px; text-align: center; }

@media (max-width: 1100px) {
  #app { grid-template-columns: 0 minmax(0, 1fr) 0; }
  #nav, #notes { display: none; }
}
#small { display: none; }
@media (max-width: 760px) {
  #app { display: none; }
  #small { display: block; padding: 40px 24px; text-align: center; }
}

/* the desktop app's file dialog, drawn by the player */
.picker { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); width: 560px; background: #f6f6f6; border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0,0,0,.35), 0 0 0 1px rgba(0,0,0,.15); font: 13px -apple-system, sans-serif; color: #222; overflow: hidden; z-index: 6; }
.picker .ph { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: #e9e9e9; border-bottom: 1px solid #d4d4d4; }
.picker .ph .dots i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; margin-right: 6px; }
.picker .ph .dots i:nth-child(2) { background: #febc2e; } .picker .ph .dots i:nth-child(3) { background: #28c840; }
.picker .pp { padding: 7px 14px; color: #555; border-bottom: 1px solid #e0e0e0; background: #fafafa; }
.picker .pl { background: #fff; max-height: 300px; overflow: hidden; padding: 4px 0; }
.picker .pr { padding: 5px 14px; display: flex; gap: 8px; align-items: center; }
.picker .pr.dim { color: #aaa; }
.picker .pr.sel { background: #2f6fde; color: #fff; }
.picker .pf { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid #ddd; }
.picker .pf span { flex: 1; color: #777; font-size: 12px; }
.picker .pf button { border: 1px solid #c8c8c8; background: #fff; border-radius: 6px; padding: 3px 14px; font: inherit; }
.picker .pf .po { background: #2f6fde; color: #fff; border-color: #2f6fde; }

.t-table { border-collapse: collapse; margin: 4px 0 6px; font-size: 11px; line-height: 1.35; white-space: normal; }
.t-table th, .t-table td { border: 1px solid #3a3e47; padding: 2px 5px; vertical-align: top; text-align: left; }
.t-table th { color: #fff; }

/* embedded in the website: the stage, captions and the bar only */
#app.embed { grid-template-rows: 0 minmax(0, 1fr) 70px; grid-template-columns: 0 minmax(0, 1fr) 0 !important; }
#app.embed #top, #app.embed #nav, #app.embed #notes { display: none; }
#app.embed #stageWrap { padding: 10px 10px 4px; }
#app.embed #caption { font-size: 15px; min-height: 52px; padding: 4px 18px 8px; }
#full { display: none; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font-size: 12px; }
#app.embed #full { display: inline-block; }

/* before the first play: one clear button over the stage */
#start { position: absolute; z-index: 20; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 16px;
  padding: 18px 28px 18px 20px; border: 0; border-radius: 16px; background: rgba(18, 21, 28, .9); color: #fff; text-align: left;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .35); font-size: 20px; }
#start:hover { background: #000; }
#start .pl { width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #1d1300; display: grid; place-items: center; font-size: 22px; }
#start small { display: block; font-size: 13px; color: #c9cfda; margin-top: 3px; }
#app.started #start { display: none; }
#app:not(.started) #pill { display: none; }
/* the browser's confirm dialog, drawn while the replay answers it */
.confirmBox { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); width: 420px; background: #fff; border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,.3); padding: 18px 20px 14px; font: 13.5px/1.45 -apple-system, BlinkMacSystemFont, sans-serif; color: #1d2433; z-index: 6; }
.confirmBox p { margin: 0 0 14px; }
.confirmBox div { display: flex; justify-content: flex-end; gap: 8px; }
.confirmBox button { border: 1px solid #d0d4db; background: #f6f7f9; border-radius: 7px; padding: 5px 16px; font-size: 13px; }
.confirmBox button.ok { background: #1a73e8; border-color: #1a73e8; color: #fff; }
.confirmBox.go button.ok { box-shadow: 0 0 0 3px rgba(26,115,232,.35); }
