:root {
  --qeel-bg: #f4f7fb;
  --qeel-surface: #ffffff;
  --qeel-surface-2: #eef4fb;
  --qeel-surface-elevated: rgba(255, 255, 255, 0.88);
  --qeel-text: #102033;
  --qeel-muted: #66758a;
  --qeel-border: #dfe7f1;
  --qeel-primary: #2563eb;
  --qeel-primary-strong: #1d4ed8;
  --qeel-primary-soft: #eaf1ff;
  --qeel-success: #16a34a;
  --qeel-warning: #d97706;
  --qeel-danger: #dc2626;
  --qeel-shadow: 0 18px 45px rgba(42, 62, 89, 0.10);
  --qeel-radius-lg: 22px;
  --qeel-radius-md: 18px;
  --qeel-radius-sm: 14px;
  --qeel-max: 1180px;
  --qeel-header-h: 72px;
  --qeel-mobile-nav-h: 68px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --qeel-bg: #08111f;
  --qeel-surface: #0e1a2a;
  --qeel-surface-2: #132238;
  --qeel-surface-elevated: rgba(14, 26, 42, 0.90);
  --qeel-text: #ecf4ff;
  --qeel-muted: #9fb0c5;
  --qeel-border: #223651;
  --qeel-primary: #60a5fa;
  --qeel-primary-strong: #93c5fd;
  --qeel-primary-soft: #132b4d;
  --qeel-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.qeel-theme {
  margin: 0;
  overflow-x: hidden;
  background: var(--qeel-bg);
  color: var(--qeel-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
body.qeel-theme a { color: inherit; text-decoration: none; }
body.qeel-theme img { max-width: 100%; height: auto; }
button, input, textarea, select { font: inherit; }

.qeel-container {
  width: min(calc(100% - 48px), var(--qeel-max));
  margin-inline: auto;
}

.qe-skip-link {
  position: fixed;
  z-index: 99999;
  left: 16px;
  top: -80px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--qeel-text);
  color: var(--qeel-bg);
}
.qe-skip-link:focus { top: 12px; }

.qeel-shell-header {
  position: sticky;
  z-index: 1000;
  top: 0;
  height: var(--qeel-header-h);
  border-bottom: 1px solid color-mix(in srgb, var(--qeel-border) 85%, transparent);
  background: var(--qeel-surface-elevated);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
body.admin-bar .qeel-shell-header { top: 32px; }
.qeel-shell-header__inner {
  height: 100%;
  display: grid;
  grid-template-columns: 190px 1fr 220px;
  align-items: center;
  gap: 20px;
}

.qeel-brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.qeel-brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--qeel-primary), #7c3aed);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 9px 24px color-mix(in srgb, var(--qeel-primary) 28%, transparent);
}
.qeel-brand__copy { display: grid; line-height: 1.05; }
.qeel-brand__copy strong { font-size: 17px; letter-spacing: .01em; }
.qeel-brand__copy small { margin-top: 4px; color: var(--qeel-muted); font-size: 11px; }

.qeel-desktop-nav { min-width: 0; }
.qeel-nav-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.qeel-nav-list a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 13px;
  border-radius: 12px;
  color: var(--qeel-muted);
  font-size: 14px;
  font-weight: 650;
}
.qeel-nav-list a:hover,
.qeel-nav-list .current-menu-item > a { background: var(--qeel-primary-soft); color: var(--qeel-primary-strong); }

.qeel-header-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.qeel-theme-toggle {
  position: relative;
  width: 44px;
  height: 40px;
  flex: 0 0 44px;
  padding: 0;
  border: 1px solid var(--qeel-border);
  border-radius: 13px;
  background: var(--qeel-surface);
  color: var(--qeel-text);
  cursor: pointer;
}
.qeel-theme-toggle > span { position: absolute; inset: 0; display: grid; place-items: center; }
.qeel-theme-toggle__moon { opacity: 0; }
html[data-theme="dark"] .qeel-theme-toggle__sun { opacity: 0; }
html[data-theme="dark"] .qeel-theme-toggle__moon { opacity: 1; }
.qeel-theme-toggle:focus-visible,
.qeel-account-slot:focus-visible,
.qeel-nav-list a:focus-visible,
.qeel-mobile-nav a:focus-visible { outline: 3px solid color-mix(in srgb, var(--qeel-primary) 34%, transparent); outline-offset: 2px; }

