:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --panel-3: #f2f4f7;
  --border: #e6e8ec;
  --border-strong: #d4d8df;
  --text: #1c1f23;
  --muted: #667085;
  --muted-2: #98a1ad;
  --accent: #4f46e5;
  --accent-d: #4338ca;
  --accent-soft: #eef0fe;
  --accent-line: #c7cafa;
  --add: #15803d;
  --add-soft: #e8f6ec;
  --add-strong: #b7e4c4;
  --del: #c62828;
  --del-soft: #fdeeee;
  --del-strong: #f6c2c2;
  --warn: #b45309;
  --a: #d97706;
  --b: #0d9488;
  --mark: #fff1a8;
  --on-color: #fff;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 14px rgba(16,24,40,.05);
  --shadow-h: 0 2px 4px rgba(16,24,40,.06), 0 10px 26px rgba(16,24,40,.09);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --hl-kw: #a626a4; --hl-str: #50a14f; --hl-num: #986801; --hl-com: #a0a1a7; --hl-title: #4078f2; --hl-attr: #c18401;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --panel: #171a20; --panel-2: #1c2027; --panel-3: #222731;
    --border: #2a2f39; --border-strong: #3a404c; --text: #e6e8ec; --muted: #9aa3b2; --muted-2: #6f7886;
    --accent: #818cf8; --accent-d: #a5b4fc; --accent-soft: #23264a; --accent-line: #3d4380;
    --add: #4ade80; --add-soft: #10291b; --add-strong: #1d5a35;
    --del: #f87171; --del-soft: #331417; --del-strong: #6b2328;
    --warn: #fbbf24; --a: #f59e0b; --b: #2dd4bf; --mark: #5b4a00; --on-color: #111318;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-h: 0 6px 22px rgba(0,0,0,.45);
    --hl-kw: #c678dd; --hl-str: #98c379; --hl-num: #d19a66; --hl-com: #7f848e; --hl-title: #61afef; --hl-attr: #e5c07b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.error { color: var(--del); }
.warn { color: var(--warn); }
.spacer { flex: 1; }
code, kbd { font-family: var(--mono); font-size: .9em; }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--panel); font-size: 11px; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.ic { width: 16px; height: 16px; flex-shrink: 0; }
.c-add { color: var(--add); font-weight: 600; }
.c-del { color: var(--del); font-weight: 600; }

