*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f0f0f;
  --surface: #181818;
  --surface2: #222222;
  --border: #2e2e2e;
  --accent: #e0e0e0;
  --muted: #666;
  --text: #d4d4d4;
  --highlight: #3a3a3a;
  --green: #3fb950;
  --yellow: #f0c040;
  --red: #f85149;
  --blue: #58a6ff;
  --orange: #d97706;
  --sidebar-w: 320px;
  --header-h: 60px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 10;
  position: relative;
}
.header h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-title svg {
  opacity: 0.7;
}

.header-count {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.header-spacer {
  flex: 1;
}

.nav-links {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  pointer-events: auto;
}

.nav-link {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--accent);
  background: var(--surface2);
  border-color: var(--border);
  text-decoration: none;
}
.nav-link.current {
  color: var(--accent);
  border-color: var(--border);
}

.search-wrap {
  position: relative;
  flex-shrink: 0;
}
.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

#search {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px 6px 32px;
  width: 220px;
  outline: none;
  transition: border-color 0.15s;
}
#search:focus {
  border-color: #555;
}
#search::placeholder {
  color: var(--muted);
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar-label {
  padding: 12px 16px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.1s;
  user-select: none;
  color: var(--text);
  font-size: 13px;
}
.sidebar-item:hover {
  background: var(--highlight);
}
.sidebar-item.active {
  background: var(--highlight);
  color: #fff;
}
.sidebar-item.hidden {
  display: none;
}

.sidebar-count {
  font-size: 10px;
  color: var(--muted);
  background: var(--border);
  padding: 1px 6px;
  border-radius: 10px;
  line-height: 1.6;
  flex-shrink: 0;
}

.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.main::-webkit-scrollbar {
  width: 6px;
}
.main::-webkit-scrollbar-track {
  background: transparent;
}
.main::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.size-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.size-ctrl label {
  white-space: nowrap;
}

.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}
.empty svg {
  display: block;
  margin: 0 auto 12px;
  opacity: 0.3;
}
.empty p {
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.sidebar-item-r {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.sidebar-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.15s;
}
.sidebar-item:hover .sidebar-actions {
  opacity: 1;
}

.sidebar-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.sidebar-action-btn:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.07);
}

.sidebar-del-btn:hover {
  color: #e05555 !important;
}

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  position: sticky;
  top: -24px;
  z-index: 100;
  background: var(--bg);
  padding: 24px 0 12px;
  margin-top: -24px;
}

.preview-input {
  flex: 1;
  min-width: 200px;
  max-width: 480px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.preview-input:focus {
  border-color: #555;
}

#fontSize {
  width: 100px;
  accent-color: #888;
  cursor: pointer;
}

#fontSizeVal {
  font-size: 11px;
  color: var(--muted);
  min-width: 36px;
}

.view-toggle {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.view-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 8px;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}
.view-btn:hover, .view-btn.active {
  background: var(--highlight);
  color: var(--accent);
}

.sort-group {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
}

.sort-label {
  font-size: 10px;
  color: var(--muted);
  padding: 0 5px 0 3px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sort-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.sort-btn.active {
  background: var(--highlight);
  color: var(--accent);
  font-weight: 600;
}
.sort-btn:hover:not(.active) {
  color: var(--accent);
}

.favs-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 11px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.favs-btn:hover {
  border-color: #f0c040;
  color: #f0c040;
}
.favs-btn.active {
  background: #f0c040;
  color: #111;
  border-color: #f0c040;
  font-weight: 700;
}

.family-section {
  margin-bottom: 40px;
  scroll-margin-top: 24px;
}
.family-section.hidden {
  display: none;
}
.family-section:hover .family-actions {
  opacity: 1;
}

.family-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 0;
}

.family-count {
  font-weight: 400;
  margin-left: 8px;
  font-size: 10px;
}

.family-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s;
}

.family-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
  transition: color 0.12s, background 0.12s;
}
.family-action-btn:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
}

.family-del-btn:hover {
  color: #e05555 !important;
}

.faces-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.faces-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.faces-list .face-card {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 14px;
  border-radius: 6px;
}
.faces-list .face-meta {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 200px;
  flex-shrink: 0;
  margin-bottom: 0;
}
.faces-list .face-preview {
  flex: 1;
}

.face-card {
  position: relative;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.face-card:hover {
  border-color: #444;
  background: #252525;
}
.face-card.starred {
  border-color: #3a3015;
}
.face-card.starred .star-btn {
  color: #f0c040;
}
.face-card.cls-hidden {
  display: none !important;
}
.face-card.has-notes .face-notes {
  display: flex;
}
.face-card:hover .note-edit-btn {
  display: block;
  opacity: 1;
}
.face-card:hover .face-del-btn {
  display: block;
  opacity: 1;
}
.face-card:hover .face-rename-btn {
  display: block;
  opacity: 1;
}

.face-meta {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.face-name {
  font-size: 11px;
  color: #888;
}

.face-formats {
  display: flex;
  gap: 4px;
}

.fmt-badge {
  font-size: 9px;
  background: var(--border);
  color: var(--muted);
  padding: 1px 5px;
  border-radius: 3px;
}

.face-meta-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.face-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
  color: var(--accent);
}

.class-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s, filter 0.15s;
}
.class-badge:hover {
  filter: brightness(1.35);
}

.class-serif {
  background: #1e1528;
  color: #c792ea;
  border: 1px solid #3a2a50;
}

.class-sans {
  background: #0f1f2d;
  color: #58a6ff;
  border: 1px solid #1c3a55;
}

.class-script {
  background: #1a1f0a;
  color: #8cc63f;
  border: 1px solid #2e3f12;
}

.class-display {
  background: #1f1508;
  color: #e09040;
  border: 1px solid #3f2a10;
}

.class-mono {
  background: #0f1f1a;
  color: #3fb9a0;
  border: 1px solid #1a3830;
}

.class-icon {
  background: #1f1010;
  color: #e05050;
  border: 1px solid #3f1818;
}

.class-unknown {
  background: var(--border);
  color: #555;
  border: 1px solid #333;
}

.classify-btn {
  background: rgba(180, 40, 40, 0.15);
  color: #e06060;
  border: 1px solid #5a2020;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.classify-btn:hover {
  background: rgba(200, 50, 50, 0.28);
  border-color: #8a3030;
  color: #f07070;
}

.classify-modal {
  max-width: 380px;
}
.classify-modal .classify-stem-label {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 16px;
  word-break: break-all;
}
.classify-modal .classify-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.classify-modal .classify-opt {
  padding: 11px 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  transition: opacity 0.15s, transform 0.1s, filter 0.15s;
}
.classify-modal .classify-opt:hover {
  opacity: 0.8;
  transform: translateY(-1px);
}
.classify-modal .classify-opt:active {
  transform: translateY(0);
}
.classify-modal .classify-opt:disabled {
  opacity: 0.4;
  cursor: wait;
}
.classify-modal .classify-opt.is-saving {
  filter: brightness(1.4);
}

.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 0 0 6px;
  color: var(--border);
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}
.star-btn:hover {
  color: #f0c040;
  transform: scale(1.25);
}

.face-notes {
  margin-top: 8px;
  font-size: 10px;
  color: var(--muted);
  display: none;
  flex-direction: column;
  gap: 4px;
}

.note-project-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #12283f;
  color: #6ab0f5;
  border-radius: 3px;
  padding: 1px 4px 1px 6px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  align-self: flex-start;
}

.note-body {
  color: #888;
  font-size: 10px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.del-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 9px;
  line-height: 1;
  padding: 0 1px;
  color: inherit;
  opacity: 0.45;
  flex-shrink: 0;
}
.del-btn:hover {
  opacity: 1;
  color: #ff6b6b;
}

.note-edit-btn {
  display: none;
  position: absolute;
  bottom: 7px;
  right: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  color: var(--muted);
  padding: 1px 6px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.note-edit-btn:hover {
  color: var(--accent);
  border-color: #555;
}

.face-del-btn {
  display: none;
  position: absolute;
  bottom: 7px;
  left: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  color: var(--muted);
  padding: 1px 6px;
  opacity: 0;
  transition: opacity 0.15s, color 0.12s, border-color 0.12s;
  z-index: 2;
}
.face-del-btn:hover {
  color: #e05555;
  border-color: #e05555;
  background: rgba(200, 50, 50, 0.12);
}

.face-rename-btn {
  display: none;
  position: absolute;
  bottom: 7px;
  left: 78px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  color: var(--muted);
  padding: 1px 6px;
  opacity: 0;
  transition: opacity 0.15s, color 0.12s, border-color 0.12s;
  z-index: 2;
}
.face-rename-btn:hover {
  color: var(--accent);
  border-color: #555;
}

.note-popup {
  position: fixed;
  z-index: 300;
  background: #1c1c1c;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  padding: 14px 16px;
  width: 280px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65);
}
.note-popup h4 {
  font-size: 10px;
  color: #666;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.note-popup label {
  display: block;
  font-size: 10px;
  color: #777;
  margin-bottom: 3px;
}
.note-popup input,
.note-popup textarea {
  width: 100%;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  color: #d4d4d4;
  font-size: 12px;
  padding: 6px 8px;
  box-sizing: border-box;
  font-family: inherit;
  margin-bottom: 10px;
  outline: none;
  resize: vertical;
}
.note-popup input:focus,
.note-popup textarea:focus {
  border-color: #555;
}
.note-popup textarea {
  min-height: 64px;
}
.note-popup .popup-row {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}
.note-popup .popup-row .popup-del {
  margin-right: auto;
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}
.note-popup .popup-row .popup-del:hover {
  color: #ff6b6b;
}
.note-popup .popup-row button {
  background: none;
  border: 1px solid #444;
  color: #bbb;
  border-radius: 5px;
  padding: 4px 11px;
  font-size: 11px;
  cursor: pointer;
}
.note-popup .popup-row button:hover {
  border-color: #888;
}
.note-popup .popup-row button.primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 600;
}
.note-popup .popup-row button.primary:hover {
  background: #fff;
}

.upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.upload-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.upload-overlay.open .upload-modal {
  transform: translateY(0) scale(1);
}

.upload-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s;
  overflow: hidden;
}

.upload-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.upload-modal-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
}

.upload-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}
.upload-modal-close:hover {
  color: var(--accent);
  background: var(--highlight);
}

.upload-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.upload-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 10px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.upload-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.upload-tab:hover:not(.active) {
  color: #aaa;
}

.upload-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.upload-field label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 5px;
}
.upload-field input[type=text],
.upload-field input[type=url] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.upload-field input[type=text]:focus,
.upload-field input[type=url]:focus {
  border-color: #555;
}
.upload-field input[type=text].error,
.upload-field input[type=url].error {
  border-color: #f85149;
}

.upload-error {
  font-size: 11px;
  color: #f85149;
  margin-top: 4px;
  display: none;
}
.upload-error.show {
  display: block;
}

.upload-warn {
  font-size: 11px;
  color: #f0c040;
  margin-top: 4px;
  display: none;
}
.upload-warn.show {
  display: block;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: #555;
  background: rgba(255, 255, 255, 0.03);
}
.drop-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-zone-icon {
  font-size: 24px;
  margin-bottom: 6px;
  opacity: 0.5;
}

.drop-zone-label {
  font-size: 12px;
  color: var(--muted);
}
.drop-zone-label strong {
  color: var(--text);
}

.drop-zone-files {
  margin-top: 8px;
  font-size: 11px;
  color: #58a6ff;
  max-height: 64px;
  overflow-y: auto;
  text-align: left;
}

.upload-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.upload-status {
  flex: 1;
  font-size: 11px;
  color: var(--muted);
}
.upload-status.ok {
  color: #3fb950;
}
.upload-status.err {
  color: #f85149;
}

