:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --surface: #111214;
  --surface-2: #16171a;
  --surface-3: #1b1d21;
  --border: #24262b;
  --border-strong: #32353c;
  --text: #f5f6f7;
  --muted: #90959f;
  --muted-2: #666b74;
  --accent: #f5f5f5;
  --accent-text: #0a0a0b;
  --danger: #ff6b6b;
  --danger-bg: rgba(255, 107, 107, 0.08);
  --success: #85d69b;
  --success-bg: rgba(133, 214, 155, 0.08);
  --warning: #e9c46a;
  --warning-bg: rgba(233, 196, 106, 0.08);
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 18px 60px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
code {
  padding: .15rem .35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: #d7d9dd;
}

.shell {
  width: min(1060px, calc(100% - 32px));
  margin-inline: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(36, 38, 43, .82);
  background: rgba(10, 10, 11, .88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 900;
}

.nav-actions { display: flex; align-items: center; gap: 6px; }
.nav-link {
  border: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-button { appearance: none; }
.inline-form { display: inline; margin: 0; }

.page { padding: 54px 0 80px; }
.narrow-page { width: min(850px, calc(100% - 32px)); }

.hero { padding: 18px 0 36px; }
.compact-hero { max-width: 760px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 12px;
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1.02;
  letter-spacing: -.05em;
}
h2 { letter-spacing: -.025em; }
.hero-copy, .detail-description, .auth-copy, .form-intro {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}
.hero-copy { max-width: 650px; margin-bottom: 0; }
.muted { color: var(--muted); }

.notice, .flash, .form-error {
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  font-size: 14px;
}
.notice.warning { color: var(--warning); border-color: rgba(233,196,106,.28); background: var(--warning-bg); }
.flash-success { color: var(--success); border-color: rgba(133,214,155,.28); background: var(--success-bg); }
.flash-error, .form-error { color: #ffaaaa; border-color: rgba(255,107,107,.28); background: var(--danger-bg); }

.search-wrap { margin-bottom: 18px; }
.search-input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  padding: 0 15px;
  transition: border-color .15s ease, background .15s ease;
}
.search-input:focus { border-color: var(--border-strong); background: var(--surface-2); }
.search-input::placeholder { color: var(--muted-2); }

.app-grid, .admin-list, .version-list { display: grid; gap: 12px; }
.app-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.app-card:hover { border-color: var(--border-strong); }
.app-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 15px;
}
.app-icon {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 15px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.06);
  background: var(--surface-3);
}
.app-icon-large { width: 88px; height: 88px; flex-basis: 88px; border-radius: 20px; }
.app-icon-placeholder {
  display: grid;
  place-items: center;
  color: #b7bbc2;
  font-weight: 800;
  font-size: 24px;
  background: linear-gradient(145deg, #1f2227, #15171a);
}
.app-info { min-width: 0; }
.app-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-title-row h2 { margin: 0; font-size: 18px; }
.version-badge, .status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
}
.status-pill { color: var(--success); border-color: rgba(133,214,155,.22); background: var(--success-bg); }
.bundle-id {
  margin: 4px 0 0;
  color: var(--muted-2);
  font-size: 12px;
  word-break: break-all;
}
.app-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-actions, .row-actions, .form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, transform .08s ease, opacity .14s ease;
}
.button:active { transform: scale(.98); }
.button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.button.primary:hover { background: #dddddf; border-color: #dddddf; }
.button.secondary { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.button.secondary:hover { border-color: var(--border-strong); background: #22252a; }
.button.ghost { color: var(--muted); border-color: var(--border); background: transparent; }
.button.ghost:hover { color: var(--text); background: var(--surface-2); }
.button.danger { color: #ff9b9b; background: var(--danger-bg); border-color: rgba(255,107,107,.25); }
.button.danger:hover { background: rgba(255,107,107,.13); }
.button.disabled { opacity: .45; cursor: default; }
.button.small { min-height: 36px; padding: 0 11px; font-size: 12px; }
.button.full { width: 100%; }
.button[disabled] { opacity: .55; cursor: wait; }

.empty-state {
  padding: 54px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
}
.empty-state h2 { margin: 12px 0 5px; color: var(--text); }
.empty-state p { margin-bottom: 0; }
.empty-icon {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 24px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 14px;
}
.back-link:hover { color: var(--text); }
.app-detail-head { display: flex; align-items: center; gap: 20px; margin-bottom: 34px; }
.app-detail-head h1 { margin: 0; font-size: clamp(32px, 5vw, 48px); }
.detail-description { margin: 12px 0 0; }
.section-block { margin-top: 32px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.section-heading h2 { margin: 0; }
.version-row {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.version-main { min-width: 0; }
.version-name { display: flex; align-items: center; gap: 8px; }
.version-meta { margin-top: 4px; color: var(--muted-2); font-size: 12px; }
.hash-line {
  max-width: 520px;
  margin-top: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #555a64;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.admin-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.admin-heading h1 { margin: 0 0 5px; font-size: clamp(32px, 5vw, 48px); }
.admin-heading .muted { margin: 0; }
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.admin-app-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.admin-icon { width: 54px; height: 54px; flex-basis: 54px; border-radius: 13px; font-size: 20px; }
.admin-app-name { font-size: 16px; }
.versions-heading { align-items: flex-end; }
.wrap-actions { flex-wrap: wrap; justify-content: flex-end; }
.admin-version-list { margin-top: 10px; }

.auth-page {
  min-height: calc(100vh - 130px);
  display: grid;
  place-items: center;
  padding: 48px 0 70px;
}
.auth-card, .form-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card h1, .form-card h1 { margin-bottom: 10px; font-size: 34px; }
.auth-copy { margin-bottom: 24px; }
.error-card { text-align: left; }

.form-page { width: min(850px, calc(100% - 32px)); }
.wide-form { width: 100%; }
.form-intro { max-width: 700px; margin-bottom: 24px; }
.form-stack { display: grid; gap: 18px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 8px; }
.field > span { color: #c9ccd1; font-size: 13px; font-weight: 650; }
.field small { color: var(--muted-2); font-weight: 500; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: 0;
  background: #0e0f11;
  color: var(--text);
  padding: 11px 12px;
}
.field input { min-height: 45px; }
.field textarea { resize: vertical; min-height: 110px; }
.field input:focus, .field textarea:focus { border-color: #41454e; }
.field input::placeholder, .field textarea::placeholder { color: #565b64; }

.upload-zone {
  position: relative;
  display: grid;
  gap: 5px;
  padding: 28px;
  border: 1px dashed #3a3d44;
  border-radius: 14px;
  background: #0e0f11;
  cursor: pointer;
  text-align: center;
}
.upload-zone:hover { border-color: #555a64; }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-title { font-weight: 750; }
.upload-subtitle, .file-name { color: var(--muted); font-size: 12px; }
.file-name { margin-top: 5px; color: #c1c4ca; }
.form-actions { justify-content: flex-end; margin-top: 4px; }

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 34px;
  padding: 18px;
  border: 1px solid rgba(255,107,107,.2);
  border-radius: 14px;
  background: var(--danger-bg);
}
.danger-zone h2 { margin: 0 0 3px; font-size: 16px; }
.danger-zone p { margin: 0; color: var(--muted); font-size: 13px; }

.footer {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #50545c;
  font-size: 12px;
}
.footer-dot { color: #34373d; }

[data-app-card][hidden] { display: none; }

@media (max-width: 760px) {
  .shell, .narrow-page, .form-page { width: min(100% - 24px, 1060px); }
  .page { padding-top: 38px; }
  .topbar-inner { min-height: 58px; }
  .brand span:last-child { display: none; }
  .app-card { align-items: flex-start; flex-wrap: wrap; }
  .app-card-main { width: 100%; }
  .card-actions { width: 100%; }
  .card-actions .button { flex: 1; }
  .admin-heading, .versions-heading { align-items: flex-start; flex-direction: column; }
  .admin-row, .version-row { align-items: flex-start; flex-direction: column; }
  .admin-row .row-actions, .version-row .row-actions { width: 100%; justify-content: flex-start; }
  .form-grid.two { grid-template-columns: 1fr; }
  .danger-zone { align-items: flex-start; flex-direction: column; }
  .app-detail-head { align-items: flex-start; }
}

@media (max-width: 480px) {
  h1 { font-size: 38px; }
  .app-icon { width: 56px; height: 56px; flex-basis: 56px; border-radius: 13px; }
  .app-icon-large { width: 74px; height: 74px; flex-basis: 74px; border-radius: 17px; }
  .auth-card, .form-card { padding: 22px; border-radius: 16px; }
  .row-actions { flex-wrap: wrap; }
  .row-actions .button, .row-actions .inline-form { flex: 1; }
  .row-actions .inline-form .button { width: 100%; }
}
