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

/* ---------- Tokens ----------
   Palette is drawn directly from the brand hex mark (favicon.png): the
   isometric mark's two lit faces — a bright periwinkle and a deeper
   blue-violet — become the dark- and light-mode accents respectively,
   so the icon and the UI are visibly the same material. */

:root {
  --font-display: "Space Grotesk", "Inter", -apple-system, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-secondary: #ffffff;
  --fill: rgba(0, 0, 0, 0.04);
  --fill-strong: rgba(0, 0, 0, 0.06);
  --text: #1d1d1f;
  --text2: #6e6e73;
  --text3: #86868b;
  --accent: #3d4ed0;
  --accent-hover: #3344c2;
  --accent-active: #2c3aa8;
  --accent-soft: rgba(61, 78, 208, 0.1);
  --danger: #ff3b30;
  --danger-bg: rgba(255, 59, 48, 0.1);
  --success: #34c759;
  --success-bg: rgba(52, 199, 89, 0.12);
  --separator: rgba(0, 0, 0, 0.08);
  --separator-strong: rgba(0, 0, 0, 0.12);
  --card: #ffffff;
  --nav-bg: rgba(255, 255, 255, 0.75);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 12px rgba(0, 0, 0, 0.04);
  --shadow-elevated: 0 8px 30px rgba(0, 0, 0, 0.08);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --focus-ring: 0 0 0 4px var(--accent-soft);
}

html[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --bg-secondary: #131314;
  --fill: rgba(255, 255, 255, 0.06);
  --fill-strong: rgba(255, 255, 255, 0.1);
  --text: #f5f5f7;
  --text2: #98989d;
  --text3: #6e6e73;
  --accent: #5170ff;
  --accent-hover: #6c89ff;
  --accent-active: #3d4ed0;
  --accent-soft: rgba(81, 112, 255, 0.16);
  --danger: #ff453a;
  --danger-bg: rgba(255, 69, 58, 0.15);
  --success: #30d158;
  --success-bg: rgba(48, 209, 88, 0.15);
  --separator: rgba(255, 255, 255, 0.1);
  --separator-strong: rgba(255, 255, 255, 0.16);
  --card: #1c1c1e;
  --nav-bg: rgba(28, 28, 30, 0.7);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow-elevated: 0 8px 30px rgba(0, 0, 0, 0.5);
}

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}
html[data-theme="dark"] { color-scheme: dark; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3 {
  font-family: var(--font-display);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s ease;
}
a:hover { opacity: 0.8; }

button {
  cursor: pointer;
  font-family: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.mono {
  font-family: var(--font-mono);
}

/* ---------- Layout ---------- */

.container { max-width: 920px; margin: 0 auto; padding: 0 20px; }

.page-header {
  padding: 44px 0 28px;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
.eyebrow-mark { font-size: 0.95em; }
.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 4vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.page-subtitle {
  color: var(--text2);
  font-size: 1.02rem;
}

/* ---------- Nav ---------- */

.nav {
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.brand-mark { color: var(--accent); font-size: 1.25rem; line-height: 1; }
.nav-actions { display: flex; gap: 6px; align-items: center; }
.nav-username { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text2); }

.theme-toggle {
  padding: 0;
  width: 40px;
  height: 40px;
  background: var(--fill);
  border: 1px solid var(--separator);
  color: var(--text);
  margin-right: 4px;
}
.theme-toggle:hover { background: var(--fill-strong); }
.theme-toggle svg { display: block; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  border: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-active); }

.btn-secondary { background: var(--fill); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--fill-strong); }

.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover:not(:disabled) { background: var(--fill); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.88; }

.btn-sm { padding: 7px 14px; font-size: 0.82rem; border-radius: 8px; }

/* ---------- Forms ---------- */

label.field-label {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text2);
  display: block;
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--separator-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text3); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
input[type="file"] {
  border: none;
  background: transparent;
  padding: 8px 0;
}

.banner {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 16px;
}
.banner-danger { background: var(--danger-bg); color: var(--danger); }
.banner-success { background: var(--success-bg); color: var(--success); }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  max-width: 420px;
  margin: 0 auto;
  padding: 64px 20px;
}

/* ---------- Grouped list ---------- */

.list-group {
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--separator);
}
.list-row:last-child { border-bottom: none; }

.list-row-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--fill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.list-row-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text2);
  font-size: 0.92rem;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin: 28px 2px 10px;
}
.section-title:first-child { margin-top: 0; }

/* ---------- Segmented control ---------- */

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--fill);
  border-radius: 10px;
  flex-wrap: wrap;
}
.segmented-item {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
  background: transparent;
  border: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  text-transform: capitalize;
}
.segmented-item:hover:not(.is-active) { color: var(--text); }
.segmented-item.is-active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(21, 18, 63, 0.16);
}
html[data-theme="dark"] .segmented-item.is-active { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }

/* ---------- Badges (status pills: public / private / pending count) ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-lock { background: var(--danger-bg); color: var(--danger); }
.badge-public { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger); color: #fff; }

/* ---------- Platform tags (build manifest style: dot + mono code) ---------- */

.ptag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--fill);
  border: 1px solid var(--separator);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text2);
  white-space: nowrap;
}
.ptag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--ptag-color, var(--text3));
}
.ptag-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1em;
  line-height: 1;
  padding: 0 0 0 2px;
  opacity: 0.6;
}
.ptag-remove:hover { opacity: 1; }

.ptag-android { --ptag-color: #2bb673; }
.ptag-ios { --ptag-color: #3a8dff; }
.ptag-windows { --ptag-color: #1aa9d6; }
.ptag-mac { --ptag-color: #8e8ea3; }
.ptag-linux { --ptag-color: #d39a00; }
.ptag-other { --ptag-color: #8786a6; }

/* ---------- Misc ---------- */

.skeleton {
  color: var(--text2);
  font-size: 0.92rem;
  padding: 24px 0;
  text-align: center;
}

.icon-preview {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--fill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  overflow: hidden;
}
.icon-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.icon-fallback { color: var(--accent); opacity: 0.7; }

/* ---------- App grid (Home) ---------- */

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

.app-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 18px;
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.app-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-elevated); border-color: var(--separator-strong); }
.app-card:active { transform: scale(0.98); }

.app-card-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--fill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  flex-shrink: 0;
  overflow: hidden;
}
.app-card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.94rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.app-card-version {
  font-family: var(--font-mono);
  color: var(--text3);
  font-size: 0.74rem;
}

.app-card-platforms {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.app-card-platforms .ptag {
  padding: 2px 7px 2px 6px;
  font-size: 0.6rem;
  gap: 4px;
}
.app-card-platforms .ptag-dot { width: 5px; height: 5px; }

/* ---------- Software detail page ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text2);
  margin-top: 24px;
}
.back-link:hover { color: var(--accent); }

.detail-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.detail-icon {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  background: var(--fill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  flex-shrink: 0;
  overflow: hidden;
}
.detail-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.detail-name {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.detail-version {
  font-family: var(--font-mono);
  color: var(--text2);
  font-size: 0.9rem;
}

.desktop-only { display: none; }
@media (min-width: 640px) {
  .desktop-only { display: inline; }
}

@media (max-width: 480px) {
  .list-row { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
