:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --panel-2: #fafaf8;
  --line: #e7e6e1;
  --line-2: #d9d8d2;
  --text: #1c1c1a;
  --text-2: #5f5e58;
  --text-3: #8f8d86;
  --accent: #5b5bd6;
  --accent-soft: #ececfd;
  --accent-text: #4040b8;
  --star: #e8a317;
  --danger: #d1453b;
  --ok: #2f9e5b;
  --warn: #c98a12;
  --shadow: 0 1px 2px rgba(20, 20, 15, .05), 0 4px 16px rgba(20, 20, 15, .06);
  --shadow-lg: 0 10px 40px rgba(20, 20, 15, .18);
  --radius: 12px;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 48px;
  --vt-bg: #f0f0ee;
  --vt-ink-muted: #5f5e58;
  --vt-ink-subtle: #8f8d86;
  --vt-success: #27a644;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131313; --vt-bg: #232425; --vt-ink-muted: #d0d6e0; --vt-ink-subtle: #8a8f98; --panel: #1b1b1b; --panel-2: #202020; --line: #2c2c2b; --line-2: #3a3a38;
    --text: #ecebe6; --text-2: #aeada6; --text-3: #7c7b75; --accent: #8d8dff; --accent-soft: #26264a;
    --accent-text: #b4b4ff; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131313; --vt-bg: #232425; --vt-ink-muted: #d0d6e0; --vt-ink-subtle: #8a8f98; --panel: #1b1b1b; --panel-2: #202020; --line: #2c2c2b; --line-2: #3a3a38;
  --text: #ecebe6; --text-2: #aeada6; --text-3: #7c7b75; --accent: #8d8dff; --accent-soft: #26264a;
  --accent-text: #b4b4ff; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.6); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 var(--ui); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); }
code { font: 12px ui-monospace, Menlo, monospace; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line); }
[hidden] { display: none !important; }

.ico { display: inline-flex; width: 16px; height: 16px; flex: none; }
.ico svg, .icon-btn svg { width: 100%; height: 100%; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
#sidebar {
  background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto;
  padding: 14px 10px 24px; display: flex; flex-direction: column; gap: 4px;
}
#main { overflow-y: auto; position: relative; }
#scrim { display: none; }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; padding: 2px 8px 10px; }
.logo {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font: 600 14px Georgia, serif;
}
.logo.big { width: 52px; height: 52px; border-radius: 14px; font-size: 26px; margin: 0 auto 6px; }

