/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #6c63ff;
  --primary-dark: #5a52d5;
  --primary-bg: #eef;
  --primary-bg-active: #ddf;
  --bg: #f5f5f7;
  --card-bg: #fff;
  --text: #1a1a2e;
  --text-secondary: #666;
  --border: #e5e5ea;
  --success: #34c759;
  --error: #ff3b30;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.screen { min-height: 100dvh; }

/* ── PIN Screen ── */
.pin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
}

.pin-logo { margin-bottom: 16px; }

.pin-container h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.pin-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

#pin-form {
  width: 100%;
  max-width: 280px;
}

#pin-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 20px;
  text-align: center;
  letter-spacing: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
}

#pin-input:focus {
  border-color: var(--primary);
}

#pin-btn {
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

#pin-btn:active { background: var(--primary-dark); }
#pin-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.error-msg {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(245, 245, 247, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  font-size: 20px;
  font-weight: 700;
}

.back-btn {
  font-size: 24px;
  text-decoration: none;
  color: var(--primary);
  line-height: 1;
}

/* ── Icon Placeholder (shared) ── */
.icon-placeholder {
  background: linear-gradient(135deg, #6c63ff 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.icon-placeholder.icon-sm {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  font-size: 22px;
}

.icon-placeholder.icon-lg {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  font-size: 32px;
}

/* ── App List ── */
.app-list {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  text-decoration: none;
  color: inherit;
  transition: transform 0.1s;
}

.app-card:active { transform: scale(0.98); }

.app-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  background: #e8e8ed;
  flex-shrink: 0;
}

.app-info {
  flex: 1;
  min-width: 0;
}

.app-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.app-version {
  font-size: 13px;
  color: var(--text-secondary);
}

.app-desc {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.download-btn {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-bg);
  border: none;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.download-btn:active { background: var(--primary-bg-active); }

/* ── App Detail ── */
.app-detail { padding: 20px; }

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.detail-icon {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  object-fit: cover;
  background: #e8e8ed;
}

.detail-meta h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-meta .package {
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-all;
}

.detail-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.download-latest-btn {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  margin-bottom: 24px;
  transition: background 0.2s;
}

.download-latest-btn:active { background: var(--primary-dark); }

/* ── Install Guide ── */
.install-guide {
  background: #fff8e1;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
  font-size: 13px;
  line-height: 1.6;
  color: #5d4037;
}

.install-guide strong { display: block; margin-bottom: 4px; }

/* ── Release List ── */
.release-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.release-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.release-info { flex: 1; }

.release-version {
  font-size: 15px;
  font-weight: 600;
}

.release-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--success);
  border-radius: 10px;
  margin-left: 6px;
}

.release-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.release-notes {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  white-space: pre-wrap;
}

.release-download {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-bg);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}

/* ── Empty / Loading ── */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 15px;
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }
