:root {
  --bg: #0b0d10;
  --panel: #141820;
  --border: #243044;
  --text: #e8eef7;
  --muted: #8b9bb0;
  --crudone-blue: #4d9fff;
  --accent: var(--crudone-blue);
  --ok: #2ecc71;
  --danger: #ff6b6b;
  --radius: 12px;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 10% -10%, #152033 0%, var(--bg) 55%);
  color: var(--text);
}
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 12, 16, 0.9);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand-crud { color: #fff; }
.brand-one { color: var(--crudone-blue); }

.topnav { flex: 1; display: flex; align-items: center; gap: 1rem; }
.auth { display: flex; align-items: center; gap: 0.75rem; }
.user-email { color: var(--muted); font-size: 0.9rem; }

.container { max-width: 860px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
.container-hub { max-width: 1040px; }
.hero h1 { margin: 0 0 0.35rem; font-size: 1.55rem; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.note { margin-top: 0.75rem; }

.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 0.45rem 0.9rem; cursor: pointer; text-decoration: none;
  font: inherit; display: inline-block;
}
.btn.primary { background: var(--accent); border-color: transparent; color: #061018; font-weight: 600; }
.btn.ghost:hover { border-color: var(--accent); }
.btn.dark {
  background: #0a0e14;
  border-color: #2a3548;
  color: #d7e0ee;
  font-weight: 500;
}
.btn.dark:hover {
  border-color: var(--card-accent, var(--accent));
  color: #fff;
}
.btn.dark.is-disabled,
.btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}
.btn.oauth {
  min-width: 7.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-align: center;
}
.btn.oauth:hover { border-color: var(--accent); }
.oauth-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  display: block;
}
.oauth-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
}
.oauth-form { display: inline-flex; margin: 0; }
.btn.oauth.apple { color: #fff; }
.btn.oauth.github { color: #fff; }

.login-section {
  margin-top: 2rem;
  display: flex;
  justify-content: center;
}
.login-panel {
  --auth-col-width: 20rem;
  --auth-gap: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: var(--auth-gap);
  width: 100%;
  max-width: calc(var(--auth-col-width) * 2 + var(--auth-gap));
}
.login-panel-single {
  max-width: var(--auth-col-width);
}
.auth-card {
  margin: 0;
  width: var(--auth-col-width);
  max-width: 100%;
  box-sizing: border-box;
  height: auto;
  align-self: flex-start;
}
.auth-side-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--auth-gap);
  width: var(--auth-col-width);
  max-width: 100%;
  box-sizing: border-box;
}
.auth-side-column .auth-card {
  width: 100%;
}
.auth-card-oauth .oauth-form-full,
.auth-card-oauth .oauth-full {
  width: 100%;
}
.auth-side-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
}
.login-panel h2 { margin: 0 0 0.85rem; font-size: 1.1rem; }
.auth-tabs {
  display: flex; gap: 0.25rem; margin: 0 0 1rem;
  border-bottom: 1px solid var(--border); padding-bottom: 0.35rem;
}
.auth-tab {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--muted); font-weight: 600; font-size: 0.95rem;
  padding: 0.45rem 0.5rem; border-radius: 8px 8px 0 0;
}
.auth-tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.auth-tab.active {
  color: var(--text);
  border-bottom: 2px solid var(--crudone-blue);
  margin-bottom: -1px;
}
.auth-forgot { margin: 0.55rem 0 0; }
.link-forgot {
  color: var(--crudone-blue);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-forgot:hover { color: #7ab8ff; }
.btn.is-loading {
  opacity: 0.75;
  cursor: wait;
  pointer-events: none;
}
.btn.is-loading::after {
  content: "";
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-left: 0.45em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.1em;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.15rem; margin: 0.75rem 0;
}
.card.auth-card {
  margin: 0;
}
.card.card-fit {
  width: max-content;
  max-width: min(100%, 28rem);
  min-width: 18rem;
}

.magic-form { display: flex; flex-direction: column; align-items: stretch; gap: 0.65rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }
.field input {
  background: #0f141c; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 0.55rem 0.7rem; font: inherit;
}
.field input:focus {
  outline: 1px solid var(--crudone-blue);
  border-color: var(--crudone-blue);
}

.divider {
  display: flex; align-items: center; gap: 0.75rem;
  margin: 1.1rem 0 0.9rem; color: var(--muted); font-size: 0.8rem;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
/* 2 wide cards on top row, third wraps below */
.app-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}
@media (max-width: 720px) {
  .app-grid { grid-template-columns: 1fr; }
}
.app-card {
  --control-h: 2.4rem;
  --control-pad-x: 0.95rem;
  --control-fs: 0.9rem;
  --control-radius: 8px;
  display: flex; flex-direction: column; gap: 0.35rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.35rem 1.4rem; text-decoration: none; color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
  min-height: 12rem;
}
.app-card:hover {
  border-color: var(--card-accent, var(--accent));
  transform: translateY(-1px);
}
.app-card-title { font-weight: 700; color: #fff; font-size: 1.2rem; }
.app-card-desc { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.95rem; flex: 1; line-height: 1.45; }

/* Shared control height: Enter, store, downloads, model select */
.app-card .control,
.app-card .btn.control {
  box-sizing: border-box;
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0 var(--control-pad-x);
  font-size: var(--control-fs);
  line-height: 1;
  border-radius: var(--control-radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
.app-card select.control {
  display: inline-flex;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 1.75rem;
}

.app-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Named install sections under Enter */
.card-section {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(36, 48, 68, 0.95);
}
.card-section-title {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.card-section-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.card-section-body .store-btn {
  align-self: flex-start;
  min-width: 8.5rem;
}

.download-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.download-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem;
  min-height: var(--control-h);
}
.download-row-iq .download-btn {
  flex: 1 1 auto;
  min-width: 8rem;
}
.download-row-prg .prg-select {
  flex: 1 1 10rem;
  min-width: 0;
  width: auto;
}
.download-row-prg .download-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.download-btn {
  text-align: center;
}
.info-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  flex-shrink: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  line-height: 1;
}
.info-trigger:hover {
  border-color: var(--card-accent, var(--accent));
  color: var(--card-accent, var(--accent));
}
.info-i {
  font-size: 0.72rem;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
}
.prg-select {
  background-color: #0a0e14;
  color: var(--text);
  border: 1px solid #2a3548;
  font: inherit;
  cursor: pointer;
}

/* Install help popup */
body.popup-open { overflow: hidden; }
.popup[hidden] { display: none !important; }
.popup {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(3px);
}
.popup-panel {
  position: relative;
  z-index: 1;
  width: min(28rem, 100%);
  max-height: min(80vh, 32rem);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  padding: 1rem 1.15rem 1.15rem;
}
.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.popup-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: #fff;
}
.popup-close {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.popup-close:hover {
  color: #fff;
  border-color: var(--accent);
}
.popup-body {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}
.popup-body p { margin: 0 0 0.55rem; color: var(--text); }
.popup-body ul { margin: 0; padding-left: 1.15rem; }
.popup-body li { margin: 0.3rem 0; }
.popup-body code {
  font-size: 0.85em;
  padding: 0.05em 0.3em;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: #d7e4f7;
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.app-card-meta {
  display: inline-block; margin-top: 0.55rem;
  color: var(--card-accent, var(--accent)); font-size: 0.8rem; font-weight: 600;
}
.name-plain { color: #fff; }
.name-accent { color: var(--card-accent, var(--accent)); }

.card-margins { --card-accent: #00c853; }
.card-colors { --card-accent: #ff6b4a; }
.card-list { --card-accent: #7c5cff; }

.banner.error {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: var(--danger); padding: 0.5rem 0.75rem; border-radius: 8px; margin: 0 0 0.75rem;
}
.banner.ok {
  background: rgba(46, 204, 113, 0.12);
  border: 1px solid rgba(46, 204, 113, 0.35);
  color: var(--ok, #2ecc71); padding: 0.5rem 0.75rem; border-radius: 8px; margin: 0 0 0.75rem;
}
.magic-form .field { margin-bottom: 0.65rem; }
.site-footer {
  text-align: center; color: var(--muted); font-size: 0.8rem;
  padding: 1rem; border-top: 1px solid var(--border);
}
.footer-links {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem 1.1rem;
  margin-bottom: 0.45rem;
}
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }
.footer-meta { margin: 0; }
.footer-meta a { color: var(--muted); }
.legal-page .legal-body { line-height: 1.55; max-width: 42rem; }
.legal-page .legal-body h2 { font-size: 1.05rem; margin: 1.25rem 0 0.4rem; }
.legal-page .legal-body p, .legal-page .legal-body li { color: var(--text); }
.legal-page .legal-body ul, .legal-page .legal-body ol { padding-left: 1.2rem; }
.legal-page .legal-body a { color: var(--crudone-blue); }
.app-card-tier {
  display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 0.15rem 0.45rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); margin-bottom: 0.35rem;
}
.app-card-tier.tier-free { border-color: rgba(46, 204, 113, 0.45); color: #2ecc71; }
.app-card-tier.tier-pro { border-color: rgba(77, 159, 255, 0.45); color: var(--crudone-blue); }

.nav-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.nav-link.active, .nav-link:hover { color: var(--text); }
.profile-layout {
  display: grid; grid-template-columns: 11rem 1fr; gap: 1.5rem; align-items: start;
}
.profile-side {
  display: flex; flex-direction: column; gap: 0.35rem;
  position: sticky; top: 4rem;
}
.side-link {
  color: var(--muted); text-decoration: none; padding: 0.4rem 0.55rem;
  border-radius: 8px; font-size: 0.92rem;
}
.side-link.active, .side-link:hover {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
}
.hero.tight h1 { margin-bottom: 0.2rem; }
.danger-zone { border-color: rgba(255, 107, 107, 0.35); }
.btn.danger {
  background: var(--danger); border-color: transparent; color: #1a0606; font-weight: 600;
}
.btn.sm { padding: 0.25rem 0.55rem; font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 0.92rem;
}
.data-table th, .data-table td {
  text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 600; }

@media (max-width: 720px) {
  .login-panel {
    flex-direction: column;
    align-items: center;
    max-width: var(--auth-col-width);
  }
  .auth-card,
  .auth-side-column {
    width: min(100%, var(--auth-col-width));
  }
}

@media (max-width: 560px) {
  .card.card-fit { width: 100%; min-width: 0; }
  .login-panel { --auth-col-width: 100%; max-width: 100%; }
  .auth-card,
  .auth-side-column { width: 100%; }
  .oauth-row { flex-direction: column; align-items: stretch; }
  .oauth-form { width: 100%; }
  .btn.oauth { width: 100%; }
  .profile-layout { grid-template-columns: 1fr; }
  .profile-side { position: static; flex-direction: row; flex-wrap: wrap; }
}
