/* The deck window, drawn the way deck draws it. Sizes are deck's own (view.rs,
   pane.rs, prose.rs); colours are measured from recordings of the window, so
   this sits beside the reel above it without a seam. */
.dk {
  --band: #141717;
  --wash: #1a1a1a;
  --seam: #212121;
  --fg: #ebdbb2;
  --muted: #9d8c77;
  --gutter: #625f4c;
  --accent: #fe8019;
  --focus: #29251b;          /* a lit range */
  --pointed: #5a361a;        /* a line the sentence points at */
  --pointed-plain: #4a2e17;  /* pointed, outside the lit range */
  --gone: #3e2621; --gone-deep: #5a2b22;
  --fresh: #2a2c20; --fresh-deep: #42431f;
  --del: #f53f2e; --add: #adb220;
  --said: #3c2717;           /* a picked sentence */
  --chip: #2a2116; --chip-edge: #5a3618;
  --chip-on: #553418; --chip-edge-on: #b86118;
  --rise: 150ms; --hand-over: 200ms; --fall: 420ms;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 820px;
  border: 1px solid #66503a;
  border-radius: 12px;
  overflow: hidden;
  background: var(--wash);
  color: var(--fg);
  font-family: var(--sans);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  user-select: none;
  -webkit-user-select: none;
}
.dk:focus { outline: none; }
.dk:focus-visible { box-shadow: 0 0 0 3px rgba(254,128,25,0.35), 0 50px 140px rgba(0,0,0,0.6); }
.dk button { cursor: pointer; font: inherit; }
.dk-nojs { margin: auto; padding: 40px; color: var(--muted); grid-row: 1 / -1; }