/* ---------- buttons / inputs ---------- */
button, .btn-sm {
  font-family: inherit; font-size: 14px; cursor: pointer; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--text);
  padding: 8px 14px; transition: background .12s, border-color .12s, color .12s;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; white-space: nowrap;
}
button:hover, .btn-sm:hover { background: var(--panel-3); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-color); justify-content: center; }
button.primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 10px; }
button.ghost:hover { background: var(--accent-soft); color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-sm .ic { width: 14px; height: 14px; }
.danger { color: var(--del) !important; }
button.danger:hover, .btn-sm.danger:hover { background: var(--del-soft); border-color: var(--del); }
.icon-btn { padding: 6px 8px; }

input[type=text], input[type=password], select {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: var(--panel); color: var(--text); outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23889' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; white-space: nowrap; user-select: none; }
.chk input { accent-color: var(--accent); margin: 0; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; }
.seg button { border: 0; border-radius: 0; padding: 6px 12px; background: var(--panel); color: var(--muted); font-size: 13px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: var(--on-color); }
.seg.sm button { padding: 4px 10px; font-size: 12.5px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.card-h h2 { margin: 0; font-size: 14px; font-weight: 650; }
.count-badge { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 20px; padding: 1px 8px; }

/* A / B markers */
.ab { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 5px;
  font-size: 11px; font-weight: 700; font-style: normal; color: var(--on-color); padding: 0; border: 0; flex-shrink: 0; }
.ab.a { background: var(--a); }
.ab.b { background: var(--b); }

/* ---------- login ---------- */
.login-view { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px 32px; width: 340px; max-width: 100%; box-shadow: var(--shadow); text-align: center; }
.login-card .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.login-card h1 { margin: 0 0 2px; font-size: 20px; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-card input { margin-bottom: 12px; }
.login-card button { width: 100%; }
.login-card .error { min-height: 1.2em; margin-top: 10px; font-size: 13px; }

/* ---------- shell ---------- */
.topbar { display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 22px;
  background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; }
.brand .sub { font-weight: 400; font-size: 12px; color: var(--muted-2); }
.page { max-width: 1480px; margin: 0 auto; padding: 18px 22px 40px; }

/* ---------- home: upload bar ---------- */
.upload-bar { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.upload-form { display: flex; gap: 10px; align-items: stretch; }
.upload-form .dropzone { flex: 1 1 auto; min-width: 0; }
.upload-form #note { flex: 0 1 280px; }
.dropzone { display: flex; align-items: center; gap: 12px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 14px; cursor: pointer; background: var(--panel-2); transition: .12s; color: var(--muted); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone.has-file { border-style: solid; border-color: var(--accent-line); background: var(--accent-soft); }
.dz-ic { display: inline-flex; width: 30px; height: 30px; border-radius: 8px; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--border); color: var(--accent); flex-shrink: 0; }
.dz-text { display: flex; flex-direction: column; min-width: 0; }
.dz-title { font-size: 13.5px; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-title .file-name { color: var(--accent); }
.dz-text small { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-result { font-size: 13px; }
.upload-result:not(:empty) { margin-top: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: var(--radius-sm); }
.upload-result .ok { color: var(--add); }
.upload-result .skip { color: var(--muted); }
.upload-result .err { color: var(--del); }
.upload-result a { font-weight: 600; }

.drop-overlay { position: fixed; inset: 0; z-index: 100; background: color-mix(in srgb, var(--accent) 14%, transparent);
  backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-overlay div { background: var(--panel); border: 2px dashed var(--accent); color: var(--accent); font-weight: 600;
  padding: 26px 36px; border-radius: 16px; font-size: 16px; box-shadow: var(--shadow-h); }

/* ---------- home: toolbar + cards ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; flex-wrap: wrap; }
.search { position: relative; flex: 0 1 380px; min-width: 200px; }
.search input { padding-left: 34px; }
.search-ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-2); display: inline-flex; }
#sort-sel { width: auto; min-width: 170px; }
#skill-count { font-size: 13px; }
.custom-hint { font-size: 12.5px; color: var(--muted); background: var(--accent-soft); border-radius: var(--radius-sm); padding: 7px 12px; margin: -4px 0 14px; }

.sec-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted);
  letter-spacing: .04em; margin: 4px 2px 10px; }
.sec-h span { font-weight: 600; color: var(--muted-2); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-bottom: 22px; }

.scard { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 14px 14px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text); transition: border-color .12s, box-shadow .12s, transform .12s; min-height: 148px; }
.scard:hover { border-color: var(--accent-line); box-shadow: var(--shadow-h); transform: translateY(-1px); }
.scard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scard.flash { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }
.scard.dragging { opacity: .55; transform: scale(.98); box-shadow: 0 0 0 2px var(--accent); }
.sc-top { display: flex; align-items: flex-start; gap: 10px; }
.mono { width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; letter-spacing: .02em;
  background: hsl(var(--h) 70% 94%); color: hsl(var(--h) 55% 36%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mono { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 70% 78%); } }
.sc-title { flex: 1; min-width: 0; }
.sc-name { font-weight: 650; font-size: 14.5px; line-height: 1.3; overflow-wrap: anywhere; }
.sc-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sc-sub b { color: var(--text); font-weight: 600; }
.pin { border: 0; background: transparent; padding: 3px; color: var(--border-strong); margin: -2px -2px 0 0; }
.pin .ic { width: 18px; height: 18px; }
.pin:hover { background: var(--panel-3); color: var(--muted); }
.pin.on { color: #f5b301; }
.pin.on .ic { fill: currentColor; }
.grip { cursor: grab; color: var(--muted-2); padding: 3px; margin-top: -2px; border-radius: 6px; touch-action: none; display: inline-flex; }
.grip:hover { background: var(--panel-3); color: var(--text); }
.grip .ic { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.sc-desc { margin: 0; font-size: 12.8px; color: var(--muted); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sc-foot { margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 12px; color: var(--muted); }
.sc-note { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-state { background: var(--panel); border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 56px 30px; text-align: center; color: var(--muted); }
.empty-state .big { font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 6px; }

/* ---------- skill detail ---------- */
.skill-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.back { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); flex-shrink: 0; margin-top: 2px; }
.back:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.back .ic { width: 18px; height: 18px; }
.sh-main { flex: 1; min-width: 0; }
.sh-main h1 { margin: 0; font-size: 21px; line-height: 1.3; overflow-wrap: anywhere; }
.sk-desc { margin: 4px 0 6px; color: var(--muted); font-size: 13px; line-height: 1.6; max-width: 980px; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sk-desc:empty { display: none; }
.sk-desc.open { -webkit-line-clamp: unset; display: block; }
.sk-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--muted); }
.sk-meta b { color: var(--text); }
.sh-actions { display: flex; gap: 8px; flex-shrink: 0; }

.skill-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }

/* timeline */
.timeline { position: sticky; top: 70px; max-height: calc(100vh - 86px); display: flex; flex-direction: column; overflow: hidden; }
.tl-legend { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.tl-legend .ab { width: 16px; height: 16px; font-size: 10px; margin-left: 4px; }
.vlist { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.vrow { position: relative; display: flex; gap: 10px; padding: 10px 10px 8px 12px; border-radius: var(--radius-sm); cursor: pointer; outline: none; }
.vrow::before { content: ""; position: absolute; left: 16px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.vrow:first-child::before { top: 18px; }
.vrow:last-child::before { bottom: calc(100% - 18px); }
.vrow:hover, .vrow:focus-visible { background: var(--panel-2); }
.vrow.cur { background: var(--accent-soft); }
.vrow.range { background: var(--panel-3); }
.vrow.is-a { box-shadow: inset 3px 0 0 var(--a); }
.vrow.is-b { box-shadow: inset 3px 0 0 var(--b); }
.vdot { position: relative; z-index: 1; width: 10px; height: 10px; border-radius: 50%; background: var(--panel); border: 2px solid var(--border-strong); margin-top: 4px; flex-shrink: 0; }
.vrow:first-child .vdot { border-color: var(--accent); background: var(--accent); }
.vrow.cur .vdot { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-line); }
.vrow.is-a .vdot { border-color: var(--a); background: var(--a); }
.vrow.is-b .vdot { border-color: var(--b); background: var(--b); }
.vmain { flex: 1; min-width: 0; }
.vtop { display: flex; align-items: center; gap: 6px; }
.vnum { font-family: var(--mono); font-size: 12.5px; font-weight: 700; }
.vtag { font-size: 10px; font-weight: 700; color: var(--on-color); background: var(--accent); border-radius: 4px; padding: 0 5px; line-height: 16px; }
.vdate { margin-left: auto; font-size: 11.5px; color: var(--muted-2); }
.vnote { font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vmeta { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.vacts { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.vacts .ab { width: 22px; height: 20px; background: var(--panel-3); color: var(--muted); border: 1px solid var(--border); cursor: pointer; }
.vacts .ab.a:hover, .vacts .ab.a.on { background: var(--a); color: var(--on-color); border-color: var(--a); }
.vacts .ab.b:hover, .vacts .ab.b.on { background: var(--b); color: var(--on-color); border-color: var(--b); }
.ib { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 24px; padding: 0; border-radius: 6px;
  border: 1px solid transparent; background: transparent; color: var(--muted); opacity: 0; transition: opacity .12s; }
.ib .ic { width: 15px; height: 15px; }
.ib:hover { background: var(--panel); border-color: var(--border); color: var(--text); }
.vrow:hover .ib, .vrow:focus-within .ib, .vrow.cur .ib, .vrow.is-a .ib, .vrow.is-b .ib { opacity: 1; }
@media (hover: none) { .ib { opacity: 1; } }

/* main panel */
.panel { min-width: 0; overflow: hidden; }
.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.tab { padding: 11px 14px 10px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.pane-bar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.pb-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.pb-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pb-actions, .fv-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.pane-msg { padding: 40px 20px; text-align: center; color: var(--muted); }
.pm-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

.split-body { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 420px; }
.ftree { border-right: 1px solid var(--border); padding: 8px 6px; background: var(--panel-2); font-size: 13px; overflow: auto; }
.ft-h { font-size: 11.5px; color: var(--muted); padding: 2px 8px 8px; display: flex; align-items: center; gap: 5px; }
.ftree ul { list-style: none; margin: 0; padding: 0 0 0 12px; }
.ftree > ul { padding-left: 0; }
.ftree summary { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; cursor: pointer; color: var(--muted); list-style: none; }
.ftree summary::-webkit-details-marker { display: none; }
.ftree summary:hover { background: var(--panel-3); }
.fi { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; color: var(--text); min-width: 0; }
.fi:hover { background: var(--panel-3); }
.fi.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fi .ic, .ftree summary .ic { width: 14px; height: 14px; color: var(--muted-2); }
.fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-left: auto; background: var(--warn); }
.dot.st-A { background: var(--add); }
.ft-h .dot { margin-left: 0; }

.cmp-files ul.flat { padding: 0; }
.cmp-files .fi { align-items: flex-start; }
.fp { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.fp .dir { color: var(--muted-2); }
.nums { display: flex; gap: 5px; font-size: 11.5px; flex-shrink: 0; }
.st { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 4px;
  font-size: 10.5px; font-weight: 700; color: var(--on-color); background: var(--warn); flex-shrink: 0; margin-top: 1px; }
.st.st-A { background: var(--add); }
.st.st-D { background: var(--del); }
.st.st-R, .st.st-C { background: var(--accent); }
.fv-path .st { width: auto; margin-right: 2px; }

.fview { min-width: 0; }
.fv-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 54px; background: var(--panel); z-index: 5; }
.fv-path { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fv-path .c-add, .fv-path .c-del { font-size: 12px; }
.arrow { color: var(--muted-2); }
.fv-body { padding: 0; }

/* code view */
.code { display: flex; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; overflow-x: auto; }
.code pre { margin: 0; padding: 12px 0; }
.code .gut { padding: 12px 10px 12px 14px; text-align: right; color: var(--muted-2); user-select: none; background: var(--panel-2);
  border-right: 1px solid var(--border); position: sticky; left: 0; }
.code .src { padding-left: 14px; padding-right: 20px; flex: 1; }
.code code { font-size: inherit; tab-size: 4; }

/* markdown view */
.fm { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 16px 24px 0; padding: 12px 14px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.fm dt { font-family: var(--mono); color: var(--muted); font-size: 12px; padding-top: 1px; }
.fm dd { margin: 0; overflow-wrap: anywhere; }
.md-body { padding: 8px 24px 28px; line-height: 1.75; font-size: 14.5px; max-width: 980px; overflow-wrap: anywhere; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { line-height: 1.35; margin: 1.5em 0 .6em; }
.md-body h1 { font-size: 1.6em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.md-body h2 { font-size: 1.3em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.md-body h3 { font-size: 1.12em; }
.md-body p, .md-body ul, .md-body ol, .md-body blockquote, .md-body table, .md-body pre { margin: .7em 0; }
.md-body ul, .md-body ol { padding-left: 1.6em; }
.md-body li + li { margin-top: .2em; }
.md-body code { background: var(--panel-3); padding: .1em .35em; border-radius: 4px; font-size: .86em; }
.md-body pre { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; overflow-x: auto; }
.md-body pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.55; }
.md-body blockquote { border-left: 3px solid var(--border-strong); padding: 2px 14px; color: var(--muted); }
.md-body table { border-collapse: collapse; display: block; overflow-x: auto; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.md-body th { background: var(--panel-2); }
.md-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md-body img { max-width: 100%; }
.md-body a.broken { color: var(--muted); text-decoration: line-through dotted; }
.md-body a[data-rel]:not(.broken) { cursor: pointer; }
.img-box { padding: 20px; text-align: center; background: repeating-conic-gradient(var(--panel-3) 0 25%, var(--panel) 0 50%) 0 0 / 16px 16px; }
.img-box img { max-width: 100%; box-shadow: var(--shadow); }

/* ---------- compare ---------- */
.cmp-bar { gap: 10px; }
.cmp-pick { display: flex; align-items: center; gap: 6px; flex: 1 1 520px; min-width: 0; }
.cmp-pick select { flex: 1; min-width: 0; font-size: 13px; padding-top: 6px; padding-bottom: 6px; }
.kbd-hint { font-size: 12px; color: var(--muted-2); white-space: nowrap; }
.cmp-overview { padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2); font-size: 13px; }
.cmp-overview:empty { display: none; }
.ov-line { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.ov-notes { margin-top: 8px; }
.ov-notes summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.ov-notes ol { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.ov-notes li { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; }
.fm-diff { margin-top: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.fm-diff-h { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.fm-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; padding: 4px 0; }
.fm-row + .fm-row { border-top: 1px dashed var(--border); }
.fm-k { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 2px; }
.fm-v { line-height: 1.7; overflow-wrap: anywhere; white-space: pre-wrap; }
.diff-note { margin: 10px 14px 0; font-size: 12.5px; color: var(--warn); }

/* inline word marks (doc mode + frontmatter) */
del, ins { text-decoration: none; border-radius: 3px; padding: 0 1px; }
del { background: var(--del-strong); color: var(--del); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--del) 60%, transparent); }
ins { background: var(--add-strong); color: inherit; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) del { color: #ffb4b4; } }
.nl { font-size: .85em; opacity: .7; padding: 0 1px; }

/* doc mode */
.diff-body { padding: 8px 0 16px; }
.dv.doc { font-size: 14px; line-height: 1.75; }
.dr { display: grid; grid-template-columns: 64px minmax(0, 1fr); border-left: 3px solid transparent; }
.dr .ln { text-align: right; padding: 0 12px 0 0; font-family: var(--mono); font-size: 11px; color: var(--muted-2); padding-top: .45em; user-select: none; }
.dr .tx { padding: 1px 24px 1px 4px; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; max-width: 1000px; }
.dr.eq .tx { color: color-mix(in srgb, var(--text) 82%, transparent); }
.dr.h .tx { font-weight: 650; color: var(--text); }
.dr.mod { background: color-mix(in srgb, var(--warn) 6%, transparent); border-left-color: var(--warn); margin: 3px 0; padding: 4px 0; }
.dr.del { background: var(--del-soft); border-left-color: var(--del); }
.dr.del .tx { color: var(--del); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--del) 45%, transparent); }
.dr.ins { background: var(--add-soft); border-left-color: var(--add); }
.dr.fold, tr.fold td { text-align: center; padding: 2px 0; }
.dr.fold { display: block; margin: 4px 0; }
.dr.fold button, tr.fold button { width: 100%; border: 0; border-radius: 0; justify-content: center; font: 12px var(--sans); color: var(--muted);
  background: var(--panel-2); border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); padding: 5px; }
.dr.fold button:hover, tr.fold button:hover { background: var(--accent-soft); color: var(--accent); }
[data-chg].pulse { animation: pulse 1.2s ease-out; }
@keyframes pulse { 0% { box-shadow: inset 0 0 0 2px var(--accent); } 100% { box-shadow: inset 0 0 0 2px transparent; } }

/* split / unified tables */
table.dv { width: 100%; border-collapse: collapse; table-layout: fixed; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
table.dv col.c-ln { width: 48px; }
table.dv col.c-sg { width: 20px; }
table.dv td { padding: 0 8px; vertical-align: top; }
table.dv td.ln { text-align: right; color: var(--muted-2); font-size: 11px; padding-top: 2px; user-select: none; background: var(--panel-2); }
table.dv td.tx { white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
table.dv td.sg { text-align: center; color: var(--muted); user-select: none; padding: 0; }
table.dv tr.del td, table.dv td.del { background: var(--del-soft); }
table.dv tr.ins td, table.dv td.ins { background: var(--add-soft); }
table.dv tr.del td.ln, table.dv td.ln.del { background: color-mix(in srgb, var(--del-soft) 70%, var(--del-strong)); }
table.dv tr.ins td.ln, table.dv td.ln.ins { background: color-mix(in srgb, var(--add-soft) 70%, var(--add-strong)); }
table.dv td.empty { background: var(--panel-3); }
table.dv.split td.tx.del, table.dv.split td.ln.ins { border-left: 0; }
table.dv.split td.ln:nth-child(3) { border-left: 1px solid var(--border); }
table.dv .x { border-radius: 2px; }
table.dv tr.del .x, table.dv td.del .x { background: var(--del-strong); }
table.dv tr.ins .x, table.dv td.ins .x { background: var(--add-strong); }

/* highlight.js tokens */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-type, .hljs-literal { color: var(--hl-kw); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string { color: var(--hl-str); }
.hljs-number, .hljs-symbol, .hljs-bullet { color: var(--hl-num); }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--hl-com); font-style: italic; }
.hljs-title, .hljs-section, .hljs-function .hljs-title, .hljs-title.function_ { color: var(--hl-title); font-weight: 600; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-name, .hljs-selector-class, .hljs-params { color: var(--hl-attr); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }
.hljs-link { color: var(--accent); }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--panel); padding: 8px 16px; border-radius: 20px; font-size: 13px; box-shadow: var(--shadow-h);
  transition: opacity .3s, transform .3s; max-width: calc(100vw - 32px); }
.toast.ok { background: var(--add); color: var(--on-color); }
.toast.err { background: var(--del); color: var(--on-color); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .skill-body { grid-template-columns: 1fr; }
  .timeline { position: static; max-height: 300px; }
  .split-body { grid-template-columns: 200px minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .page { padding: 12px 16px 32px; }
  .topbar { padding: 0 16px; }
  .brand .sub { display: none; }
  .upload-form { flex-direction: column; }
  .upload-form #note { flex: none; }
  .search { flex: 1 1 100%; }
  .skill-head { flex-wrap: wrap; }
  .sh-actions { width: 100%; }
  .split-body { grid-template-columns: 1fr; }
  .ftree { border-right: 0; border-bottom: 1px solid var(--border); max-height: 220px; }
  .fv-h { position: static; }
  .dr { grid-template-columns: 40px minmax(0, 1fr); }
  .dr .tx { padding-right: 12px; }
  .md-body { padding: 8px 16px 24px; }
  .fm { margin: 12px 16px 0; }
  .kbd-hint { display: none; }
  .cmp-pick { flex-basis: 100%; }
}
