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

:root {
  color-scheme: dark;
  --bg:         #111111;
  --surface:    #1a1a1a;
  --surface2:   #222222;
  --surface3:   #2a2a2a;
  --border:     #303030;
  --border2:    #3e3e3e;
  --text:       #eeebe6;
  --text-dim:   #b0aca6;
  --text-muted: #787470;
  --accent:     #c4964e;
  --accent-dim: rgba(196, 150, 78, 0.10);
  --error:      #c07878;
  --success:    #78a88e;
  --font-ui:    Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono:  Consolas, "Liberation Mono", "Courier New", monospace;
  --r:  4px;
  --t:  0.13s ease;
}

html.light {
  color-scheme: light;
  --bg:         #f8f8f7;
  --surface:    #ffffff;
  --surface2:   #efeee9;
  --surface3:   #e5e4de;
  --preview:    #eeede9;
  --text:       #111111;
  --text-dim:   #555555;
  --text-muted: #888582;
  --border:     #dddbd5;
  --border2:    #b8b6b0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
}

button, textarea, input, select { font: inherit; }
button { cursor: pointer; }

* { scrollbar-width: thin; scrollbar-color: var(--border2) var(--surface); }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.panel { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.ph {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; min-height: 36px;
  background: var(--surface2); border-bottom: 1px solid var(--border);
  flex-shrink: 0; font-size: 11px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  transition: background var(--t), color var(--t), border-color var(--t);
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface3);
  color: var(--text);
}

.btn-hi {
  background: var(--accent-dim);
  border-color: rgba(196,150,78,.35);
  color: var(--accent);
}

/* ── App info sidebar ───────────────────────────────────────────────────── */

.app-info {
  display: flex;
  flex-direction: column;
  padding: 24px 22px;
  gap: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.app-info-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  transition: color var(--t);
}

.app-info-back:hover { color: var(--text); }

.app-info-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.app-info-mark {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--accent);
  font-weight: 700;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
}

.app-info-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.65;
}

.app-info-sep {
  height: 1px;
  background: var(--border);
}

.app-info-hints {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-info-hints li {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Directory page (index.html) ────────────────────────────────────────── */

.dir-body {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  height: 100%;
}

.dir-info {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 22px;
  overflow-y: auto;
}

.dir-info h1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.dir-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.dir-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.65;
  margin-bottom: 18px;
}

.dir-lines {
  list-style: none;
  margin-bottom: 20px;
}

.dir-lines li {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.9;
}

.dir-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.dir-filters {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dir-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--text-muted);
  padding: 5px 0;
  text-align: left;
  transition: color var(--t);
}

.dir-filter:hover {
  color: var(--text);
}

.dir-filter.active {
  color: var(--text);
  font-weight: 600;
}

.dir-filter-count {
  font-size: 12px;
}

.dir-footer {
  margin-top: auto;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.9;
}

.dir-footer a {
  color: inherit;
  text-decoration: none;
}

.dir-footer a:hover {
  color: var(--text);
}

.dir-main {
  padding: 28px 32px;
  overflow-y: auto;
  height: 100vh;
}

.dir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.dir-card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.dir-card[hidden] {
  display: none;
}

.dir-card-preview {
  background: var(--preview);
  aspect-ratio: 4 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 2px;
  transition: background var(--t);
}

.dir-card:hover .dir-card-preview {
  background: #e4e3de;
}

.dir-card-icon {
  font-size: 38px;
  line-height: 1;
}

.dir-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  max-width: 72%;
  line-height: 1.5;
}

.dir-card-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 10px;
}

.dir-card-name {
  font-size: 13px;
  color: var(--text);
}

.dir-card-open {
  font-size: 12px;
  color: var(--text-muted);
  transition: color var(--t);
}

.dir-card:hover .dir-card-open {
  color: var(--text);
}

.dir-empty {
  display: none;
  font-size: 13px;
  color: var(--text-muted);
  padding: 40px 0;
}

@media (max-width: 680px) {
  .dir-body {
    grid-template-columns: 1fr;
    height: auto;
  }

  .dir-info {
    position: static;
    height: auto;
    border-bottom: 1px solid var(--border);
    padding: 20px 18px;
  }

  .dir-lines,
  .dir-cta,
  .dir-filters,
  .dir-footer {
    display: none;
  }

  .dir-desc {
    margin-bottom: 0;
  }

  .dir-main {
    height: auto;
    padding: 20px 18px;
  }

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