.upload-btn {
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 6px;
  padding: 7px 18px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.upload-btn:hover {
  background: #fff;
}
.upload-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.upload-btn.danger {
  background: #c0392b;
  color: #fff;
}
.upload-btn.danger:hover {
  background: #e74c3c;
}

.upload-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  display: none;
}
.upload-progress.show {
  display: block;
}

.upload-progress-bar {
  height: 100%;
  background: #58a6ff;
  width: 0;
  transition: width 0.3s;
}

.dl-found-note {
  font-size: 11px;
  color: var(--muted);
  padding: 2px 0 0;
}
.dl-found-note.ok {
  color: #3fb950;
}
.dl-found-note.err {
  color: #f85149;
}

.dl-file-list {
  margin-top: 6px;
  max-height: 80px;
  overflow-y: auto;
  font-size: 10px;
  color: #58a6ff;
  line-height: 1.6;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-font-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-family-name {
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
  font-weight: 400;
}

.modal-size-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
.modal-size-ctrl label {
  white-space: nowrap;
}

#modalFontSize {
  width: 110px;
  accent-color: #888;
  cursor: pointer;
}

#modalFontSizeVal {
  font-size: 11px;
  color: var(--muted);
  min-width: 36px;
}

.modal-align {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.align-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 7px;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}
.align-btn:hover, .align-btn.active {
  background: var(--highlight);
  color: var(--accent);
}

.modal-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.modal-nav-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
  flex-shrink: 0;
}
.modal-nav-btn:hover:not(:disabled) {
  color: var(--accent);
  background: var(--highlight);
  border-color: #555;
}
.modal-nav-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

.modal-nav-counter {
  font-size: 10px;
  color: var(--muted);
  min-width: 32px;
  text-align: center;
  letter-spacing: 0.02em;
  user-select: none;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.1s, background 0.1s;
  flex-shrink: 0;
}
.modal-close:hover {
  color: var(--accent);
  background: var(--highlight);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.modal-text {
  width: 100%;
  min-height: 300px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--accent);
  line-height: 1.5;
  resize: none;
  font-size: 32px;
  text-align: left;
}