.folder { margin: 0 4px 8px; padding: 9px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.folder-path { font-size: 12px; color: var(--text-2); word-break: break-all; line-height: 1.35; max-height: 3.6em; overflow: hidden; }
.folder-actions { display: flex; gap: 4px; margin-top: 6px; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 9px; border-radius: 8px; border: 0; background: none;
  text-align: left; color: var(--text); text-decoration: none; position: relative; min-height: 31px; width: 100%;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 560; }
.nav-item .ico { color: var(--text-3); }
.nav-item.active .ico { color: var(--accent-text); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item .cat-actions { display: none; gap: 2px; }
.nav-item:hover .cat-actions, .nav-item:focus-within .cat-actions { display: flex; }
.nav-item:hover .count { display: none; }
.nav-item.drop { outline: 2px dashed var(--accent); }

.side-title {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 9px 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600;
}
.filters { padding: 4px 9px; display: flex; flex-direction: column; gap: 9px; }
.check-line { display: flex; align-items: center; gap: 7px; color: var(--text-2); cursor: pointer; }
.check-line input { accent-color: var(--accent); }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------- controls ---------- */
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: none; padding: 7px;
  display: inline-grid; place-items: center; color: var(--text-2); flex: none;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.sm { width: 24px; height: 24px; padding: 4px; }
.icon-btn.on { background: var(--accent-soft); color: var(--accent-text); }
.btn, .btn-ghost {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font-weight: 520; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--text-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 99px;
  border: 1px solid var(--line-2); background: var(--panel); font-size: 12px; color: var(--text-2); white-space: nowrap;
}
button.chip:hover { border-color: var(--text-3); color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
input[type="text"], input[type="search"], input[type="password"], textarea, select {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; height: 32px; outline: none;
}
textarea { padding: 8px 10px; height: auto; resize: vertical; line-height: 1.5; width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="range"] { accent-color: var(--accent); }

/* ---------- toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
#btnMenu { display: none; }
.search { position: relative; flex: 0 1 260px; min-width: 150px; }
.search .ico { position: absolute; left: 10px; top: 8px; color: var(--text-3); }
.search input { width: 100%; padding-left: 32px; }
.sample { position: relative; flex: 1 1 300px; min-width: 160px; display: flex; gap: 6px; align-items: center; }
.sample input { flex: 1; min-width: 0; }
.presets { display: flex; gap: 4px; }
.size { display: flex; align-items: center; gap: 8px; flex: none; }
.size input { width: 110px; }
#sizeLabel { width: 42px; color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 12px; }
.seg { display: flex; border: 1px solid var(--line-2); border-radius: 9px; padding: 2px; gap: 2px; background: var(--panel); }
.seg .icon-btn { width: 28px; height: 26px; padding: 5px; }

.subbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px 4px; color: var(--text-2); }
#summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 26px; }
#summary b { color: var(--text); font-weight: 600; }
.subbar-right { display: flex; gap: 6px; align-items: center; }
.subbar select { height: 28px; font-size: 12px; }


/* ---------- bộ lọc ở thanh bên ----------
   Bố cục theo Google Fonts: nhóm gập được, đặt lại kèm số bộ lọc đang bật.
   Hình dáng theo Shopify: chip và công tắc dạng pill, nhịp 8px, viền hairline. Màu và font giữ nguyên của app. */
.fpanel { margin: 8px 0 4px; border-top: 1px solid var(--line); }
.fpanel-head { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 9px; }
.fpanel-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }
.badge-n { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 11px; font-variant-numeric: tabular-nums; }
.fsec { border-top: 1px solid var(--line); }
.fsec:first-of-type { border-top: 0; }
.fsec-head { display: flex; align-items: center; justify-content: space-between; padding-right: 4px; }
.fsec-toggle {
  flex: 1; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 9px; border: 0; background: none;
  color: var(--text); font-weight: 560; text-align: left; border-radius: 8px;
}
.fsec-toggle:hover { background: var(--panel-2); }
.fsec-toggle .chev { width: 14px; height: 14px; color: var(--text-3); transition: transform .15s; }
.fsec.closed .chev { transform: rotate(-90deg); }
.fsec-tools { display: flex; gap: 2px; }
.fsec-body { padding: 4px 9px 14px; }
.fsec-body .chip-row { gap: 8px 6px; }
.fsec-body .sub { padding: 2px 0; }

.fchip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text-2); font-size: 12.5px; white-space: nowrap; cursor: pointer;
}
.fchip:hover:not(:disabled):not(.on) { border-color: var(--text-3); color: var(--text); }
.fchip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 560; }
.fchip .n, .frow .n, .fswitch .n { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.fchip.on .n { color: inherit; opacity: .8; }
.fchip.cat .cat-edit { display: inline-flex; gap: 0; margin-right: -8px; }
.fchip:disabled, .frow:disabled { opacity: .45; cursor: not-allowed; }
.fchip:focus-visible, .frow:focus-visible, .fswitch:focus-visible, .fsec-toggle:focus-visible, #fMinStyles:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.frow { display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--text-2); text-align: left; }
.frow:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.frow .t { flex: 1; min-width: 0; }
.frow.on { color: var(--accent-text); font-weight: 560; }
.frow .radio { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-2); flex: none; background: var(--panel); }
.frow.on .radio { border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--panel), inset 0 0 0 8px var(--accent); }
.frow .vt-ico { width: 10px; height: 10px; }
.frow .vt-ico .vt-dot { width: 7px; height: 7px; }

