/* Zero-dependency modern design system for MMUI Download & Release Portal */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --primary-text: #ffffff;
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --tablet-accent: #0ea5e9;
  --mobile-accent: #8b5cf6;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-subtle: #1e293b;
    --border: #1f2937;
    --border-strong: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-soft: rgba(59, 130, 246, 0.16);
    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.16);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.16);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.16);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.4);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

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

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}
.brand-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Buttons & Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms, border-color 140ms, opacity 140ms, transform 80ms;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-subtle); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-subtle); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  gap: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.segmented button.active {
  background: var(--primary);
  color: var(--primary-text);
}
.segmented button.active.beta {
  background: var(--warning);
  color: #ffffff;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 26%, transparent); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 26%, transparent); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 26%, transparent); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 26%, transparent); }
.badge-muted { background: var(--surface-subtle); color: var(--text-muted); border-color: var(--border); }

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* Main layout */
.page-main {
  padding: 26px 0 56px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Hero */
.hero {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 9%, var(--surface)) 0%, var(--surface) 60%, color-mix(in srgb, var(--tablet-accent) 7%, var(--surface)) 100%);
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  box-shadow: var(--shadow-sm);
}
.hero-copy { max-width: 620px; display: flex; flex-direction: column; gap: 10px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.hero h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; line-height: 1.25; }
.hero p { margin: 0; color: var(--text-muted); font-size: 14px; }
.hero-cta {
  width: 330px;
  max-width: 100%;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.hero-cta-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.hero-cta-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-muted); }

/* Sections & Cards */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-bar {
  width: 5px;
  height: 20px;
  border-radius: 99px;
  background: var(--primary);
}
.section-bar.tablet { background: var(--tablet-accent); }
.section-bar.mobile { background: var(--mobile-accent); }
.section-title h2 { margin: 0; font-size: 18px; }
.section-title span { font-size: 12px; color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}
.card.recommended {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent);
}
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-ident { display: flex; align-items: center; gap: 12px; }
.icon-box {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text);
}
.card-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-name h3 { margin: 0; font-size: 16px; }
.card-sub { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.card-ver { text-align: right; flex-shrink: 0; }
.card-ver strong { font-family: var(--font-mono); font-size: 14px; display: block; }
.card-ver span { font-size: 12px; color: var(--text-muted); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.pill.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.notes-box {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 12px 14px;
  font-size: 12px;
}
.notes-box-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-weight: 600; }
.notes-box ul { margin: 0; padding-left: 18px; color: var(--text-muted); display: flex; flex-direction: column; gap: 3px; }

.card-actions { display: flex; gap: 8px; align-items: center; }
.card-actions .btn-primary { flex: 1; }
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Panel & Table-like list */
.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-head p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.panel-body { padding: 18px 20px; }

.list-rows > .list-row {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.list-rows > .list-row:last-child { border-bottom: 0; }
.list-row.archived { opacity: 0.58; }
.row-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: 12px; }
.row-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

/* Tips */
.tip-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 12px 14px;
  font-size: 12px;
}
.tip-card strong { display: block; margin-bottom: 4px; color: var(--text); }
.tip-card p { margin: 0; color: var(--text-muted); }

/* Forms (Admin) */
.admin-grid { display: grid; grid-template-columns: 440px minmax(0, 1fr); gap: 20px; align-items: start; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
.field label, .field-label { color: var(--text-muted); font-weight: 600; }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.5; }

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 140ms, background 140ms;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.progress-track {
  height: 7px;
  width: 100%;
  border-radius: 99px;
  background: var(--surface-subtle);
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 120ms linear;
}
.alert-box {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
}
.alert-box.warn { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); color: var(--warning); }
.alert-box.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, transparent); color: var(--primary); }

/* Commits viewer */
.commit-list { max-height: 360px; overflow-y: auto; }
.commit-row {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}
.commit-row:last-child { border-bottom: 0; }
.commit-left { display: flex; align-items: flex-start; gap: 10px; min-width: 0; flex: 1; }
.commit-subject { font-weight: 600; color: var(--text); word-break: break-word; }
.commit-sub { margin-top: 3px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-muted); }

/* Login Card */
.login-wrap {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 28px;
  box-shadow: var(--shadow-md);
}

/* Modal & Overlays */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 22px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.qr-box {
  width: 210px;
  height: 210px;
  margin: 0 auto;
  padding: 12px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-box svg { width: 100%; height: 100%; display: block; }

.wechat-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.84);
  color: #ffffff;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 70;
  max-width: 380px;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.toast-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.toast.error .toast-dot { background: var(--danger); }

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

/* Responsive */
@media (max-width: 960px) {
  .hero { flex-direction: column; align-items: stretch; padding: 20px; }
  .hero-cta { width: 100%; }
  .admin-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .container { padding: 0 14px; }
  .grid-2, .grid-3, .grid-4, .form-row-2 { grid-template-columns: 1fr; }
  .list-rows > .list-row { flex-direction: column; align-items: flex-start; }
  .topbar-inner { height: auto; padding: 10px 0; flex-wrap: wrap; }
}
