/* === Основные стили страницы === */
:root {
  --bg: #111;
  --fg: #eee;
  --muted: #bbb;
  --accent: #00bcd4;
  --surface: #1a1a1a;
  --surface-2: #222;
  --max-content-width: 900px;
  --gap: 16px;
}

/* Mobile-first base */
html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  /* avoid horizontal scroll */
  -webkit-overflow-scrolling: touch;
  /* smooth scrolling on iOS */
}

/* === Сайдбар === */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background-color: var(--surface);
  overflow-x: hidden;
  transition: width 0.28s ease;
  z-index: 1000;
  padding-top: 60px;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.4);
}

.sidebar a {
  padding: 12px 20px;
  text-decoration: none;
  font-size: 17px;
  color: var(--muted);
  display: block;
  transition: color 0.2s, background 0.2s, transform 0.12s;
}

.sidebar a:hover {
  color: #00bcd4;
  background: #222;
}

.sidebar .closebtn {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 32px;
  color: #aaa;
  transition: color 0.2s;
}

.sidebar .closebtn:hover {
  color: #00bcd4;
}

/* === Кнопка открытия меню === */
.openbtn {
  font-size: 18px;
  background-color: var(--surface);
  color: var(--fg);
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.18s, transform 0.12s;
}

.openbtn:hover {
  background-color: #00bcd4;
  color: #111;
  transform: translateY(-2px);
}

/* === Основное содержимое === */
#main {
  transition: margin-left 0.28s ease, padding 0.2s ease;
  padding: 18px;
  max-width: var(--max-content-width);
  margin: 0 auto;
}

#main h1 {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
  margin-bottom: 18px;
  font-size: 1.6rem;
}

#main p {
  color: #ccc;
  line-height: 1.6;
}

ul {
  list-style-type: none;
  padding: 0;
}

ul li {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: transform 0.12s, background 0.18s;
}

ul li:hover {
  transform: translateY(-3px);
  background: #222;
}

ul li a {
  color: #4dd0e1;
  text-decoration: none;
  font-weight: 500;
}

ul li a:hover {
  text-decoration: underline;
}

/* === iframe (если используется на главной) === */
.content-frame {
  width: 100%;
  height: calc(100vh - 120px);
  border: none;
  background: var(--surface);
  border-radius: 10px;
  display: block;
}

/* PDF iframe helper class for mobile */
.pdf {
  width: 100%;
  height: calc(100dvh - 120px);
  /* use dynamic viewport height where supported */
  min-height: 60dvh;
  border: none;
  background: var(--surface);
  overflow: auto;
}

/* === Адаптивность === */
@media screen and (max-width: 1024px) {

  /* tablet and below: collapse sidebar behavior */
  #main {
    margin-left: 0;
    padding: 14px;
  }

  .sidebar {
    padding-top: 48px;
  }

  .sidebar a {
    font-size: 15px;
  }

  .openbtn {
    font-size: 17px;
  }
}

@media screen and (max-width: 600px) {

  /* mobile tweaks */
  #main {
    padding: 12px;
  }

  #main h1 {
    font-size: 1.3rem;
  }

  ul li {
    padding: 10px;
  }

  .openbtn {
    padding: 8px 10px;
  }

  .sidebar {
    width: 240px;
  }
}

/* === FIX: закрывать sidebar на маленьких экранах === */
@media screen and (max-width: 768px) {
  .sidebar {
    width: 0 !important;
  }

  body.sidebar-open .sidebar {
    width: 250px !important;
  }

  body.sidebar-open #main {
    margin-left: 0 !important;
  }
}

/* === Back Button === */
.back-button {
  display: inline-block;
  margin-bottom: 20px;
  padding: 10px 15px;
  background-color: var(--surface);
  color: var(--accent);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
  border: 1px solid var(--surface-2);
}

.back-button:hover {
  background-color: var(--surface-2);
  color: #fff;
  border-color: var(--accent);
}