.range-top, .range-ends { display: flex; justify-content: space-between; color: var(--text-2); }
.range-top b { color: var(--text); font-variant-numeric: tabular-nums; }
.range-ends { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
#fMinStyles { width: 100%; margin: 8px 0 2px; }

.fswitch { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--text-2); text-align: left; }
.fswitch:hover { background: var(--panel-2); color: var(--text); }
.fswitch .t { flex: 1; min-width: 0; }
.fswitch .track { width: 32px; height: 18px; border-radius: 99px; background: var(--line-2); position: relative; flex: none; transition: background .15s; }
.fswitch .track i { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.fswitch.on .track { background: var(--accent); }
.fswitch.on .track i { transform: translateX(14px); }
.fswitch.on { color: var(--text); }

/* chip trong tóm tắt: bấm để bỏ lọc đó */
.chip.rm { cursor: pointer; padding-right: 5px; }
.chip.rm .x { width: 14px; height: 14px; display: inline-grid; place-items: center; border-radius: 50%; }
.chip.rm .x svg { width: 10px; height: 10px; }
.chip.rm:hover .x { background: color-mix(in srgb, var(--accent-text) 18%, transparent); }
.chip.rm:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#empty .btn { margin-top: 14px; }
@media (prefers-reduced-motion: reduce) { .fsec-toggle .chev, .fswitch .track, .fswitch .track i { transition: none; } }

/* ---------- results ---------- */
#results { padding: 10px 20px 20px; }
#results.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(clamp(250px, calc(var(--fs) * 5.2), 620px), 1fr));
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); position: relative;
  display: flex; flex-direction: column; min-width: 0; transition: border-color .12s, box-shadow .12s; cursor: pointer;
}
.card:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card .preview {
  padding: 12px 16px 6px; min-height: calc(var(--fs) * 2 + 18px); display: flex; align-items: center;
  overflow: hidden;
}
.fontsample {
  font-size: var(--fs); line-height: 1.25; color: var(--text); overflow-wrap: anywhere; width: 100%;
  transition: opacity .2s; font-synthesis: none;
}
.card .fontsample { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: normal; white-space: pre-wrap; padding: .42em 0 .32em; }
.card .preview { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.fontsample.pending { opacity: .12; }
.fontsample.failed { opacity: .5; font-size: 13px !important; font-family: var(--ui) !important; color: var(--danger); }
.card .meta { padding: 8px 14px 12px; display: flex; align-items: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.card .meta-text { flex: 1; min-width: 0; }
.name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
/* chip danh mục trong card: cùng kiểu pill với nhãn Việt hoá (status-badge của Linear) */
.tags .chip { height: auto; padding: 2px 8px; border: 0; border-radius: 9999px; background: var(--vt-bg); color: var(--vt-ink-muted); font: 400 12px/1.40 var(--ui); letter-spacing: 0; }
.badge { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 5px; letter-spacing: .02em; }
.badge.vi-full { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.badge.vi-partial { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.badge.vi-none, .badge.plain { color: var(--text-3); background: var(--panel-2); }
.badge.vi-no { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }

/* ---------- nhãn Việt hoá — theo status-badge của Linear ----------
   pill: nền surface-2, chữ caption 12px/400/1.40, letter-spacing 0, bo 9999px, padding 2px 8px, không viền.
   Trạng thái nằm ở chấm 6px; màu ngữ nghĩa duy nhất là xanh #27a644, không dùng đỏ/cam. */
.vt {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 9999px;
  background: var(--vt-bg); color: var(--vt-ink-muted);
  font: 400 12px/1.40 var(--ui); letter-spacing: 0; white-space: nowrap;
}
.vt-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; display: none; }
.vt-full .vt-dot, .vt-partial .vt-dot, .vt-none .vt-dot { display: block; }
.vt-full .vt-dot { background: var(--vt-success); }
.vt-partial .vt-dot { background: linear-gradient(90deg, var(--vt-success) 50%, transparent 50%); box-shadow: inset 0 0 0 1px var(--vt-success); }
.vt-none .vt-dot { box-shadow: inset 0 0 0 1.25px currentColor; }
.vt-none { color: var(--vt-ink-subtle); }
/* chấm ở thanh bên dùng cùng ngôn ngữ */
.vt-ico { width: 16px; height: 16px; display: grid; place-items: center; flex: none; color: var(--vt-ink-subtle); }
.vt-ico .vt-dot { width: 7px; height: 7px; }
/* lưới: nhãn trong hàng tag; danh sách: cột riêng, thẳng hàng */
.row-vi { display: none; }
#results.list .tag-vi { display: none; }
#results.list .row-vi { display: flex; order: 3; width: 150px; flex: none; padding: 0 8px; }
#results.list .row-actions { order: 4; }
.tag-vi { display: contents; }
.vi-note { font-size: 12px; line-height: 1.4; color: var(--vt-ink-subtle); padding: 4px 9px 4px 34px; }
.vi-missing { margin-top: 6px; font: 400 12px/1.40 var(--ui); color: var(--vt-ink-subtle); }
.vi-missing span { color: var(--vt-ink-muted); letter-spacing: .08em; }
.fontsample .miss, #missLegend .miss { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); border-radius: .08em; }
.dr-head .tags { margin-top: 6px; }
#missLegend { font-size: 12px; color: var(--text-3); margin-right: auto; }
#missLegend .miss { font-weight: 700; padding: 0 2px; }

.card-top { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; pointer-events: none; z-index: 1; }
.card-top > * { pointer-events: auto; }
.card-top .right { display: flex; align-items: center; gap: 2px; }
.card-actions .icon-btn { background: var(--panel); }
.star-btn.on svg { fill: currentColor; }
.selbox {
  width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line-2); background: var(--panel);
  display: grid; place-items: center; opacity: 0; transition: opacity .1s; padding: 3px; color: #fff;
}
.card:hover .selbox, .selecting .selbox, .selbox:focus-visible { opacity: 1; }
.selected .selbox { background: var(--accent); border-color: var(--accent); }
.selbox svg { width: 100%; height: 100%; visibility: hidden; }
.selected .selbox svg { visibility: visible; }
.star-btn { width: 28px; height: 28px; padding: 5px; border-radius: 7px; border: 0; background: none; color: var(--text-3); opacity: 0; }
.card:hover .star-btn, .star-btn.on, .star-btn:focus-visible { opacity: 1; }
.star-btn:hover { background: var(--panel-2); }
.star-btn.on { color: var(--star); }
.star-btn svg { width: 100%; height: 100%; }
.card-actions { display: flex; gap: 2px; opacity: 0; }
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; }

/* list mode */
#results.list { display: flex; flex-direction: column; gap: 0; padding-top: 6px; }
#results.list .card { flex-direction: row; align-items: center; border-radius: 0; border-width: 0 0 1px; background: transparent; }
#results.list .card:first-child { border-top-width: 1px; }
#results.list .card:hover { background: var(--panel); box-shadow: none; }
#results.list .card.selected { background: var(--accent-soft); box-shadow: none; }
#results.list .card-top { position: static; width: auto; gap: 2px; padding-left: 4px; order: 0; flex: none; }
#results.list .card-top .card-actions { display: none; }
#results.list .meta { order: 1; border: 0; width: 240px; flex: none; padding: 10px 12px; align-items: center; }
#results.list .preview { order: 2; flex: 1; min-width: 0; padding: 8px 12px; min-height: calc(var(--fs) * 1.5 + 16px); }
#results.list .fontsample { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: none; padding: .42em 0 .32em; }
#results.list .row-actions { order: 3; display: flex; gap: 2px; padding-right: 10px; opacity: 0; }
#results.list .card:hover .row-actions { opacity: 1; }
#results.grid .row-actions { display: none; }

#sentinel { height: 1px; }
#empty { text-align: center; color: var(--text-3); padding: 80px 20px; font-size: 14px; }
#empty .big { font-size: 40px; font-family: Georgia, serif; color: var(--line-2); margin-bottom: 8px; }

/* ---------- bulk bar ---------- */
#bulkbar {
  position: fixed; left: calc(248px + (100vw - 248px) / 2); transform: translateX(-50%); bottom: 20px; z-index: 40;
  display: flex; align-items: center; gap: 6px; padding: 7px 7px 7px 16px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg);
}
#bulkCount { font-weight: 600; margin-right: 6px; white-space: nowrap; }

