:root {
  --bg: #FAFAFA;
  --card-bg: #FFFFFF;
  --card-hover: #F8F9FA;
  --border: #E8E8EC;
  --border-hover: #D1D1D6;
  --tag-bg: #F4F4F5;
  
  --text: #18181B;
  --text-muted: #71717A;
  --text-subtle: #A1A1AA;
  
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --transition: all 0.15s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page-wrapper {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 0 20px 0;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--text-subtle);
  transition: var(--transition);
}

.status-indicator.online {
  background-color: #10B981;
}

/* Hero */
.hero-section {
  padding: 48px 0 36px 0;
}

.hero-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 10px;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 580px;
}

/* Grid */
.platforms-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.platform-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
}

.platform-card:hover {
  background: var(--card-hover);
  border-color: var(--border-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.platform-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-tag {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--tag-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.platform-title {
  font-size: 1.18rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.platform-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 20px;
  flex: 1;
}

/* Buttons */
.btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--tag-bg);
  color: var(--text);
  transition: var(--transition);
}

.btn:hover {
  background: #ECECEE;
  border-color: var(--border-hover);
}

/* Accent Buttons */
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-block {
  width: 100%;
}

/* Direct link */
.portal-footer-link {
  text-align: center;
  margin-bottom: 32px;
}

.direct-app-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  transition: var(--transition);
}

.direct-app-link:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

/* Footer */
.footer {
  margin-top: auto;
  padding: 20px 0;
  text-align: center;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-subtle);
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.footer a:hover {
  color: var(--text);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.12);
}

.modal-card-lg {
  max-width: 620px;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--tag-bg);
  color: var(--text);
}

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

.modal-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.modal-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Downloads */
.download-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.download-option-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

.download-option-card:hover {
  border-color: var(--border-hover);
  background: var(--card-hover);
}

.option-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.option-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.option-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}

.option-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.option-btn {
  background: var(--tag-bg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
}

/* Steps in Scriptable modal */
.steps-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--tag-bg);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.step-number {
  width: 20px;
  height: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.widget-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.widget-actions .btn {
  flex: 1;
}

/* Code Preview */
.code-preview-wrapper {
  background: #F8F9FA;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.code-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--tag-bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.code-preview-content {
  padding: 12px 14px;
  max-height: 180px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  color: #27272A;
  line-height: 1.4;
}

/* Guidance */
.guidance-block {
  margin-bottom: 16px;
  background: var(--tag-bg);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.guidance-heading {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text);
}

.guidance-steps {
  padding-left: 18px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.guidance-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.modal-actions {
  margin-top: 16px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #18181B;
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(12px);
  opacity: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
  pointer-events: auto;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 640px) {
  .hero-title {
    font-size: 1.65rem;
  }
  .platforms-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .widget-actions {
    flex-direction: column;
  }
}