.qeel-account-slot {
  width: 154px;
  height: 40px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--qeel-border);
  border-radius: 13px;
  background: var(--qeel-surface);
}
.qeel-account-slot__avatar { width: 28px; height: 28px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: var(--qeel-surface-2); color: var(--qeel-muted); }
.qeel-account-slot__avatar-img { width: 28px; height: 28px; border-radius: 50%; }
.qeel-account-slot__label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; font-weight: 650; }

.qeel-page { min-height: calc(100vh - var(--qeel-header-h) - 160px); }
.qe-content-page { padding: 48px 0 72px; }
.qe-entry { max-width: 820px; margin: 0 auto; padding: clamp(24px, 4vw, 42px); border: 1px solid var(--qeel-border); border-radius: var(--qeel-radius-lg); background: var(--qeel-surface); box-shadow: var(--qeel-shadow); }
.qe-entry__title { margin: 0 0 24px; font-size: clamp(28px, 4vw, 44px); line-height: 1.15; }
.qe-entry__content { color: var(--qeel-text); }
.qe-entry__content a { color: var(--qeel-primary-strong); text-decoration: underline; text-underline-offset: 3px; }

.qeel-shell-footer { border-top: 1px solid var(--qeel-border); background: var(--qeel-surface); }
.qeel-shell-footer__inner { min-height: 138px; display: grid; place-content: center; text-align: center; gap: 6px; padding: 28px 0; }
.qeel-shell-footer p { margin: 0; }
.qeel-shell-footer__brand { font-size: 14px; font-weight: 750; }
.qeel-shell-footer__brand span { color: var(--qeel-muted); font-weight: 500; }
.qeel-shell-footer__meta { color: var(--qeel-muted); font-size: 12px; }

.qeel-mobile-nav { display: none; }

@media (max-width: 1023px) {
  :root { --qeel-header-h: 64px; }
  .qeel-container { width: min(calc(100% - 40px), var(--qeel-max)); }
  .qeel-shell-header__inner { grid-template-columns: 1fr auto; gap: 14px; }
  .qeel-desktop-nav { display: none; }
  .qeel-header-actions { grid-column: 2; }
  .qeel-account-slot { width: 132px; }
  .qeel-mobile-nav {
    position: fixed;
    z-index: 1200;
    right: 14px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 14px;
    min-height: var(--qeel-mobile-nav-h);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
    padding: 8px;
    border: 1px solid var(--qeel-border);
    border-radius: 20px;
    background: var(--qeel-surface-elevated);
    box-shadow: 0 16px 42px rgba(10, 25, 48, 0.16);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }
  .qeel-mobile-nav a { min-width: 0; min-height: 50px; display: grid; place-content: center; gap: 2px; border-radius: 14px; color: var(--qeel-muted); text-align: center; }
  .qeel-mobile-nav a:hover { color: var(--qeel-primary-strong); background: var(--qeel-primary-soft); }
  .qeel-mobile-nav span { font-size: 20px; line-height: 1; }
  .qeel-mobile-nav small { font-size: 11px; font-weight: 700; }
  body.qeel-theme { padding-bottom: calc(var(--qeel-mobile-nav-h) + 34px + env(safe-area-inset-bottom)); }
}

@media (max-width: 782px) {
  body.admin-bar .qeel-shell-header { top: 46px; }
}

@media (max-width: 767px) {
  .qeel-container { width: min(calc(100% - 30px), var(--qeel-max)); }
  .qeel-brand__copy small { display: none; }
  .qeel-header-actions { gap: 7px; }
  .qeel-account-slot { width: 42px; grid-template-columns: 1fr; padding: 6px; }
  .qeel-account-slot__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .qe-content-page { padding-top: 28px; }
}

.qe-entry__header { margin-bottom: 22px; }
.qe-entry__meta { margin: 0 0 8px; color: var(--qeel-muted); font-size: 12px; }
.qe-entry__content > :first-child { margin-top: 0; }
.qe-entry__content > :last-child { margin-bottom: 0; }
.qe-entry__content p, .qe-entry__content li { color: color-mix(in srgb, var(--qeel-text) 88%, var(--qeel-muted)); }
.qe-entry__content pre { max-width: 100%; overflow-x: auto; padding: 16px; border: 1px solid var(--qeel-border); border-radius: 14px; background: var(--qeel-surface-2); }
.qe-entry__content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.qe-not-found { text-align: center; }
.qe-not-found .qe-section-kicker { margin-bottom: 10px; }
.qe-not-found p { color: var(--qeel-muted); }
.qe-not-found .qe-button { margin-top: 8px; }

.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.screen-reader-text:focus {
  width: auto;
  height: auto;
  margin: 0;
  clip: auto;
  white-space: normal;
}