/* ---------- drawer ---------- */
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 50; background: var(--panel);
  border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); transform: translateX(105%);
  transition: transform .22s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column;
}
#drawer.open { transform: none; }
.dr-head { display: flex; align-items: flex-start; gap: 10px; padding: 18px 18px 12px; border-bottom: 1px solid var(--line); }
.dr-head h2 { margin: 0; font-size: 19px; line-height: 1.25; font-weight: 650; word-break: break-word; }
.dr-head .sub { white-space: normal; margin-top: 3px; }
.dr-title { flex: 1; min-width: 0; }
.dr-body { overflow-y: auto; padding: 4px 18px 30px; flex: 1; }
.dr-section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.dr-section:last-child { border-bottom: 0; }
.dr-section h3 { margin: 0 0 9px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.style-row { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.style-row:last-child { border-bottom: 0; }
.style-row .style-name { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--text-3); gap: 8px; }
.style-row .fontsample { font-size: min(var(--fs), 56px); margin-top: 2px; }
dl.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--text-3); }
dl.kv dd { margin: 0; word-break: break-word; }
.license { max-height: 90px; overflow: auto; font-size: 12px; color: var(--text-2); white-space: pre-wrap; }
.file-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.file-row .path { flex: 1; min-width: 0; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.file-row .ext { font: 600 10.5px ui-monospace, Menlo, monospace; text-transform: uppercase; color: var(--text-3); width: 42px; }
.saved { font-size: 11px; color: var(--ok); text-transform: none; letter-spacing: 0; font-weight: 500; opacity: 0; transition: opacity .2s; }
.saved.show { opacity: 1; }

.glyphs { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 3px; }
.glyph {
  height: 46px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; font-size: 24px;
  background: var(--panel-2); position: relative;
}
.glyph:hover { border-color: var(--accent); }
.glyph.missing { color: var(--danger); opacity: .55; font-family: var(--ui) !important; font-size: 15px; text-decoration: line-through; background: none; border-style: dashed; }
.glyph-head { font-size: 12px; color: var(--text-2); margin: 12px 0 6px; font-weight: 560; }
.glyph-head:first-child { margin-top: 0; }

/* ---------- popover / modal ---------- */
#popover {
  position: fixed; z-index: 70; min-width: 230px; max-width: 300px; max-height: 60vh; overflow: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.pop-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 9px; border: 0; background: none; border-radius: 7px; text-align: left; }
