.demo {
  --d-bg: #1b1c1f;
  --d-rail: #161719;
  --d-line: #2a2c31;
  --d-hover: #24262a;
  --d-sel: #2c2e33;
  --d-text: #e3e4e6;
  --d-muted: #8d9199;
  --d-add: #5fcf7f;
  --d-del: #e06c6c;
  --d-addbg: #1f3125;
  --d-delbg: #3a2427;
  --d-warn: #e7b94c;
  position: relative;
  height: 640px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--d-bg);
  color: var(--d-text);
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
  user-select: none;
}
.demo button, .demo select, .demo input { font: inherit; color: inherit; }
.demo button { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.demo code { font-family: var(--mono); font-size: 12.5px; }
.d-muted { color: var(--d-muted); }
.d-warn { color: var(--d-warn); }
.d-add { color: var(--d-add); }
.d-del { color: var(--d-del); }
.d-pad { padding: 16px; }
.d-right { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }

/* title bar */
.d-title { height: 44px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 10px 0 14px; border-bottom: 1px solid var(--d-line); background: var(--d-rail); }
.d-lights { display: flex; gap: 7px; }
.d-lights i { width: 11px; height: 11px; border-radius: 50%; background: #4a4c52; }
.d-what { display: flex; align-items: baseline; gap: 10px; min-width: 0; white-space: nowrap; overflow: hidden; }
.d-what span:not(.d-add):not(.d-del) { overflow: hidden; text-overflow: ellipsis; }
.d-actions { margin-left: auto; display: flex; gap: 6px; }
.d-actions button, .d-dbtns button {
  border: 1px solid var(--d-line) !important; border-radius: 5px; padding: 4px 11px !important; background: #202125 !important; white-space: nowrap;
}
.d-actions button:hover:not(:disabled), .d-dbtns button:hover { background: var(--d-hover) !important; }
.d-actions button:disabled { opacity: .4; cursor: default; }
.demo .d-primary { background: var(--d-text) !important; color: #111 !important; border-color: var(--d-text) !important; font-weight: 600; }
.demo .d-primary:hover:not(:disabled) { background: #fff !important; }
.d-slot { display: inline-block; min-width: 16px; margin-left: 7px; padding: 0 3px; background: #111; color: #fff; font-size: 11px; text-align: center; border-radius: 2px; }
.d-slot:empty { background: transparent; }

/* layout */
.d-body { flex: 1; display: flex; min-height: 0; }
.d-left { width: 236px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--d-line); background: var(--d-rail); }
.d-top, .d-bottom { flex: 1; overflow-y: auto; min-height: 0; }
.d-bottom { border-top: 1px solid var(--d-line); }
.d-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.d-outline { width: 184px; flex: none; overflow-y: auto; padding: 10px 0; border-left: 1px solid var(--d-line); background: var(--d-rail); }

/* left rail */
.d-find { display: block; width: calc(100% - 20px); margin: 10px; padding: 6px 9px; background: var(--d-bg); border: 1px solid var(--d-line); border-radius: 5px; outline: none; user-select: text; }
.d-find:focus { border-color: #5b6070; }
.d-find::placeholder { color: var(--d-muted); }
.d-group { padding: 10px 14px 4px; color: var(--d-muted); font-size: 12px; }
.d-req { display: flex !important; align-items: baseline; gap: 10px; width: 100%; padding: 5px 14px !important; border-left: 2px solid transparent !important; white-space: nowrap; }
.d-req:hover { background: var(--d-hover) !important; }
.d-req.sel { background: var(--d-sel) !important; border-left-color: var(--d-text) !important; }
.d-req span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.d-req em { font-style: normal; color: var(--d-muted); font-size: 12px; }
.d-uncentry { padding-top: 7px !important; padding-bottom: 7px !important; border-bottom: 1px solid var(--d-line) !important; }
.d-railhead { position: sticky; top: 0; padding: 10px 14px 6px; color: var(--d-muted); font-size: 12px; background: var(--d-rail); }
.d-stage { display: block !important; width: 100%; padding: 4px 14px !important; }
.d-stage:hover { background: var(--d-hover) !important; }
.d-stage > div:first-child { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.d-stage b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.d-stage em { font-style: normal; color: var(--d-muted); font-size: 12px; }
.d-sub { color: var(--d-muted); font-size: 12px; padding-left: 0; }
.d-pips { display: inline-flex; gap: 2px; flex: none; }
.d-pips i { width: 9px; height: 8px; background: #3d4046; }
.d-pips i.on { background: var(--d-text); }
.d-pips i.wip { background: var(--d-warn); }

/* tabs */
.d-tabs { height: 40px; flex: none; display: flex; align-items: stretch; gap: 22px; padding: 0 16px; border-bottom: 1px solid var(--d-line); }
.d-tab { display: flex; align-items: center; border-bottom: 2px solid transparent !important; color: var(--d-muted); }
.d-tab.on { color: var(--d-text); border-bottom-color: var(--d-text) !important; }
.d-tab:hover { color: var(--d-text); }
.d-viewpick { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--d-muted); white-space: nowrap; font-size: 12px; }
.d-viewpick b { color: var(--d-text); font-weight: 400; }
.d-select { background: var(--d-bg); border: 1px solid var(--d-line); border-radius: 4px; padding: 2px 4px; color: var(--d-text) !important; font-size: 12px !important; }

/* stream */
.d-stream { flex: 1; overflow-y: auto; position: relative; padding-bottom: 40px; }
.d-repo { position: sticky; top: 0; z-index: 2; display: flex; align-items: baseline; gap: 10px; padding: 9px 16px; background: var(--d-bg); border-bottom: 1px solid var(--d-line); }
.d-repo b { font-size: 15px; }
.d-repo .d-right { font-size: 12px; align-self: center; }
.d-file { border-bottom: 1px solid #222428; }
.d-fhead { display: flex; align-items: baseline; gap: 8px; padding: 9px 16px 5px; cursor: pointer; }
.d-fhead:hover { background: #1f2023; }
.d-caret { display: inline-block; width: 10px; color: var(--d-muted); font-size: 10px; transition: transform .12s; }
.d-caret.shut { transform: rotate(-90deg); }
.d-diff { padding-bottom: 8px; }
.d-hunk { padding: 4px 0 4px 86px; color: var(--d-muted); font: 11.5px var(--mono); }
.d-line { display: flex; align-items: baseline; min-height: 20px; }
.d-line.add { background: var(--d-addbg); }
.d-line.del { background: var(--d-delbg); }
.d-num { width: 44px; flex: none; padding-right: 10px; text-align: right; color: #62666e; font: 12px var(--mono); }
.d-line.add .d-num, .d-line.add .d-mark { color: var(--d-add); }
.d-line.del .d-num, .d-line.del .d-mark { color: var(--d-del); }
.d-mark { width: 16px; flex: none; text-align: center; font: 12px var(--mono); }
.d-line code { white-space: pre; padding-right: 16px; }
.t-k { color: #c9b8f2; }
.t-s { color: #e2c08d; }
.t-n { color: #e7b94c; }
.t-c { color: #7d828b; font-style: italic; }
.d-uncsec { padding: 14px 16px 2px; color: var(--d-warn); font-weight: 600; }

/* commits */
.d-hint { padding: 10px 16px; color: var(--d-muted); font-size: 12px; }
.d-commit { display: grid !important; grid-template-columns: 64px minmax(0,1fr) 120px 72px; gap: 12px; width: 100%; padding: 7px 16px !important; align-items: baseline; white-space: nowrap; }
.d-commit:hover { background: var(--d-hover) !important; }
.d-commit code { color: var(--d-muted); }
.d-commit .d-csub, .d-commit span { overflow: hidden; text-overflow: ellipsis; }

/* outline */
.d-orepo { padding: 8px 14px 3px; color: var(--d-muted); font-weight: 600; font-size: 12.5px; }
.d-orow { display: flex !important; align-items: center; gap: 8px; width: 100%; padding: 3px 14px !important; color: var(--d-muted); font-size: 12.5px; }
.d-orow span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-orow:hover { color: var(--d-text); background: var(--d-hover) !important; }
.d-orow.cur { color: var(--d-text); }
.d-bar { display: inline-flex; height: 5px; font-style: normal; }
.d-bar b { background: var(--d-add); }
.d-bar s { background: var(--d-del); }

/* status bar */
.d-status { height: 26px; flex: none; display: flex; align-items: center; padding: 0 14px; border-top: 1px solid var(--d-line); background: var(--d-rail); color: var(--d-muted); font-size: 12px; }
.d-task { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.d-prog { display: inline-block; width: 80px; height: 3px; background: var(--d-line); }
.d-prog b { display: block; height: 100%; background: var(--accent); transition: width .15s; }

/* modals */
.d-modal-host { position: absolute; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, .45); }
.d-modal-host.open { display: flex; }
.d-dialog { width: 560px; max-width: calc(100% - 40px); padding: 18px 20px; background: #202125; border: 1px solid #34363c; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.d-dialog h4 { margin: 0 0 4px; font-size: 15px; }
.d-dialog p { margin: 0 0 12px; font-size: 12px; }
.d-plan { max-height: 300px; overflow-y: auto; border: 1px solid var(--d-line); border-radius: 6px; }
.d-prow { display: flex; align-items: baseline; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--d-line); white-space: nowrap; }
.d-prow:last-child { border-bottom: 0; }
.d-prow b { font-weight: 500; width: 120px; flex: none; }
.d-prow.skip { color: var(--d-muted); }
.d-prow .d-right { min-width: 0; overflow: hidden; text-overflow: ellipsis; display: block; }
.d-prow.skip b { color: var(--d-muted); }
.d-prow.doing { background: #26282d; }
.d-prow.doing .d-right::before { content: ""; width: 10px; height: 10px; border: 2px solid var(--d-muted); border-top-color: transparent; border-radius: 50%; animation: d-spin .6s linear infinite; }
.d-prow.ok .d-right { color: var(--d-add); }
@keyframes d-spin { to { transform: rotate(360deg); } }
.d-dbtns { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 14px; min-height: 28px; }

.d-win { width: calc(100% - 80px); height: calc(100% - 70px); display: flex; flex-direction: column; background: var(--d-bg); border: 1px solid #34363c; border-radius: 10px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.d-wtitle { height: 38px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--d-rail); border-bottom: 1px solid var(--d-line); white-space: nowrap; }
.d-wtitle .d-lights i:first-child { background: #ec6a5e; cursor: pointer; }
.d-wtitle code { color: var(--d-muted); }
.d-wbody { flex: 1; display: flex; min-height: 0; }
.d-wtree { width: 180px; flex: none; padding: 8px 0; background: var(--d-rail); border-right: 1px solid var(--d-line); overflow-y: auto; }
.d-wdiff { flex: 1; overflow: auto; padding-top: 8px; }

.d-toast { position: absolute; left: 50%; bottom: 44px; z-index: 20; transform: translateX(-50%); padding: 8px 14px; background: #2b2d32; border: 1px solid #3a3d43; border-radius: 7px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); transition: opacity .35s; white-space: nowrap; }
.d-toast.gone { opacity: 0; }

@media (max-width: 1060px) {
  .d-outline { display: none; }
  .d-hide-narrow { display: none; }
}

/* scrollbars: dark, thin, no white track */
.demo { color-scheme: dark; }
.demo * { scrollbar-width: thin; scrollbar-color: #3a3d43 transparent; }
.demo *::-webkit-scrollbar { width: 8px; height: 8px; background: transparent; }
.demo *::-webkit-scrollbar-track, .demo *::-webkit-scrollbar-corner { background: transparent; }
.demo *::-webkit-scrollbar-thumb { background: #3a3d43; border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }
.demo *::-webkit-scrollbar-thumb:hover { background-color: #50545b; }
