/* Rain Date. Built on polr.css tokens; light theme only. */
html { color-scheme: light; }
body { margin: 0; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--space-4); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.grow { flex: 1; }

.top { padding: var(--space-6) 0 var(--space-4); background: var(--surface); border-bottom: 1px solid var(--line); margin-bottom: var(--space-6); }
.top .wrap { display: flex; flex-direction: column; gap: var(--space-3); }
.top-row { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; }
.top-text { display: flex; flex-direction: column; gap: var(--space-2); }
.top-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.lede { margin: 0 0 var(--space-2); color: var(--ink-muted); max-width: 65ch; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-6); align-items: start; padding-bottom: 64px; }
aside { display: flex; flex-direction: column; gap: var(--space-4); position: sticky; top: var(--space-4); }
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  aside { position: static; }
}

.polr-btn.small { height: 32px; padding: 0 var(--space-3); }

/* Toolbar */
.toolbar { position: sticky; top: var(--space-2); z-index: 6; display: flex; align-items: center; gap: var(--space-2); padding: 4px 4px 4px 4px; margin-bottom: var(--space-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow-x: auto; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.toolbar > * { flex: none; }
.tool { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--ink); cursor: pointer; transition: background-color 140ms ease-out, transform 140ms ease-out; }
.tool:hover { background: var(--sunken); }
.tool:active { transform: translateY(1px); }
.tool:focus-visible, .linkish:focus-visible, button.polr-chip:focus-visible, .select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tool[disabled] { opacity: 0.35; cursor: not-allowed; background: transparent; }
.sep { width: 1px; height: 20px; margin: 0 2px; background: var(--line); }
.tb-gap { flex: 1 !important; min-width: var(--space-2); }
button.polr-chip { border: 0; cursor: pointer; font-family: var(--font-sans); }
.select { height: 32px; padding: 0 28px 0 var(--space-3); border: 1.5px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); font: 500 13px/18px var(--font-sans); }
.status { display: inline-flex; align-items: center; gap: var(--space-2); }
.status .caption { color: var(--ink); max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rev { color: var(--ink-muted); padding: 0 var(--space-1); }
#publish { margin-right: 2px; }

/* Inline notices under the toolbar */
.notice { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3); background: var(--violet-soft); border-radius: var(--radius-lg); }
.notice-text { flex: 1; min-width: 220px; margin: 0; color: var(--ink); }
.notice-text p { margin: 0; color: var(--ink); }
.notice .actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
#publish-box { background: var(--accent-soft); }

/* Games that lost their slot */
.tray { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); border-radius: var(--radius-lg); padding: var(--space-4); margin-bottom: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.tray-head { display: flex; align-items: center; gap: var(--space-2); }
.tray .title, .week .title { margin: 0; }
.tray > .caption { margin: 0; color: var(--ink-muted); }
.tray-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); margin-top: var(--space-1); }
.tray-item { display: flex; flex-direction: column; gap: 4px; }
.tray-item .caption { color: var(--ink-muted); font-size: 12px; line-height: 16px; }
.tray-item .game { min-height: 48px; }

/* Calendar */
.calendar { display: flex; flex-direction: column; gap: var(--space-4); }
.week { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.week-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.week-head .caption { color: var(--ink-muted); }
.played-weeks { background: var(--sunken); box-shadow: none; }
.played-weeks .days { margin-top: var(--space-2); }
.days { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-start; }
.day { flex: 3 1 420px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.day.narrow { flex: 1 1 150px; max-width: 220px; }
.day-head { display: flex; align-items: center; gap: var(--space-2); min-height: 24px; flex-wrap: wrap; }
.day-head .label { color: var(--ink); }
.day.past .day-head .label { color: var(--ink-muted); }
.linkish { all: unset; cursor: pointer; font: 500 12px/16px var(--font-sans); color: var(--violet-text); border-radius: var(--radius-sm); padding: 2px 4px; }
.linkish:hover { text-decoration: underline; }
.grid { display: grid; grid-template-columns: 58px repeat(var(--cols), minmax(0, 1fr)); gap: 4px; align-items: stretch; }
.gh { text-align: center; color: var(--ink-muted); font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-bottom: 2px; }
.tl { font-size: 11px; color: var(--ink-muted); align-self: center; white-space: nowrap; }
.cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.game, .slot { box-sizing: border-box; width: 100%; min-height: 44px; border-radius: var(--radius-md); }
.game { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 0; padding: 4px 10px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: grab; text-align: left; font-family: var(--font-sans); transition: background-color 140ms ease-out, border-color 140ms ease-out, opacity 140ms ease-out, transform 140ms ease-out; }
.game:hover { background: var(--sunken); }
.game:active { transform: translateY(1px); }
.game:focus-visible, .slot:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.game .h { font: 600 13px/17px var(--font-sans); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game .a { font: 400 12px/16px var(--font-sans); color: var(--ink-muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game.played { cursor: default; background: transparent; border-color: var(--line); opacity: 0.7; }
.game.played:hover { background: transparent; }
.game.changed::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.game.conflict { border-color: var(--danger); background: var(--danger-soft); }
.game.conflict .h { color: var(--danger-text); }
.game .flag { position: absolute; right: 6px; bottom: 4px; font: 700 11px/14px var(--font-mono); color: var(--danger-text); }
.game.selected { border-color: var(--violet); background: var(--violet-soft); box-shadow: 0 0 0 2px var(--violet); }
.game.mine { border-color: var(--violet); }
.game.dim { opacity: 0.35; }
.game.just-moved { animation: settle 6.5s ease-out forwards; }
@keyframes settle {
  0%, 15% { background: color-mix(in srgb, var(--amber) 60%, var(--surface)); border-color: var(--amber); }
  100% { background: var(--surface); }
}
.game.conflict.just-moved { animation: none; }

.slot { display: grid; place-items: center; }
.slot.none { background: transparent; }
.slot.closed { background: var(--sunken); border: 1px solid var(--line); }
.slot.closed .caption { color: var(--ink-muted); font-size: 11px; }
.slot.open { border: 1.5px dashed var(--line-strong); background: transparent; cursor: pointer; padding: 0; transition: background-color 140ms ease-out, border-color 140ms ease-out; }
.slot.open .caption { color: var(--ink-muted); font-size: 11px; }
.slot.open:hover { background: var(--sunken); }
.slot.open.fits { border-style: solid; border-color: var(--good); background: var(--good-soft); }
.slot.open.fits .caption { color: var(--good-text); font-weight: 600; }
.slot.open.nofit .caption { color: var(--ink-muted); }
.slot.open.over { box-shadow: 0 0 0 2px var(--focus); }
.hint { color: var(--ink-muted); margin: var(--space-4) 2px 0; max-width: 80ch; }
.empty { color: var(--ink-muted); margin: var(--space-2) 0 0; }

@media (prefers-reduced-motion: reduce) {
  .game.just-moved { animation: none; border-color: var(--amber); }
}
@media (max-width: 640px) {
  .wrap { padding: 0 var(--space-3); }
  .week { padding: var(--space-3); }
  .day, .day.narrow { flex: 1 1 100%; max-width: none; }
  .grid { grid-template-columns: 52px repeat(var(--cols), minmax(0, 1fr)); }
  .tl { font-size: 10px; }
  .game { padding: 4px 6px; }
  .game .h { font-size: 12px; }
  .game .a { font-size: 11px; }
}

/* Side panel */
aside .polr-card p { font-size: 14px; line-height: 20px; }
.polr-tabs { margin-bottom: var(--space-2); }
.mcp-text { margin: var(--space-2) 0 var(--space-3); color: var(--ink-muted); }
.changes, .tools { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); max-height: 62vh; overflow: auto; }
.change { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); background: var(--surface); }
.change .meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.change .meta .value { color: var(--ink-muted); font-size: 12px; }
.change .label { font: 600 13px/18px var(--font-sans); color: var(--ink); }
.change .note { margin: 0; font: 400 13px/19px var(--font-sans); color: var(--ink-muted); }
.moves { display: flex; flex-direction: column; gap: 6px; }
.move { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--sunken); }
.move:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.move .who { font: 600 12px/16px var(--font-sans); color: var(--ink); }
.move .from { font: 400 12px/16px var(--font-sans); color: var(--danger-text); text-decoration: line-through; text-decoration-thickness: 1px; }
.move .to { font: 400 12px/16px var(--font-sans); color: var(--good-text); }
.tools li { display: flex; flex-direction: column; gap: 2px; }
.tools .value { color: var(--ink); }
.tools .caption { color: var(--ink-muted); font-size: 12px; line-height: 17px; }
aside a { color: var(--violet-text); }

.rules, .blackouts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rules li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font: 400 13px/18px var(--font-sans); color: var(--ink); }
.rules li.soft { color: var(--ink-muted); }
.sub { margin: var(--space-4) 0 var(--space-2); color: var(--ink); }
#issues { display: flex; flex-direction: column; gap: 6px; margin-top: var(--space-3); }
.issue { all: unset; cursor: pointer; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger-text); font: 400 12px/17px var(--font-sans); }
.issue.warn { background: var(--sunken); color: var(--ink); }
.issue:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ha { display: grid; grid-template-columns: 1fr 1fr; gap: 2px var(--space-4); }
.ha span { display: flex; justify-content: space-between; font: 400 13px/20px var(--font-sans); color: var(--ink); }
.ha span.off { color: var(--danger-text); font-weight: 600; }
.ha .value { font-size: 12px; }
.blackouts li { font: 400 13px/18px var(--font-sans); color: var(--ink); }
.blackouts li .caption { display: block; color: var(--ink-muted); font-size: 12px; line-height: 16px; }

