.pd-dock {
  --pd-bg: #1b221e;
  --pd-raised: #242d26;
  --pd-hover: #333d32;
  --pd-line: #495348;
  --pd-ink: #f2ebd9;
  --pd-muted: #bdbdab;
  --pd-accent: #e9c68d;
  --pd-positive: #aed6a3;
  --pd-negative: #f1b5a5;
  --pd-radius: 7px;
  position: fixed;
  z-index: 9;
  inset-inline-start: max(14px, env(safe-area-inset-left));
  inset-block-end: max(14px, env(safe-area-inset-bottom));
  width: min(248px, calc(100vw - 28px));
  color: var(--pd-ink);
  font: 500 13px/1.45 var(--sans, system-ui, sans-serif);
  text-align: start;
  color-scheme: dark;
}
.pd-dock[hidden], .pd-dock [hidden] { display: none !important; }
.pd-dock :where(p, h2, h3, ol, ul) { margin: 0; }
.pd-dock :where(button, input) { font: inherit; letter-spacing: inherit; }
.pd-dock :focus-visible { outline: 2px solid var(--pd-accent); outline-offset: 2px; }
.pd-sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pd-bar { display: flex; align-items: stretch; gap: 4px; }
.pd-button, .pd-tab, .pd-preview {
  border: 1px solid var(--pd-line);
  border-radius: var(--pd-radius);
  color: var(--pd-ink);
  background: var(--pd-raised);
  cursor: pointer;
  touch-action: manipulation;
}
.pd-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 36px;
  padding: 4px 8px;
  white-space: nowrap;
  font-weight: 650;
}
.pd-button svg { flex: none; color: var(--pd-muted); }
.pd-button[aria-expanded='true'], .pd-tab[aria-selected='true'] {
  color: var(--pd-accent);
  border-color: #937d57;
  background: #37362a;
}
.pd-button[aria-expanded='true'] svg { color: inherit; }
.pd-unread {
  padding: 0 4px;
  min-width: 16px;
  border-radius: 8px;
  color: #27251a;
  background: var(--pd-accent);
  font-size: 10px;
  font-weight: 750;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pd-preview {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 36px;
  margin-top: 4px;
  padding: 5px 7px;
  color: var(--pd-muted);
  background: var(--pd-bg);
  font-size: 11px;
  text-align: start;
}
.pd-preview-empty { align-self: center; }
.pd-preview-line { display: flex; align-items: baseline; min-width: 0; gap: 6px; }
.pd-preview-line .pd-name { flex: 0 1 auto; max-width: 42%; color: var(--pd-accent); font-weight: 650; }
.pd-preview-line .pd-name, .pd-preview-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-chat {
  position: absolute;
  inset-inline-start: 0;
  inset-block-end: calc(100% + 5px);
  width: min(320px, calc(100vw - 28px));
  border: 1px solid var(--pd-line);
  border-radius: 9px;
  background: var(--pd-bg);
  box-shadow: 0 12px 30px #090d0a97;
}
.pd-chat-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 11px; border-bottom: 1px solid var(--pd-line); }
.pd-chat-header h2 { font-size: 13px; font-weight: 700; }
.pd-close-chat, .pd-close { width: 38px; padding: 0; }
.pd-transcript {
  display: flex;
  flex-direction: column;
  height: min(204px, 35dvh);
  padding: 7px 11px;
  overflow: auto;
  overscroll-behavior: contain;
}
.pd-transcript:focus-visible, .pd-panel:focus-visible, .pd-hand-summary:focus-visible { outline-offset: -3px; }
.pd-transcript .pd-empty { margin: auto; }
.pd-messages { display: grid; gap: 7px; padding: 0; list-style: none; }
.pd-message-meta { display: flex; justify-content: space-between; gap: 10px; }
.pd-name { min-width: 0; overflow-wrap: anywhere; }
.pd-message .pd-name { color: var(--pd-accent); font-size: 11px; font-weight: 650; }
.pd-time { color: var(--pd-muted); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pd-message-text { overflow-wrap: anywhere; white-space: pre-wrap; unicode-bidi: plaintext; }
.pd-composer { display: flex; gap: 5px; padding: 7px; border-top: 1px solid var(--pd-line); }
.pd-message-input {
  min-width: 0;
  min-height: 36px;
  flex: 1;
  padding: 6px 9px;
  border: 1px solid var(--pd-line);
  border-radius: var(--pd-radius);
  background: #121813;
  color: var(--pd-ink);
  font-size: 16px;
}
.pd-message-input::placeholder { color: var(--pd-muted); opacity: .9; font-size: 13px; }
.pd-send { color: #26271e; background: var(--pd-accent); border-color: var(--pd-accent); }
.pd-send:disabled { color: var(--pd-muted); background: var(--pd-raised); border-color: var(--pd-line); opacity: .67; cursor: default; }
.pd-feedback { padding: 0 8px 7px; color: var(--pd-negative); font-size: 12px; overflow-wrap: anywhere; }
.pd-feedback:empty { padding: 0; }

.pd-modal {
  width: min(530px, calc(100vw - 28px));
  max-width: calc(100% - 28px);
  max-height: calc(100dvh - max(12px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
  padding: 0;
  overflow: hidden;
  color: var(--pd-ink);
  border: 1px solid var(--pd-line);
  border-radius: 12px;
  background: var(--pd-bg);
  box-shadow: 0 22px 70px #090d0bcc;
}
.pd-modal::backdrop { background: #0b110ec8; }
.pd-modal-layout { display: flex; flex-direction: column; height: min(590px, 86dvh); max-height: inherit; }
.pd-modal-header { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px 12px; }
.pd-kicker { color: var(--pd-muted); font-size: 11px; }
.pd-modal-header h2 { font-size: clamp(18px, 4vw, 22px); font-weight: 700; }
.pd-tabs { display: flex; flex: none; gap: 5px; margin: 0 16px; padding: 0 0 10px; border-bottom: 1px solid var(--pd-line); }
.pd-tab { flex: 1; min-height: 40px; padding: 6px 10px; font-weight: 650; }
.pd-panel { min-height: 0; flex: 1; padding: 12px 16px 16px; overflow: auto; overscroll-behavior: contain; }
.pd-hand { overflow: hidden; border: 1px solid var(--pd-line); border-radius: var(--pd-radius); }
.pd-hand + .pd-hand { margin-top: 6px; }
.pd-hand-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 7px 10px;
  background: var(--pd-raised);
  list-style: none;
  cursor: pointer;
}
.pd-hand-summary::-webkit-details-marker { display: none; }
.pd-hand-summary::after { content: ''; grid-column: 4; width: 7px; height: 7px; margin-inline: 4px; border-right: 1.5px solid var(--pd-muted); border-bottom: 1.5px solid var(--pd-muted); transform: translateY(-2px) rotate(45deg); }
.pd-hand[open] .pd-hand-summary::after { transform: translateY(2px) rotate(225deg); }
.pd-hand-title { font-weight: 700; }
.pd-hand-status { color: var(--pd-muted); font-size: 11px; overflow-wrap: anywhere; }
.pd-hand-status.pd-live { color: var(--pd-accent); }
.pd-hand-when { text-align: end; }
.pd-hand-body { padding: 7px 10px 10px; border-top: 1px solid var(--pd-line); }
.pd-board { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; padding: 0; list-style: none; }
.pd-board li { min-width: 27px; padding: 2px 4px; border: 1px solid #696b5f; border-radius: 4px; color: var(--pd-ink); background: var(--pd-raised); text-align: center; font-variant-numeric: tabular-nums; }
.pd-board .pd-red-card { color: var(--pd-negative); }
.pd-street { margin-top: 7px; }
.pd-street h3 { padding: 4px 6px; border-radius: 4px; color: var(--pd-muted); background: var(--pd-raised); font-size: 11px; font-weight: 650; }
.pd-payouts, .pd-actions { list-style: none; padding: 0; }
.pd-payouts li, .pd-actions li { display: grid; align-items: baseline; padding: 4px 6px; column-gap: 7px; min-width: 0; }
.pd-payouts li { grid-template-columns: minmax(0, 1fr) auto; color: var(--pd-accent); }
.pd-actions li { grid-template-columns: minmax(0, 1fr) minmax(49px, 22%) minmax(0, auto); border-bottom: 1px solid #394339; }
.pd-action-kind { color: var(--pd-muted); }
.pd-amount { text-align: end; font-variant-numeric: tabular-nums; }
.pd-positive { color: var(--pd-positive); }
.pd-negative { color: var(--pd-negative); }
.pd-empty { padding: 8px 0; color: var(--pd-muted); text-align: center; font-size: 12px; }
.pd-note { margin: 6px 0 0; color: var(--pd-muted); font-size: 11px; }
.pd-ledger { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pd-ledger caption { margin-bottom: 8px; color: var(--pd-muted); text-align: start; font-size: 12px; }
.pd-ledger :is(th, td) { padding: 8px; border-bottom: 1px solid var(--pd-line); }
.pd-ledger th { text-align: start; }
.pd-ledger th:not(:first-child) { text-align: end; }
.pd-ledger thead { background: var(--pd-raised); color: var(--pd-muted); }
.pd-ledger tbody th { min-width: 45px; overflow-wrap: anywhere; font-weight: 600; }
.pd-ledger td { overflow-wrap: anywhere; }
.pd-self { display: inline-block; margin-inline-start: 5px; padding: 0 4px; color: var(--pd-accent); background: var(--pd-raised); border-radius: 4px; font-size: 10px; }

@media (hover:hover) {
  .pd-button:not(:disabled):hover, .pd-tab:hover, .pd-preview:hover, .pd-hand-summary:hover { background: var(--pd-hover); }
  .pd-send:not(:disabled):hover { background: #f3d49f; }
}
/* Keep the dock under the playing controls when the columns cannot coexist. */
@media (max-width: 900px), (max-height: 520px) {
  .pd-dock { position: relative; inset: auto; width: auto; align-self: stretch; margin: 0 max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .pd-bar { width: min(100%, 320px); }
  .pd-preview { width: min(100%, 320px); }
  .pd-chat { position: relative; inset: auto; width: min(100%, 440px); margin-top: 4px; box-shadow: none; }
}
@media (max-width: 440px) {
  .pd-modal-header { padding: 12px; }
  .pd-tabs { margin-inline: 12px; }
  .pd-panel { padding-inline: 12px; }
  .pd-hand-summary { grid-template-columns: auto minmax(0, 1fr) auto; }
  .pd-hand-summary::after { grid-column: 3; }
  .pd-hand-when:not(:empty) { grid-column: 1 / 3; grid-row: 2; text-align: start; }
  .pd-hand-when:empty { display: none; }
  .pd-ledger :is(th, td) { padding-inline: 5px; }
}
@media (pointer: coarse) {
  .pd-button, .pd-preview, .pd-tab { min-height: 44px; }
  .pd-close-chat, .pd-close { width: 44px; }
}

.pd-dock .pd-system .pd-name{color:#f5d690;font-weight:800}
.pd-dock .pd-message.pd-system{border-inline-start:2px solid #bc9b58;padding-inline-start:8px}
