:root {
  color-scheme: light;
  --bg: #f4f8fb;
  --bg-accent: linear-gradient(160deg, #e8f2fc 0%, #f4f8fb 40%, #eef6f0 100%);
  --surface: rgba(255, 255, 255, 0.85);
  --surface-strong: rgba(255, 255, 255, 0.95);
  --surface-soft: rgba(240, 247, 255, 0.7);
  --border: rgba(180, 205, 230, 0.4);
  --border-strong: rgba(130, 175, 220, 0.5);
  --text: #1a2b3c;
  --text-muted: #5a7085;
  --text-soft: #7a95aa;
  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --accent: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --shadow: 0 8px 32px rgba(100, 140, 180, 0.12);
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --container: 1200px;
  --transition: 180ms ease;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-accent);
  color: var(--text);
}

body,
button,
a {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  display: block;
}

button,
a {
  cursor: pointer;
}

button,
input,
textarea,
select {
  font: inherit;
}

button:focus,
a:focus {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.text-muted {
  color: var(--text-muted);
  margin: 0;
}

/* Layout */

.page-shell {
  width: min(100% - 32px, var(--container));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.layout {
  display: grid;
  gap: 32px;
}

.layout-two-col {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: start;
}

.col-main {
  display: grid;
  gap: 32px;
}

.col-side {
  position: sticky;
  top: 100px;
  display: grid;
  gap: 24px;
}

.section-block {
  display: grid;
  gap: 16px;
}

.section-title {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  letter-spacing: -0.02em;
  color: var(--text);
}

/* Card base */

.card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

/* Topbar */

.topbar {
  display: flex;
  position: sticky;
  top: 16px;
  z-index: 20;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding: 16px 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(100, 140, 180, 0.1);
}

.topbar > * + * {
  margin-left: 20px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.3rem, 1.6vw, 1.8rem);
  letter-spacing: -0.03em;
  color: var(--text);
}

.topbar-meta {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.topbar-meta > * + * {
  margin-left: 12px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-soft);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.15);
  flex: 0 0 auto;
}

/* Download card */

.download-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.download-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 12px 40px rgba(100, 140, 180, 0.16);
}

.download-card__head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.download-card__head > * + * {
  margin-left: 16px;
}

.download-card__label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-soft);
}

.download-card__title {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.latest-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.meta-list {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 4px;
}

.meta-list div {
  flex: 1 1 0;
  min-width: 0;
  margin: 0 24px 16px 0;
}

.meta-list dt {
  color: var(--text-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.meta-list dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
  font-size: 0.92rem;
}

.hash-preview {
  font-family: 'SFMono-Regular', ui-monospace, monospace;
  font-size: 0.82rem;
  color: var(--accent);
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.1);
  color: var(--accent);
  border: 1px solid rgba(14, 165, 233, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
}

.button > * + * {
  margin-left: 10px;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}

.button-primary:hover {
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

/* Changelog */

.changelog-card {
  line-height: 1.7;
}

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

.changelog-header > * + * {
  margin-left: 12px;
}

.changelog-version {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.88rem;
}

.changelog-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

.changelog-list li {
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.changelog-list li:last-child {
  margin-bottom: 0;
}

.changelog-section-title {
  margin: 14px 0 6px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

/* QR Code */

.qrcode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px;
  text-align: center;
}

.qrcode-card > * + * {
  margin-top: 16px;
}

.qrcode-img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.qrcode-fallback {
  color: var(--text-soft);
  font-size: 0.88rem;
}

/* Guide card */

.guide-card {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--transition), transform var(--transition);
}

.guide-card > * + * {
  margin-left: 14px;
}

.guide-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.guide-icon {
  flex-shrink: 0;
  color: var(--primary);
}

.guide-title {
  margin: 0 0 2px;
  font-weight: 600;
  font-size: 0.92rem;
}

/* Download card with icon */

.latest-card--with-icon {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 20px;
  align-items: start;
}

.app-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: contain;
  border: 1px solid var(--border);
  background: #fff;
}

.latest-card__body {
  min-width: 0;
}

/* Tools grid */

.tool-icon-img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.tool-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.tool-item > * + * {
  margin-top: 12px;
}

.tool-item:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(100, 140, 180, 0.16);
}

.tool-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
}

.tool-name {
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

/* Feedback */

.feedback-panel {
  min-height: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.feedback-panel.is-error {
  color: #dc2626;
}

.feedback-panel.is-success {
  color: var(--success);
}

/* Skeleton */

.skeleton {
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.06), transparent);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* Splash screen */

.splash {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.splash.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.splash-content > * + * {
  margin-top: 32px;
}

.splash-icon-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  animation: splash-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.splash-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: contain;
}

.splash-ring {
  width: 140px;
  height: 140px;
  transform: rotate(-90deg);
}

.splash-ring-bg,
.splash-ring-fill {
  fill: none;
  stroke-width: 4;
}

.splash-ring-bg {
  stroke: rgba(255, 255, 255, 0.1);
}

.splash-ring-fill {
  stroke: url(#splash-gradient);
  stroke: #3b82f6;
  stroke-linecap: round;
  stroke-dasharray: 402;
  stroke-dashoffset: 402;
  animation: splash-circle 1.6s 0.2s ease-in-out forwards;
}

.splash-text {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.1em;
  animation: splash-fade-up 0.8s 0.3s ease both;
}

@keyframes splash-pop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes splash-fade-up {
  0% { transform: translateY(16px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes splash-circle {
  0% { stroke-dashoffset: 402; stroke: #3b82f6; }
  50% { stroke: #0ea5e9; }
  100% { stroke-dashoffset: 0; stroke: #10b981; }
}

/* Responsive */

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, var(--container));
    padding-top: 20px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    border-radius: 20px;
    padding: 16px;
  }

  .topbar > * + * {
    margin-left: 0;
    margin-top: 12px;
  }

  .layout-two-col {
    grid-template-columns: 1fr;
  }

  .col-side {
    position: static;
  }

  .download-card {
    padding: 16px;
  }

  .button {
    width: 100%;
  }

  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
  }

  .tool-item {
    padding: 18px 12px;
  }

  .qrcode-img {
    width: 160px;
    height: 160px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
