/* LMail 2.0 — base: reset, page background, focus, scrollbars, checkboxes, motion.
   Sources: portal preflight equivalent (design-tokens §7), globals.css:510-580,
   techno-theme.css:52-98, globals.css:6183-6197, 6563-6628. */

/* Reset (Tailwind preflight equivalent used by the portal) */
*,
::after,
::before,
::backdrop,
::file-selector-button {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0 solid;
}
html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
}
a {
  color: inherit;
  -webkit-text-decoration: inherit;
  text-decoration: inherit;
}
b, strong {
  font-weight: bolder;
}
code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 1em;
}
small {
  font-size: 80%;
}
table {
  text-indent: 0;
  border-color: inherit;
  border-collapse: collapse;
}
ol, ul, menu {
  list-style: none;
}
img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  vertical-align: middle;
}
img, video {
  max-width: 100%;
  height: auto;
}
button, input, select, optgroup, textarea, ::file-selector-button {
  font: inherit;
  font-feature-settings: inherit;
  font-variation-settings: inherit;
  letter-spacing: inherit;
  color: inherit;
  border-radius: 0;
  background-color: transparent;
  opacity: 1;
}
::placeholder {
  opacity: 1;
  color: color-mix(in oklab, currentcolor 50%, transparent);
}
textarea {
  resize: vertical;
}

/* The hidden attribute must win over any class that sets display. */
[hidden] { display: none !important; }

/* Page */
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: radial-gradient(circle at 74% -10%, color-mix(in srgb, var(--accent-primary) 10%, transparent), transparent 31%), var(--lm-body-base);
  color: var(--graphite);
  font-family: var(--font-sans);
  text-rendering: optimizeLegibility;
}
body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: var(--lm-grid-opacity);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  animation: grid-drift 18s linear infinite;
  -webkit-mask-image: linear-gradient(to bottom, black, transparent 92%);
  mask-image: linear-gradient(to bottom, black, transparent 92%);
  pointer-events: none;
}
@keyframes grid-drift { to { background-position: 48px 48px, 48px 48px; } }

button, a { -webkit-tap-highlight-color: transparent; }
button:not(:disabled), summary, label:has(input[type="checkbox"]) { cursor: pointer; }
button { text-align: inherit; }

::selection { background: color-mix(in srgb, var(--amber) 28%, transparent); }

/* Keyboard focus */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--lm-focus);
  outline-offset: 3px;
}
/* Dense lists, menus and chips: the ring is drawn inside the element. */
:is(.lm-menu__item, .lm-chip > button, .lm-recent__item > button, .lm-suggest__item, .market-admin-tabs > *, .tech-sidebar > nav a, .lm-folder__more, .mobile-tabbar > *, .lm-toast button, .sidebar-profile, .sidebar-logout, .lm-reader__body, #lm-main):focus-visible {
  outline-width: 2px;
  outline-offset: -2px;
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: var(--r-xs); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent-primary); background-clip: content-box; }

/* Checkboxes and radios */
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; flex: 0 0 auto; display: grid; margin: 0; appearance: none; border: 1px solid var(--line-strong); border-radius: var(--r-xs); background: transparent; cursor: pointer; place-content: center; transition: border-color 0.15s ease, background 0.15s ease; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover:not(:disabled), input[type="radio"]:hover:not(:disabled) { border-color: var(--accent-primary); }
input[type="checkbox"]:checked, input[type="radio"]:checked { border-color: var(--accent-primary); background: var(--accent-primary); }
input[type="checkbox"]::before { width: 5px; height: 9px; border: solid var(--lm-on-accent); border-width: 0 2px 2px 0; content: ""; opacity: 0; transform: rotate(45deg) translate(-1px, -1px); }
input[type="radio"]::before { width: 8px; height: 8px; border-radius: 50%; background: var(--lm-on-accent); content: ""; opacity: 0; }
input[type="checkbox"]:checked::before, input[type="radio"]:checked::before { opacity: 1; }
input[type="checkbox"]:indeterminate { border-color: var(--accent-primary); }
input[type="checkbox"]:indeterminate::before { width: 8px; height: 0; border-width: 0 0 2px; border-color: var(--accent-primary); opacity: 1; transform: none; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { cursor: not-allowed; opacity: 0.45; }

/* Helpers */
.lm-visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.lm-skip { position: fixed; left: 12px; top: -64px; z-index: var(--lm-z-tooltip); padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--accent-primary); }
.lm-skip:focus { top: 12px; }
.lm-boot { min-height: 100vh; min-height: 100dvh; gap: 22px; align-content: center; color: var(--accent-primary); }

/* Kazakh glyphs must never fall back to a partial decorative font. */
html[lang="kk"] body,
html[lang="kk"] body * { font-family: var(--font-sans) !important; }
html[lang="kk"] body .lm-code { font-family: var(--font-mono) !important; }
html[lang="kk"] :is(.tech-kicker, .network-status, .tech-btn, .nav-group-label, .terminal-form label, .sidebar-logout, .lm-field__label, .lm-menu__heading, .super-status) { letter-spacing: 0.045em; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }
