/* Flowboard: a three-column workspace. Left rail lists graphics, the middle shows one, the right is its chat. */
:root {
  --bg: #f5f8f8; --surface: #ffffff; --fg: #142326; --muted: #55676b; --line: #c9d5d7;
  --accent: #0b6e7c; --accent-soft: #dff0f2; --danger: #a8321f;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1719; --surface: #18252a; --fg: #e6eeef; --muted: #9db0b4; --line: #33474c;
    --accent: #5fcbd9; --accent-soft: #12343a; --danger: #f08a78; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
input[type=text], input[type=email], input[type=password], textarea {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: 5px; padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=submit], button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 5px; padding: 8px 14px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--surface);
}
.link-button { background: none; border: 0; color: var(--accent); padding: 4px 6px; font-weight: 500; }
.link-button.danger { color: var(--danger); }
.flash { margin: 0; padding: 8px 12px; border-radius: 5px; background: var(--accent-soft); }

.app { display: grid; grid-template-columns: var(--rail-w, 180px) 7px minmax(0, 1fr) 7px var(--chat-w, 330px); height: 100vh; }
.app.rail-closed { grid-template-columns: 0 0 minmax(0, 1fr) 7px var(--chat-w, 330px); }
.app.chat-closed { grid-template-columns: var(--rail-w, 180px) 7px minmax(0, 1fr) 0 0; }
.app.rail-closed.chat-closed { grid-template-columns: 0 0 minmax(0, 1fr) 0 0; }
.app.rail-closed .rail, .app.rail-closed .grip-rail, .app.chat-closed .chat, .app.chat-closed .grip-chat { display: none; }
.grip { cursor: col-resize; touch-action: none; background: linear-gradient(var(--line), var(--line)) center / 1px 100% no-repeat; }
.grip:hover, .grip.dragging, .grip:focus-visible { background: var(--accent-soft); outline: none; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pane-toggle, .pane-close { flex: none; background: none; border: 1px solid var(--line); color: var(--muted); padding: 4px 9px; font-weight: 500; line-height: 1.3; }
.pane-toggle:hover, .pane-close:hover { background: var(--accent-soft); color: var(--accent); }
.pane-close { border: 0; font-size: 20px; padding: 0 6px; }
.scrim { display: none; }
.rail { display: flex; flex-direction: column; gap: 14px; padding: 18px 14px; min-width: 0; overflow-y: auto; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.graphic-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.graphic-list summary { display: flex; align-items: stretch; gap: 2px; list-style: none; }
.graphic-list summary::-webkit-details-marker { display: none; }
.graphic-list .dots { flex: none; display: grid; place-items: center; width: 26px; border-radius: 5px; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.graphic-list .dots:hover, .graphic-list details[open] .dots { background: var(--accent-soft); color: var(--accent); }
.item-menu { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 2px 0 8px; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); font-size: 13px; }
.item-rename { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.item-rename input[type=text] { padding: 5px 7px; }
.item-rename input[type=submit] { padding: 4px 8px; align-self: flex-start; }
.graphic-list a { flex: 1; min-width: 0; display: block; padding: 7px 10px; border-radius: 5px; color: var(--fg); text-decoration: none; overflow-wrap: anywhere; }
.graphic-list a:hover { background: var(--accent-soft); }
.graphic-list a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.new-graphic { display: flex; gap: 6px; }
.new-graphic input[type=submit] { padding: 8px 10px; }
.rail-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; }

.main { display: flex; flex-direction: column; gap: 16px; padding: 18px 22px 40px; min-width: 0; overflow-y: auto; }
.main-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title { flex: 1; min-width: 0; font-size: 22px; font-weight: 650; overflow-wrap: anywhere; }

.stage { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.frame-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.frame { display: block; width: 100%; border: 0; background: var(--surface); }
.caption { margin: 0; max-width: 78ch; color: var(--muted); }
.stage-meta { margin: 0; font-size: 13px; color: var(--muted); }

.revisions { display: flex; flex-direction: column; gap: 8px; }
.revisions ol { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); max-width: 640px; }
.revisions li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 8px 2px 0; border-top: 1px solid var(--line); }
.revisions li:first-child { border-top: 0; }
.revisions li.shown { background: var(--accent-soft); }
.rev-link { display: flex; flex-direction: column; padding: 7px 12px; text-decoration: none; color: var(--fg); min-width: 0; flex: 1; }
.rev-note { overflow-wrap: anywhere; }
.rev-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rev-restore { margin: 0; }

.chat { display: flex; flex-direction: column; gap: 10px; padding: 18px 14px 14px; min-width: 0; min-height: 0; background: var(--surface); }
.messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.chat-hint { margin: 0; color: var(--muted); font-size: 14px; }
.msg { display: flex; flex-direction: column; gap: 2px; }
.msg-author { font-size: 12px; font-weight: 600; color: var(--muted); }
.msg-user .msg-author { color: var(--accent); }
.msg-body { overflow-wrap: anywhere; }
.msg-body p { margin: 0 0 6px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-error .msg-body { color: var(--danger); }
.msg-chip { align-self: flex-start; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 7px; margin-top: 3px; }
.pending { color: var(--muted); }
.dots-anim::after { content: "…"; animation: blink 1.2s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .dots-anim::after { animation: none; } }
.chat-form { display: flex; flex-direction: column; gap: 8px; }
.chat-form textarea { resize: vertical; }
.chat-form input[type=submit] { align-self: flex-end; }

.signin, .empty { max-width: 340px; margin: 12vh auto 0; padding: 0 16px; display: flex; flex-direction: column; gap: 16px; }
.signin-form { display: flex; flex-direction: column; gap: 8px; }
.signin-form label { font-size: 13px; font-weight: 600; color: var(--muted); }
.signin-form input[type=submit] { margin-top: 8px; }

@media (max-width: 1000px) {
  html, body { height: auto; }
  .app, .app.rail-closed, .app.chat-closed, .app.rail-closed.chat-closed { display: block; height: auto; }
  .grip { display: none; }
  .main { overflow: visible; padding: 12px 12px 40px; }
  .main-head { flex-wrap: wrap; }
  .title { font-size: 18px; }
  /* The side panes become drawers that slide over the graphic. */
  .app .rail, .app .chat, .app.rail-closed .rail, .app.chat-closed .chat {
    display: none; position: fixed; top: 0; bottom: 0; z-index: 20; width: min(88vw, 380px); height: 100dvh;
    background: var(--surface); box-shadow: 0 0 24px rgb(0 0 0 / .3);
  }
  .rail { left: 0; }
  .chat { right: 0; }
  .app.rail-open .rail, .app.chat-open .chat { display: flex; }
  .app.rail-open .scrim, .app.chat-open .scrim { display: block; position: fixed; inset: 0; z-index: 10; background: rgb(0 0 0 / .35); }
}
@media (min-width: 1001px) { .pane-close { display: none; } }
.sub { margin: 0; color: var(--muted); font-size: 14px; }