.pop-item:hover { background: var(--panel-2); }
.pop-item .box { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--line-2); display: grid; place-items: center; color: #fff; flex: none; }
.pop-item .box.all { background: var(--accent); border-color: var(--accent); }
.pop-item .box.some { background: var(--accent); border-color: var(--accent); }
.pop-item .box svg { width: 12px; height: 12px; }
.pop-sep { height: 1px; background: var(--line); margin: 5px 2px; }
.pop-title { padding: 6px 9px 4px; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

#modal { position: fixed; inset: 0; z-index: 80; background: rgba(10, 10, 8, .38); display: grid; place-items: center; padding: 20px; }
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: min(460px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column;
}
.modal-card.wide { width: min(760px, 100%); }
.modal-card h2 { margin: 0; padding: 18px 20px 6px; font-size: 16px; }
.modal-card .m-body { padding: 8px 20px; overflow: auto; color: var(--text-2); }
.modal-card .m-body input[type="text"] { width: 100%; }
.modal-card .m-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }
.dup-group { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.dup-group .name { margin-bottom: 4px; }
.sug-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.sug-row .name { width: 200px; flex: none; color: var(--text); }
.sug-row .fontsample { font-size: 22px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- setup / scanning / toast ---------- */
#setup, #scanning { position: fixed; inset: 0; z-index: 90; background: var(--bg); display: grid; place-items: center; padding: 20px; }
#scanning { background: color-mix(in srgb, var(--bg) 80%, transparent); }
.setup-card, .scan-card {
  width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); padding: 30px; text-align: center;
}
.setup-card h1 { margin: 0 0 6px; font-size: 22px; }
.setup-card p { color: var(--text-2); margin: 0 0 18px; }
.setup-card .or { color: var(--text-3); font-size: 12px; margin: 16px 0 8px; }
.setup-card form { display: flex; gap: 6px; }
.setup-card form input { flex: 1; }
.err { color: var(--danger) !important; margin: 12px 0 0 !important; min-height: 1em; }
.scan-card { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-2); }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { width: 100%; height: 5px; background: var(--line); border-radius: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 380px; animation: pop .18s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .presets { display: none; }
  .size input { width: 80px; }
}
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.menu-open #sidebar { transform: none; }
  body.menu-open #scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.3); }
  #btnMenu { display: inline-grid; }
  .toolbar { flex-wrap: wrap; padding: 10px 16px; }
  .search { flex: 1 1 200px; }
  .sample { order: 5; flex-basis: 100%; }
  .subbar, #results { padding-left: 16px; padding-right: 16px; }
  #bulkbar { left: 50%; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 32px); }
  #results.list .meta { width: 170px; }
}

/* chạy trên server: không có "Hiện trong Finder" */
.no-reveal [data-act="reveal"], .no-reveal [data-reveal] { display: none !important; }

/* ---------- đăng nhập ----------
   Theo DESIGN.md của Linear (getdesign.md, slug linear.app): canvas #010102, bậc nền surface-1..4,
   viền hairline, một màu nhấn duy nhất #5e6ad2. Font Linear là font riêng nên dùng SF Pro / system. */
.login-page {
  --l-primary: #5e6ad2; --l-primary-hover: #828fff; --l-primary-focus: #5e69d1;
  --l-ink: #f7f8f8; --l-ink-muted: #d0d6e0; --l-ink-subtle: #8a8f98; --l-ink-tertiary: #62666d;
  --l-canvas: #010102; --l-s1: #0f1011; --l-s2: #141516; --l-s3: #18191a;
  --l-hair: #23252a; --l-hair-strong: #34343a; --l-hair-3: #3e3e44;
  --l-display: "SF Pro Display", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --l-text: "SF Pro Text", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --l-mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
  background: var(--l-canvas); color: var(--l-ink);
  font: 400 16px/1.5 var(--l-text); letter-spacing: -0.05px;
  min-height: 100vh;
}
.lg-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); min-height: 100vh; }

/* cột form */
.lg-form-col { display: flex; flex-direction: column; padding: 32px 48px; }
.lg-brand { display: flex; align-items: center; gap: 12px; font: 500 14px/1.2 var(--l-text); color: var(--l-ink); }
.lg-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--l-primary); color: #fff;
  display: grid; place-items: center; font: 600 14px Georgia, serif;
}
.lg-form-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 360px; margin: 0 auto; padding: 48px 0; }
.lg-eyebrow { margin: 0 0 12px; font: 500 13px/1.3 var(--l-text); letter-spacing: 0.4px; color: var(--l-ink-subtle); }
.lg-title { margin: 0 0 8px; font: 600 28px/1.2 var(--l-display); letter-spacing: -0.6px; color: var(--l-ink); }
.lg-lead { margin: 0 0 32px; font: 400 14px/1.5 var(--l-text); color: var(--l-ink-subtle); }

