:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-2: #3a6fd8;
  --ok: #2faf6a;
  --off: #6b7280;
  --danger: #e0556b;
  --radius: 12px;
}

/* Light theme: applied when <html data-theme="light">. */
:root[data-theme="light"] {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #d8dde7;
  --text: #1b1f27;
  --muted: #5b6474;
  --accent: #2f6fe0;
  --accent-2: #2459bd;
  --ok: #1f9d57;
  --off: #7b8493;
  --danger: #d33a52;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.inline { display: inline; margin: 0; }
.linklike { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* Theme toggle button (sun/moon) */
.theme-toggle {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--muted);
  cursor: pointer; transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
/* Show the sun in dark mode (click to brighten), the moon in light mode. */
.theme-toggle .icon-sun, .theme-toggle .icon-moon { display: none; }
:root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }

/* Hero */
.hero h1 { margin: 0 0 6px; font-size: 1.9rem; }
.hero p { color: var(--muted); margin: 0 0 22px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 26px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted); background: var(--surface); font-size: .9rem;
}
.tab.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.tab:hover { text-decoration: none; }
.filters input[type="search"] {
  flex: 1; min-width: 180px; padding: 9px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}

/* Grid of cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  display: flex; gap: 14px; padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
  transition: border-color .15s, transform .15s;
  flex: 1; align-items: flex-start;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.card-icon {
  flex: 0 0 52px; height: 52px; border-radius: 12px; background: var(--surface-2);
  display: grid; place-items: center; font-size: 1.4rem; font-weight: 700; color: var(--accent); overflow: hidden;
}
.card-icon img { width: 100%; height: 100%; object-fit: cover; }
.card-icon.big { flex-basis: 72px; height: 72px; font-size: 2rem; }
.card-body h3 { margin: 0 0 4px; font-size: 1.05rem; }
.card-body p { margin: 0 0 10px; color: var(--muted); font-size: .9rem; }

/* Badges */
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: .72rem; padding: 3px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.ver { color: var(--text); }
.badge.type-web { color: #7cc6ff; }
.badge.type-desktop { color: #b69bff; }
.badge.type-mobile { color: #79e0b4; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.off { color: var(--off); }

.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* Detail */
.back { display: inline-block; margin-bottom: 16px; color: var(--muted); }
.detail-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 22px; }
.detail-head h1 { margin: 0 0 6px; }
.summary { color: var(--muted); margin: 0 0 10px; }
.detail section { margin-top: 26px; }
.detail h2 { font-size: 1.1rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.desc { white-space: pre-wrap; }
.notes { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; white-space: pre-wrap; font-family: inherit; }
.api-hint { margin-top: 12px; color: var(--muted); }
.api-hint code { background: var(--surface-2); padding: 4px 8px; border-radius: 6px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font-size: .92rem;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }

/* Auth */
.auth-box { max-width: 360px; margin: 40px auto; background: var(--surface); padding: 28px; border-radius: var(--radius); border: 1px solid var(--border); }
.auth-box h1 { margin: 0 0 18px; font-size: 1.3rem; }

/* Forms */
label { display: block; margin-bottom: 14px; font-size: .9rem; color: var(--muted); }
label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit;
}
label.checkbox input { width: auto; margin: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 18px; padding: 16px 18px; }
legend { color: var(--text); font-weight: 600; padding: 0 6px; }
.app-form { max-width: 640px; }
.form-actions { display: flex; gap: 10px; }
.error { color: var(--danger); background: rgba(224,85,107,.1); padding: 10px 14px; border-radius: 8px; }
.error.small { font-size: .82rem; padding: 6px 10px; margin-top: 8px; }
.field-hint { color: var(--muted); font-size: .82rem; margin: -8px 0 14px; }
.scan-info {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 14px; font-size: .88rem;
}

/* Admin table */
.admin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.admin-head-actions { display: flex; align-items: center; gap: 10px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.muted { color: var(--muted); font-size: .82rem; margin-left: 6px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Favorites */
.card-wrap { position: relative; display: flex; flex-direction: column; }
.fav-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 30px; height: 30px; padding: 0; line-height: 1;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--muted);
  font-size: 1rem; cursor: pointer;
  transition: color .15s, border-color .15s, transform .1s;
}
.fav-btn:hover { color: #ffd166; border-color: #ffd166; }
.fav-btn:active { transform: scale(.9); }
.fav-btn.is-fav { color: #ffd166; border-color: #ffd166; }
.card-wrap .card { padding-right: 44px; }

.fav-section { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.fav-section h2 {
  font-size: 1.05rem; margin: 0 0 12px; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.fav-section h2::before { content: "\2605"; color: #ffd166; }

/* Footer */
.footer { display: flex; justify-content: space-between; max-width: 1080px; margin: 0 auto; padding: 20px 24px; color: var(--muted); border-top: 1px solid var(--border); font-size: .85rem; }

/* Light-theme contrast tweaks: the dark-theme accents are too pale on white. */
:root[data-theme="light"] .badge.type-web { color: #1666b0; }
:root[data-theme="light"] .badge.type-desktop { color: #6a3fd0; }
:root[data-theme="light"] .badge.type-mobile { color: #128a5c; }
:root[data-theme="light"] .fav-btn:hover,
:root[data-theme="light"] .fav-btn.is-fav { color: #d99b00; border-color: #d99b00; }
:root[data-theme="light"] .fav-section h2::before { color: #d99b00; }