/* the band */
.dk-band { display: grid; grid-template-columns: minmax(0, 1fr) 180px; background: var(--band); border-bottom: 6px solid var(--seam); }
.dk-say { padding: 15px 18px 14px; display: flex; flex-direction: column; gap: 9px; min-width: 0; min-height: 150px; }
.dk-title { font-size: 15.5px; font-weight: 600; line-height: 1.3; color: var(--fg); }
.dk-prose { display: flex; flex-direction: column; gap: 8.8px; font-size: 13.2px; line-height: 21px; color: var(--fg); }
.dk-para { display: flex; flex-wrap: wrap; align-items: center; }
.dk-w { white-space: pre-wrap; border-radius: 2px; cursor: pointer; border-bottom: 1px solid transparent; transition: background-color var(--fall) cubic-bezier(.45,0,.55,1); }
.dk-w.lit { background: var(--said); transition-duration: var(--rise); }
.dk-w.remarked { border-bottom-color: #928374; }
.dk-w b { font-weight: 600; }
.dk-w em { font-style: normal; color: var(--accent); }
.dk-w code { font-family: var(--mono); font-size: 11.6px; padding: 1px 4px; border-radius: 3px; background: var(--wash); }
.dk-chip { display: inline-block; padding: 0 5px; border-radius: 3px; color: var(--accent); background: var(--chip); border: 1px solid var(--chip-edge); line-height: 19px; transition: background-color var(--rise), border-color var(--rise); }
.dk-w.on .dk-chip, .dk-chip:hover { background: var(--chip-on); border-color: var(--chip-edge-on); }
.dk-keys { border-left: 1px solid var(--seam); padding: 14px 16px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.dk-keys p { font-size: 10px; letter-spacing: 0.08em; color: #6f6656; margin: 0 0 8px; }
.dk-keys button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 2.5px 0; border: 0; background: none; color: var(--muted); font-family: var(--mono); font-size: 11.5px; text-align: left; }
.dk-keys button:hover { color: var(--fg); }
.dk-keys kbd { min-width: 18px; padding: 0 4px; font-size: 10.5px; line-height: 17px; border: 1px solid #3a3530; background: #1b1a18; color: var(--fg); }

/* the room */
.dk-room { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 0; background: var(--seam); }
.dk-panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; min-height: 0; padding-right: 6px; }
.dk-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--wash); }
.dk-frame { position: absolute; inset: 0; border: 2px solid var(--accent); opacity: 0; pointer-events: none; transition: opacity var(--fall) cubic-bezier(.45,0,.55,1); z-index: 2; }
.dk-pane.talk .dk-frame { opacity: .9; transition-duration: var(--rise); }
.dk-head { flex: none; padding: 9px 14px 2px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.dk-head .nm { color: var(--accent); flex: none; }
.dk-head .path { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-note { flex: none; padding: 0 14px 6px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* code: one row per line, its ground spanning the pane */
.dk-code { flex: 1; min-height: 0; overflow: auto; font-family: var(--mono); font-size: 12px; scrollbar-width: thin; scrollbar-color: #333 transparent; }
.dk-rows { min-width: 100%; width: max-content; }
.dk-row { display: flex; align-items: center; height: 19.44px; background: var(--wash); cursor: text; transition: background-color var(--hand-over) cubic-bezier(.45,0,.55,1); }
.dk-row .bar { flex: none; width: 12px; text-align: center; color: transparent; transition: color var(--hand-over); }
.dk-row .num { flex: none; width: 44px; padding-right: 12px; text-align: right; color: var(--gutter); }
.dk-row .txt { flex: 1; padding-right: 18px; white-space: pre; }
.dk-row.lit { background: var(--focus); }
.dk-row.lit .bar { color: var(--accent); }
.dk-row.lit .num { color: var(--muted); }
.dk.pointing .dk-row.lit:not(.pt) .bar { color: var(--muted); }
.dk-row.gone { background: var(--gone); }
.dk-row.gone .bar { color: var(--del); }
.dk-row.fresh { background: var(--fresh); }
.dk-row.fresh .bar { color: var(--add); }
.dk-row.pt { transition-duration: var(--rise); }
.dk-row.pt .bar { color: var(--accent); transition-duration: var(--rise); }
.dk-row.pt.lit { background: var(--pointed); }
.dk-row.pt:not(.lit):not(.gone):not(.fresh) { background: var(--pointed-plain); }
.dk-row.pt.gone { background: var(--gone-deep); }
.dk-row.pt.fresh { background: var(--fresh-deep); }
.dk-row.held { box-shadow: inset 0 0 0 999px rgba(254,128,25,0.14); }
.dk-row.noted .num { color: #83a598; }
.k { color: #fb4934; } .f { color: #fabd2f; } .s { color: #b8bb26; } .ty { color: #8ec07c; } .c { color: #928374; font-style: italic; } .nu { color: #d3869b; } .d { color: #8ec07c; }

/* a page, wearing deck's colours */
.dk-page { flex: 1; min-height: 0; position: relative; }
.dk-page iframe { position: absolute; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); border: 0; background: transparent; color-scheme: dark; }
.dk-again { position: absolute; right: 12px; top: 30px; z-index: 3; padding: 3px 10px; border-radius: 14px; border: 1px solid #333; background: #1d1d1d; color: var(--muted); font-size: 12px; }
.dk-again:hover { color: var(--fg); }

/* the rail */
.dk-rail { width: 46px; background: var(--band); display: flex; flex-direction: column; min-height: 0; transition: width .35s ease; overflow: hidden; }
.dk-rail.open { width: 300px; }
.dk-rail-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-family: var(--mono); font-size: 11px; color: var(--fg); white-space: nowrap; border: 0; background: none; text-align: left; }
.dk-rail-head .chev { color: var(--muted); }
.dk-rail-head .sub { color: var(--muted); }
.dk-rail:not(.open) .dk-rail-head { flex-direction: column; padding: 14px 0; gap: 12px; height: 100%; }
.dk-rail:not(.open) .dk-rail-head .lab { writing-mode: vertical-rl; letter-spacing: 0.08em; }
.dk-rail:not(.open) .dk-rail-head .sub, .dk-rail:not(.open) .dk-chat, .dk-rail:not(.open) .dk-compose { display: none; }
.dk-rail .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.dk-rail:not(.unread) .dot { visibility: hidden; }
.dk-chat { flex: 1; min-height: 0; overflow: auto; padding: 4px 16px 12px; display: flex; flex-direction: column; gap: 16px; scrollbar-width: thin; scrollbar-color: #333 transparent; }
.dk-empty { margin: auto; font-family: var(--mono); font-size: 12px; font-style: italic; color: #6f6656; }
.dk-msg { display: grid; grid-template-columns: 12px minmax(0, 1fr); column-gap: 10px; }
.dk-msg i { width: 9px; height: 9px; margin-top: 4px; border-radius: 50%; background: var(--accent); }
.dk-msg.agent i { background: none; border: 1.5px solid var(--muted); }
.dk-msg .who { font-family: var(--mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dk-msg p { grid-column: 2; margin: 3px 0 0; font-size: 12.2px; line-height: 18.6px; color: #d5c5a1; white-space: pre-wrap; word-wrap: break-word; user-select: text; -webkit-user-select: text; }
.dk-pulse { grid-column: 2; margin-top: 6px; width: 28px; height: 4px; border-radius: 2px; background: var(--accent); animation: dkbreathe 1.4s ease-in-out infinite; }
@keyframes dkbreathe { 50% { opacity: .25; } }
.dk-compose { flex: none; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.dk-compose .on { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dk-compose textarea { width: 100%; height: 92px; resize: none; padding: 10px 12px; border-radius: 6px; border: 1.5px solid #4a4a48; background: #191b1b; color: var(--fg); font: 13.5px/1.5 var(--sans); user-select: text; -webkit-user-select: text; }
.dk-compose textarea:focus { outline: none; border-color: #7a7a76; }
.dk-compose .row { display: flex; align-items: center; gap: 8px; }
.dk-compose .row span { margin-right: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.dk-compose .row button { padding: 6px 10px; border-radius: 5px; font-size: 12px; white-space: nowrap; }
.dk-compose .later { border: 1px solid #3a3a38; background: #1d1d1d; color: var(--fg); }
.dk-compose .now { border: 0; background: var(--accent); color: #282828; font-weight: 500; }
.dk-compose .hint { font-family: var(--mono); font-size: 10px; opacity: 0.7; margin-left: 4px; }
.dk-compose.idle textarea { height: 38px; }
.dk-compose.idle .on, .dk-compose.idle .row { display: none; }

/* status line */
.dk-foot { display: flex; align-items: center; gap: 18px; padding: 8px 18px; background: var(--band); border-top: 1px solid var(--seam); font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.dk-foot .grp { color: var(--fg); }
.dk-foot .msg { color: var(--accent); overflow: hidden; text-overflow: ellipsis; }
.dk-foot .r { margin-left: auto; display: flex; gap: 18px; }

@media (max-width: 860px) {
  .dk { height: auto; grid-template-rows: auto auto auto; }
  .dk-band { grid-template-columns: minmax(0, 1fr); }
  .dk-keys { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; border-left: 0; border-top: 1px solid var(--seam); }
  .dk-keys p, .dk-keys kbd { display: none; }
  .dk-keys button { width: auto; min-height: 44px; padding: 0 12px; border: 1px solid var(--edge-2); border-radius: 6px; font: 13px var(--sans); }
  .dk-keys button[data-key="w"], .dk-keys button[data-key="t"], .dk-keys button[data-key="z"], .dk-keys button[data-key="h"], .dk-keys button[data-key="q"] { display: none; }
  .dk-keys button[data-key="p"] { order: -1; }
  .dk-say { padding: 16px; }
  .dk-prose { font-size: 14px; line-height: 1.65; }
  .dk-compose textarea { font-size: 16px; }
  .dk-compose .row { flex-wrap: wrap; }
  .dk-compose .row > span, .dk-compose .hint { display: none; }
  .dk-compose .row button, .dk-rail-head, .dk-again { min-height: 44px; }
  .dk-foot { gap: 10px; padding: 10px 12px; font-size: 10px; }
  .dk-room { grid-template-columns: minmax(0, 1fr); }
  .dk-panes { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .dk-pane { height: 380px; }
  .dk-rail, .dk-rail.open { width: auto; border-top: 6px solid var(--seam); }
  .dk-rail:not(.open) .dk-rail-head { flex-direction: row; height: auto; padding: 12px 14px; }
  .dk-rail:not(.open) .dk-rail-head .lab { writing-mode: horizontal-tb; }
  .dk-chat { max-height: 320px; }
  .dk-foot .r span:not(:first-child) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .dk *, .dk *::before { transition: none !important; }
}
