

/* Современные CSS-переменные для базовой настройки */
:root {
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', 
               Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Агрессивный сброс отступов и границ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Нормализация HTML-элементов */

/* Документ и body */
html {
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  line-height: 1.5;
}

/* Семантические элементы HTML5 */
main {
  display: block;
}

hr {
  box-sizing: content-box;
  height: 0;
  overflow: visible;
  border: none;
  border-top: 1px solid;
  margin: 1rem 0;
}

/* Типография и текст */
h1 {
  font-size: 2em;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: inherit;
  line-height: 1.2;
  overflow-wrap: break-word;
  margin-block-start: 0;
  margin-block-end: 0;
  text-wrap: balance;
}

p {
  overflow-wrap: break-word;
  hyphens: auto;
  text-wrap: pretty;
  margin-block-start: 0;
  margin-block-end: 0;
}

pre {
  font-family: var(--font-mono);
  font-size: 1em;
  white-space: pre-wrap;
}

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 1em;
}


sub, sup {
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

/* Ссылки и интерактивные элементы */
a {
  color: inherit;
  text-decoration-skip-ink: auto;
  -webkit-tap-highlight-color: transparent;
}

abbr[title] {
  border-bottom: none;
  text-decoration: underline;
  text-decoration: underline dotted;
  cursor: help;
}

b, strong {
  font-weight: bolder;
}

/* Медиа-элементы */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  border-style: none;
}

svg {
  fill: currentColor;
}

/* Формы и интерактивные элементы*/
button, input, optgroup, select, textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: 1.15;
  margin: 0;
  color: inherit;
  background: none;
  border: none;
  outline: revert;
}

button, input {
  overflow: visible;
}

button, select {
  text-transform: none;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

button,
[type="button"],
[type="reset"],
[type="submit"] {
  -webkit-appearance: button;
}

button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
  border-style: none;
  padding: 0;
}

button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
  outline: 1px dotted ButtonText;
}

fieldset {
  padding: 0.35em 0.75em 0.625em;
  border: 1px solid;
}

legend {
  box-sizing: border-box;
  color: inherit;
  display: table;
  max-width: 100%;
  padding: 0;
  white-space: normal;
}

progress {
  vertical-align: baseline;
}

textarea {
  overflow: auto;
  resize: vertical;
}

input[type="search"] {
  -webkit-appearance: textfield;
  outline-offset: -2px;
}

input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

input[type="checkbox"],
input[type="radio"] {
  box-sizing: border-box;
  padding: 0;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  height: auto;
}

::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}

/* Таблицы */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Списки */
ul, ol {
  list-style: none;
}

/* Детали и раскрывающиеся элементы */
details {
  display: block;
}

summary {
  display: list-item;
  cursor: pointer;
}

summary::-webkit-details-marker {
  display: none;
}

/* Скрытые элементы и шаблоны */
template {
  display: none;
}

[hidden] {
  display: none !important;
}

/* Исправление современных проблем и улучшения */

/* Динамический viewport для мобильных устройств */
@media (max-height: 600px) and (orientation: landscape) {
  body {
    min-height: 100svh;
  }
}

/* Улучшение доступности фокуса */
:focus-visible {
  outline: 2px solid Highlight;
  outline-offset: 2px;
}

@media (-webkit-min-device-pixel-ratio: 0) {
  :focus-visible {
    outline-color: -webkit-focus-ring-color;
  }
}

/* Оптимизация для сенсорных устройств */
@media (hover: none) and (pointer: coarse) {
  input,
  textarea,
  button,
  select,
  a {
    -webkit-tap-highlight-color: transparent;
  }
  
  button,
  input[type="button"],
  input[type="submit"],
  input[type="reset"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Уменьшение движения (accessibility) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* Оптимизация печати */
@media print {
  *,
  *::before,
  *::after {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  a {
    text-decoration: underline;
  }
  
  a[href^="http"]::after {
    content: " (" attr(href) ")";
  }
  
  pre {
    white-space: pre-wrap !important;
  }
  
  @page {
    margin: 2cm;
  }
}


/* Исправление проблем с наследованием в формах */
input::placeholder,
textarea::placeholder {
  color: currentColor;
  opacity: 0.6;
}

/* Критические исправления для современных браузеров */

/* Исправление проблемы с автозаполнением в Chrome/Safari */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-background-clip: text;
  -webkit-text-fill-color: currentColor;
  transition: background-color 5000s ease-in-out 0s;
}

/* Исправление для Safari на iOS (превью ссылок) */
a[href^="tel"],
a[href^="mailto"] {
  color: inherit;
  text-decoration: none;
}

/*  Исправление проблем с интерактивными элементами в Firefox */
@-moz-document url-prefix() {
  button,
  input,
  select,
  textarea {
    border-radius: 0;
  }
}

/* Поддержка диалоговых окон */
dialog {
  padding: 0;
  border: none;
  background: none;
  max-width: calc(100% - 2rem);
  max-height: calc(100% - 2rem);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}