/* The simulated agent session. It is the person's own agent, a different app from this
   site, so it is dark, uses system fonts and has its own chrome. */
.agent {
  --surface: #171b24; --ground: #0e1117; --sunken: #0b0e14; --line: #2a2f3c; --line-strong: #7d8499;
  --ink: #edeff5; --ink-muted: #a3aabc; --accent: #ff8a4c; --on-accent: #12151c;
  --violet: #a996ff; --violet-soft: #2c2266; --violet-text: #bfb1ff;
  --good: #4fd08a; --good-soft: #123624; --good-text: #6fe0a2;
  --accent-soft: #3a1c0c; --accent-text: #ffab7a;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  position: fixed; top: auto; right: var(--space-4); bottom: var(--space-4); z-index: 20;
  width: min(420px, calc(100vw - 32px)); max-height: min(62vh, 560px);
  display: flex; flex-direction: column; gap: var(--space-3);
  background: var(--ground); color: var(--ink); color-scheme: dark; font-family: var(--font-sans);
  border: 1px solid #3a4052; border-radius: 22px; padding: var(--space-4);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: agent-up 460ms cubic-bezier(0.2, 0.9, 0.25, 1);
  transition: transform 420ms cubic-bezier(0.5, 0, 0.75, 0.2), opacity 420ms ease-in;
}
.agent[hidden] { display: none; }
.agent.leaving { transform: translateY(calc(100% + 40px)); opacity: 0.6; }
.agent-bar { position: relative; display: flex; align-items: center; justify-content: center; height: 18px; margin: -4px 0 -2px; }
.agent-dots { position: absolute; left: 0; display: flex; gap: 8px; }
.dot { all: unset; box-sizing: border-box; width: 12px; height: 12px; border-radius: 50%; cursor: pointer; position: relative; border: 1px solid rgba(0, 0, 0, 0.25); }
.dot:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.dot-close { background: #ff5f57; }
.dot-min { background: #febc2e; }
.dot-max { background: #28c840; }
.agent-dots:hover .dot::after { position: absolute; inset: 0; display: grid; place-items: center; font: 700 9px/1 var(--font-sans); color: rgba(0, 0, 0, 0.6); }
.agent-dots:hover .dot-close::after { content: "\00d7"; font-size: 11px; }
.agent-dots:hover .dot-min::after { content: "\2212"; }
.agent-dots:hover .dot-max::after { content: "+"; }
.agent-title { font: 500 12px/18px var(--font-sans); color: var(--ink-muted); }
.agent-head { display: flex; align-items: center; gap: var(--space-3); }
.agent-avatar { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--violet); color: #12151c; }
.agent-id { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.agent-name { font: 650 15px/20px var(--font-sans); color: var(--ink); }
.agent-sub { font: 400 12px/16px var(--font-sans); color: var(--ink-muted); }
.agent-link { display: flex; align-items: center; gap: var(--space-2); padding: 6px 10px; border-radius: var(--radius-pill); background: var(--sunken); border: 1px solid var(--line); color: var(--ink-muted); min-width: 0; }
.agent-link svg { flex: none; }
.agent-link.sending { border-color: var(--violet); color: var(--violet-text); animation: send-pulse 700ms ease-in-out infinite alternate; }
@keyframes send-pulse { to { background: var(--violet-soft); } }
.agent-link .value { font: 400 11px/16px var(--font-mono); color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-said { margin: 0; align-self: flex-end; max-width: 88%; padding: 8px 14px; background: var(--violet); color: #12151c; border-radius: 18px 18px 4px 18px; font: 500 15px/22px var(--font-sans); min-height: 22px; overflow-wrap: anywhere; }
.agent-said:empty { display: none; }
.agent-said.typing::after { content: ""; display: inline-block; width: 0.5em; height: 1em; margin-left: 2px; vertical-align: text-bottom; background: #12151c; animation: caret 700ms steps(1) infinite; }
.agent-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); overflow-y: auto; min-height: 0; scrollbar-color: #3a4052 transparent; }
.step { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: var(--space-3); animation: step-in 180ms ease-out; }
.s-ico { width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--line-strong); box-sizing: border-box; }
.step.run .s-ico { border-color: var(--line); border-top-color: var(--accent); animation: spin 800ms linear infinite; }
.step.ok .s-ico { border: 0; background: var(--good); position: relative; }
.step.ok .s-ico::after { content: ""; position: absolute; left: 5px; top: 2.5px; width: 4px; height: 8px; border: solid #0e1117; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.s-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.s-tag { font: 500 11px/16px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.s-tag.s-call { color: var(--violet-text); }
.s-text { margin: 0; font: 400 13px/19px var(--font-sans); color: var(--ink); overflow-wrap: anywhere; }
.s-text.value { font: 500 12px/18px var(--font-mono); }
.s-fn { margin: 0; font: 400 11px/16px var(--font-mono); color: var(--ink-muted); overflow-wrap: anywhere; }
.step.run .s-text { color: var(--ink-muted); }
.step.final .s-tag { color: var(--good-text); }
.step.final .s-text { font-weight: 600; }
.s-out { margin: var(--space-1) 0 0; padding: 4px 8px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); font: 400 12px/17px var(--font-mono); color: var(--ink-muted); overflow-wrap: anywhere; }
.agent-note { margin: 0; color: var(--ink-muted); font-family: var(--font-sans); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes step-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes agent-up { from { transform: translateY(calc(100% + 40px)); } }
@media (prefers-reduced-motion: reduce) {
  .agent { animation: none; transition: opacity 200ms; }
  .agent.leaving { transform: none; opacity: 0; }
  .step { animation: none; }
  .step.run .s-ico { animation: none; border-top-color: var(--accent); }
}

/* Phones: the agent panel is a bottom sheet that shrinks to one line once the edit starts */
@media (max-width: 900px) {
  .agent { left: var(--space-2); right: var(--space-2); bottom: var(--space-2); width: auto; max-height: 44vh; padding: var(--space-3); gap: var(--space-2); border-radius: 20px; }
  .agent .agent-link { display: none; }
  .agent .agent-said { font-size: 14px; line-height: 20px; }
  .agent.compact { max-height: none; }
  .agent.compact .agent-said, .agent.compact .agent-note, .agent.compact .agent-link, .agent.compact .step:not(:last-child) { display: none; }
  .agent.compact .agent-steps { overflow: visible; }
  .agent.compact .s-out, .agent.compact .s-fn { display: none; }
}

/* The toolbar scrolls sideways on narrow screens without showing a scrollbar */
.toolbar { scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }

/* Only the step list scrolls; the request bubble and header keep their full height */
.agent > * { flex: none; }
.agent > .agent-steps { flex: 0 1 auto; }
