/* Общий вид: цвета, боковая панель, формы, кнопки. Тема — по системе.
   Палитра и формы — те же, что в Atlas (Nuxt UI): нейтральный zinc и морской акцент sea. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #ffffff;
  --elevated: #f4f4f5;
  --text: #3f3f46;
  --strong: #18181b;
  --muted: #71717a;
  --dimmed: #a1a1aa;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --accent: #0e7c86;
  --accent-soft: rgb(14 124 134 / 0.1);
  --accent-text: #ffffff;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --warn: #a16207;
  --badge: #0e7c86;
  --radius: 8px;
  --radius-lg: 12px;
  --gutter: 16px;
  --side: 240px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* Тёмная палитра дважды: по системе (если тему не выбрали кнопкой «Тема») и по выбору. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18181b;
    --surface: #18181b;
    --elevated: #27272a;
    --text: #e4e4e7;
    --strong: #fafafa;
    --muted: #a1a1aa;
    --dimmed: #71717a;
    --line: #27272a;
    --line-strong: #3f3f46;
    --accent: #45b7c1;
    --accent-soft: rgb(69 183 193 / 0.14);
    --accent-text: #08272b;
    --danger: #fca5a5;
    --danger-bg: #3b1d1d;
    --ok: #86efac;
    --ok-bg: #14291b;
    --warn: #facc15;
    --badge: #45b7c1;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #18181b;
  --surface: #18181b;
  --elevated: #27272a;
  --text: #e4e4e7;
  --strong: #fafafa;
  --muted: #a1a1aa;
  --dimmed: #71717a;
  --line: #27272a;
  --line-strong: #3f3f46;
  --accent: #45b7c1;
  --accent-soft: rgb(69 183 193 / 0.14);
  --accent-text: #08272b;
  --danger: #fca5a5;
  --danger-bg: #3b1d1d;
  --ok: #86efac;
  --ok-bg: #14291b;
  --warn: #facc15;
  --badge: #45b7c1;
}

:root[data-theme="light"] {
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

pre,
code {
  font-family: var(--mono);
  font-size: 0.92em;
}

pre {
  overflow-x: auto;
  max-width: 100%;
}

/* Раскладка: слева панель, справа страница (как в Atlas). */

.shell {
  display: flex;
  min-height: 100vh;
}

.shell-bare {
  flex-direction: column;
}

.side {
  position: sticky;
  top: 0;
  align-self: flex-start;
  flex: none;
  width: var(--side);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--elevated) 40%, var(--bg));
}

.bare {
  padding: 20px var(--gutter) 0;
  max-width: 28rem;
  width: 100%;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 12px;
  font-weight: 600;
  color: var(--strong);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.9rem;
  font-weight: 700;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
}

.nav a,
.me summary,
.me-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.nav a:hover,
.me summary:hover,
.me-menu a:hover {
  background: var(--elevated);
  color: var(--strong);
  text-decoration: none;
}

.nav a[aria-current="page"],
.me-menu a[aria-current="page"] {
  background: var(--elevated);
  color: var(--accent);
}

.ico {
  flex: none;
}

.badge {
  display: inline-block;
  min-width: 1.5em;
  margin-left: auto;
  padding: 0 0.4em;
  border-radius: 999px;
  background: var(--badge);
  color: var(--accent-text);
  font-size: 0.75rem;
  line-height: 1.5;
  text-align: center;
}

/* «Тема» — кнопка, но выглядит пунктом панели, как в Atlas. */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  filter: none;
}

.theme-toggle:hover {
  background: var(--elevated);
  color: var(--strong);
  filter: none;
}

.me {
  position: relative;
}

.me summary {
  cursor: pointer;
  list-style: none;
}

.me summary span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.me-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.14);
}

.me-menu form {
  margin: 0;
}

.me-menu button.link {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.me-menu button.link:hover {
  background: var(--elevated);
  color: var(--strong);
  text-decoration: none;
}

/* Вкладки над экранами учёбы и кнопка «назад» — как в разделе «Учёба» Atlas. */

.tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 24px -10px;
}

.tabs a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.tabs a:hover {
  color: var(--strong);
  text-decoration: none;
}

.tabs a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px -10px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.back:hover {
  background: var(--elevated);
  color: var(--strong);
  text-decoration: none;
}

/* Описание под заголовком экрана: приглушённое, как в Atlas. */
.lede {
  margin: -10px 0 24px;
  color: var(--muted);
}

/* Страница */

.page {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 64rem;
  padding: 32px 32px 64px;
}

.shell-bare .page {
  max-width: 28rem;
  margin: 0 auto;
  padding: 16px var(--gutter) 48px;
}

h1 {
  margin: 0 0 16px;
  color: var(--strong);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

h2 {
  margin: 28px 0 12px;
  color: var(--strong);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.muted {
  color: var(--muted);
}

.error-page {
  max-width: 34em;
  padding: 24px 0;
}

/* Формы */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 26em;
}

.form label,
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--strong);
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
}

textarea {
  min-height: 7em;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

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

button,
.button {
  display: inline-block;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 16px;
  text-decoration: none;
  text-align: center;
}

button:hover,
.button:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

button.secondary,
.button.secondary {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text);
  filter: none;
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--elevated);
  color: var(--strong);
}

button.link {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--text);
  text-align: left;
  filter: none;
}

button.link:hover {
  text-decoration: underline;
}

.alert {
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 0 0 16px;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.hint {
  color: var(--muted);
  font-size: 0.9em;
}

.login-page {
  margin: 4vh 0 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.login-page h1 {
  margin-bottom: 20px;
}

/* Узкий экран: панель становится верхней полосой, разделы — строка под ней, листается вбок. */
@media (max-width: 860px) {
  .shell {
    flex-direction: column;
  }

  .side {
    position: sticky;
    z-index: 20;
    width: auto;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
  }

  .brand {
    padding: 2px 4px;
  }

  .nav {
    order: 3;
    flex: 1 0 100%;
    flex-direction: row;
    gap: 2px;
    overflow-x: auto;
  }

  .nav a {
    flex: none;
  }

  /* Первая строка полосы: бренд слева, «Тема» и имя справа; разделы — второй строкой. */
  .theme-toggle {
    width: auto;
    margin-left: auto;
  }

  .theme-toggle span {
    display: none;
  }

  .me {
    margin-left: 0;
  }

  .me summary {
    max-width: 11em;
  }

  .me-menu {
    top: 100%;
    bottom: auto;
    left: auto;
    right: 0;
    min-width: 11em;
    margin: 6px 0 0;
  }

  .page {
    padding: 20px var(--gutter) 48px;
  }
}

/* На телефоне четыре пункта с иконками не помещаются в ширину — иконки уходят, подписи остаются. */
@media (max-width: 480px) {
  .nav a .ico {
    display: none;
  }
}

@media (max-width: 420px) {
  :root {
    --gutter: 12px;
  }

  h1 {
    font-size: 1.35rem;
  }
}