.page-convert {
  font-size: 13px;
}
.page-convert .header {
  --header-h: 56px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-convert .nav-links {
  gap: 6px;
}

.ft-status {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}
.ft-status.ok {
  background: #12261e;
  color: var(--green);
  border: 1px solid #1f4032;
}
.ft-status.err {
  background: #2a1215;
  color: var(--red);
  border: 1px solid #4a1515;
}

.stats-bar {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
}
.stat-card .val {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}
.stat-card .lbl {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-card.pending .val {
  color: var(--yellow);
}
.stat-card.done .val {
  color: var(--green);
}
.stat-card.total .val {
  color: var(--accent);
}

.convert-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 14px;
  flex-wrap: wrap;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 6px 10px;
  width: 240px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus {
  border-color: #555;
}

.filter-group {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
}

.filter-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.filter-btn.active {
  background: var(--highlight);
  color: var(--accent);
}
.filter-btn:hover:not(.active) {
  color: var(--accent);
}

.btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover {
  color: var(--accent);
  border-color: #555;
}
.btn.primary {
  background: var(--blue);
  color: #000;
  border-color: var(--blue);
  font-weight: 600;
}
.btn.primary:hover {
  background: #79bbff;
  border-color: #79bbff;
}
.btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.sel-count {
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}

.table-wrap {
  padding: 0 24px 40px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th:first-child {
  padding-left: 6px;
  width: 32px;
}

tbody tr {
  border-bottom: 1px solid #1e1e1e;
  transition: background 0.1s;
}
tbody tr:hover {
  background: var(--surface);
}
tbody tr.hidden-row {
  display: none;
}
tbody tr.done-row {
  opacity: 0.45;
}
tbody tr.done-row:hover {
  opacity: 1;
}

td {
  padding: 8px 10px;
  vertical-align: middle;
}
td:first-child {
  padding-left: 6px;
}

.folder-badge {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stem-name {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}

.ext-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}

.ext-ttf {
  background: #1e2d3d;
  color: #58a6ff;
}

.ext-otf {
  background: #2d1e3d;
  color: #c792ea;
}

.fmt-cell {
  display: flex;
  gap: 5px;
  align-items: center;
}

.fmt-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s;
}
.fmt-pill.present {
  background: #12261e;
  color: var(--green);
  border-color: #1f4032;
  cursor: default;
}
.fmt-pill.missing {
  background: #1e1e1e;
  color: #444;
  border-color: #2e2e2e;
}
.fmt-pill.converting {
  background: #1c2233;
  color: var(--blue);
  border-color: #2a3a55;
  animation: pulse 0.8s ease-in-out infinite;
}
.fmt-pill.success {
  background: #12261e;
  color: var(--green);
  border-color: #1f4032;
}
.fmt-pill.error {
  background: #2a1215;
  color: var(--red);
  border-color: #4a1515;
  cursor: pointer;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
.action-cell {
  white-space: nowrap;
}

.row-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.row-btn:hover {
  color: var(--accent);
  border-color: #555;
}
.row-btn.go {
  border-color: #2a3a55;
  color: var(--blue);
}
.row-btn.go:hover {
  background: #1c2233;
}
.row-btn:disabled {
  opacity: 0.25;
  cursor: default;
}
.row-btn.done-indicator {
  color: var(--green);
  border-color: #1f4032;
  cursor: default;
}

.empty-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 13px;
}

.install-banner {
  margin: 20px 24px 0;
  background: #1a1208;
  border: 1px solid #3a2a10;
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 12px;
  color: #c9a227;
  line-height: 1.7;
}
.install-banner code {
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: "SF Mono", "Fira Mono", monospace;
  font-size: 11px;
  color: #e8e8e8;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 12px;
  max-width: 300px;
  z-index: 200;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.ok {
  border-color: #1f4032;
  color: var(--green);
}
.toast.err {
  border-color: #4a1515;
  color: var(--red);
}

.page-icons {
  --sidebar-w: 240px;
}
.page-icons #iconSize {
  width: 90px;
  accent-color: #888;
  cursor: pointer;
}
.page-icons #iconSizeVal {
  font-size: 11px;
  color: var(--muted);
  min-width: 30px;
}

.purge-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 5px;
  white-space: nowrap;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  margin-right: 8px;
  transition: color 0.15s, border-color 0.15s;
}
.purge-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.sidebar-cdn {
  font-size: 9px;
  color: #444;
  border: 1px solid #333;
  padding: 0 4px;
  border-radius: 3px;
  line-height: 1.8;
  flex-shrink: 0;
}

.lib-section {
  margin-bottom: 48px;
  scroll-margin-top: 24px;
}
.lib-section.hidden {
  display: none;
}

.lib-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.lib-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.lib-count {
  font-size: 10px;
  color: #555;
}

.lib-src-badge {
  font-size: 10px;
  color: #555;
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 4px;
}

.style-note {
  font-size: 10px;
  color: #444;
  font-style: italic;
}

.lib-spacer {
  flex: 1;
}

.style-tabs {
  display: flex;
  gap: 3px;
}

.style-tab {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-family: monospace;
  padding: 3px 8px;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  white-space: nowrap;
}
.style-tab:hover {
  background: var(--highlight);
  color: var(--text);
}
.style-tab.active {
  background: var(--highlight);
  color: var(--accent);
  border-color: #555;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
}

.icon-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px 6px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
  position: relative;
}
.icon-card:hover {
  border-color: #444;
  background: #282828;
}
.icon-card.hidden {
  display: none;
}
.icon-card::after {
  content: "copied!";
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%) scale(0.85);
  background: #333;
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  border: 1px solid #444;
  z-index: 10;
}
.icon-card.copied::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.icon-glyph {
  font-size: 22px;
  line-height: 1;
  color: var(--accent);
  transition: font-size 0.1s;
  flex-shrink: 0;
  min-height: 1em;
}

.icon-label {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  word-break: break-all;
  line-height: 1.3;
  max-width: 100%;
}