.lg-form { display: flex; flex-direction: column; }
.lg-label { font: 500 13px/1.3 var(--l-text); color: var(--l-ink-muted); margin-bottom: 8px; }
.lg-field { position: relative; }
.lg-field input {
  width: 100%; height: 44px; padding: 8px 44px 8px 12px;
  background: var(--l-s1); color: var(--l-ink); border: 1px solid var(--l-hair); border-radius: 8px;
  font: 400 16px/1.5 var(--l-text); letter-spacing: -0.05px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.lg-field input:hover { border-color: var(--l-hair-strong); }
.lg-field input:focus { border-color: var(--l-hair-strong); box-shadow: 0 0 0 2px rgba(94, 105, 209, .5); }
.lg-field input[aria-invalid="true"] { border-color: var(--l-hair-3); }
.lg-reveal {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 6px; background: none; color: var(--l-ink-tertiary);
}
.lg-reveal svg { width: 18px; height: 18px; }
.lg-reveal:hover, .lg-reveal[aria-pressed="true"] { color: var(--l-ink-muted); background: var(--l-s3); }
.lg-reveal:focus-visible { outline: 2px solid rgba(94, 105, 209, .5); outline-offset: 0; }
.lg-hint { margin: 8px 0 0; font: 400 12px/1.4 var(--l-text); color: var(--l-ink-subtle); }

.lg-btn {
  margin-top: 16px; height: 44px; padding: 8px 14px; border: 0; border-radius: 8px;
  background: var(--l-primary); color: #fff; font: 500 14px/1.2 var(--l-text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color .15s;
}
.lg-btn:hover { background: var(--l-primary-hover); }
.lg-btn:active { background: var(--l-primary-focus); }
.lg-btn:focus-visible { outline: 2px solid rgba(94, 105, 209, .5); outline-offset: 2px; }
.lg-btn:disabled { cursor: default; background: var(--l-primary-focus); color: rgba(255, 255, 255, .7); }
.lg-btn.busy::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: lg-spin .7s linear infinite;
}
@keyframes lg-spin { to { transform: rotate(360deg); } }
.lg-err { min-height: 20px; margin: 12px 0 0; font: 400 13px/1.5 var(--l-text); color: var(--l-ink-muted); }
.lg-err:not(:empty)::before { content: "●"; color: #e5484d; font-size: 9px; vertical-align: 2px; margin-right: 8px; }
.lg-foot { margin: 0; font: 400 12px/1.4 var(--l-text); color: var(--l-ink-tertiary); text-align: center; }

/* cột specimen: vai trò "product screenshot" của Linear */
.lg-specimen { padding: 24px 24px 24px 0; display: flex; }
.lg-panel {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: var(--l-s1); border: 1px solid var(--l-hair); border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
.lg-panel-bar { display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px; border-bottom: 1px solid var(--l-hair); }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--l-s3); border: 1px solid var(--l-hair-strong); }
.lg-panel-title { margin-left: 8px; font: 400 13px/1.5 var(--l-mono); color: var(--l-ink-tertiary); }
.lg-hero-glyph {
  flex: 1; display: grid; place-items: center; min-height: 220px;
  font: 400 clamp(140px, 17vw, 260px)/1 Georgia, "Times New Roman", serif; letter-spacing: -0.04em; color: var(--l-ink);
}
.lg-rows { border-top: 1px solid var(--l-hair); }
.lg-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--l-hair);
}
.lg-sample { color: var(--l-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.s-serif { font: 400 22px/1.25 Georgia, serif; }
.s-sans { font: 600 20px/1.25 var(--l-display); letter-spacing: -0.4px; }
.s-mono { font: 400 18px/1.3 var(--l-mono); color: var(--l-ink-muted); }
.s-italic { font: italic 400 22px/1.25 Georgia, serif; }
.lg-meta { flex: none; font: 400 12px/1.4 var(--l-text); color: var(--l-ink-subtle); }
.lg-tags { display: flex; gap: 8px; padding: 16px 24px; }
.lg-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 9999px;
  background: var(--l-s2); border: 1px solid var(--l-hair); font: 400 12px/1.4 var(--l-text); color: var(--l-ink-muted);
}
.lg-badge i { width: 6px; height: 6px; border-radius: 50%; background: #27a644; }

@media (max-width: 1024px) {
  .lg-shell { grid-template-columns: 1fr; }
  .lg-specimen { display: none; }
}
@media (max-width: 480px) {
  .lg-form-col { padding: 24px 16px; }
  .lg-form-wrap { padding: 32px 0; }
}
@media (prefers-reduced-motion: reduce) {
  .lg-btn.busy::before { animation-duration: 2s; }
}

/* ---------- xoá font ---------- */
.danger-ghost { color: var(--danger); }
.danger-ghost:hover { border-color: var(--danger); }
.icon-btn.danger-ico:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.del-list { margin: 8px 0 12px; padding-left: 18px; max-height: 160px; overflow: auto; color: var(--text); }
.confirm-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; color: var(--text); }
.copy-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 6px 0 8px; border-radius: 6px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: copy;
}
.copy-chip code { border: 0; background: none; padding: 0; font: 600 12.5px ui-monospace, Menlo, monospace; }
.copy-chip:hover { border-color: var(--text-3); }
.copy-chip .ico { width: 13px; height: 13px; color: var(--text-3); }
.copy-chip .ok-ico { display: none; color: var(--ok); }
.copy-chip.copied .ok-ico { display: inline-flex; }
.copy-chip.copied .copy-ico { display: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger:disabled:hover { border-color: var(--danger); }
.modal-card .m-body input[type="text"]:focus { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
