:root {
  --bg: #0f172a;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #2563eb;
  --accent-2: #4f46e5;
  --danger: #ef4444;
  --border: #1f2937;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}

.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.topbar .left-group, .topbar .right-group { display: flex; align-items: center; gap: 10px; }

button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.08s ease-in-out, filter 0.2s ease;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }

.section {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 16px;
}

h1, h3 { margin-top: 0; }

.form {
  display: grid;
  gap: 12px;
  max-width: 420px;
  background: var(--panel);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
label { display: grid; gap: 6px; }
input[type="text"], input[type="password"] {
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  outline: none;
}
input::placeholder { color: var(--muted); }

.message { margin-top: 10px; color: var(--muted); }
.message.error { color: var(--danger); }

/* Центрирование главного меню */
.menu-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 20vh;
}

.menu-container h1 {
  margin-bottom: 32px;
  font-size: 2.5rem;
  font-weight: 700;
}

.menu-buttons { 
  display: flex; 
  gap: 16px; 
  flex-wrap: wrap;
  justify-content: center;
}

.menu-buttons button {
  padding: 16px 24px;
  font-size: 1.1rem;
  min-width: 200px;
}

.viewer {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  height: calc(100vh - 120px);
}
@media (max-width: 900px) {
  .viewer { 
    grid-template-columns: 1fr; 
    height: auto;
  }
}

.tags-panel {
  background: var(--panel);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 100%;
  overflow: auto;
}
.tags-panel ul { list-style: none; padding: 0; margin: 0; }
.tags-panel li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px dashed var(--border);
}
.tags-panel li .tag { color: var(--text); }
.tags-panel li .prob { color: var(--muted); }

.image-panel {
  display: grid;
  gap: 12px;
  grid-template-rows: 1fr auto;
  height: 100%;
}

.image-wrapper {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}

#mainImage {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Стили для навигационных кнопок с стрелками */
.nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 5;
  backdrop-filter: blur(4px);
}

.nav-button:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: translateY(-50%) scale(1.1);
}

.nav-button:active {
  transform: translateY(-50%) scale(0.95);
}

.nav-button-left {
  left: 16px;
}

.nav-button-right {
  right: 16px;
}

.nav-button svg {
  width: 24px;
  height: 24px;
}

/* Скрываем кнопки на мобильных устройствах для избежания случайных нажатий */
@media (max-width: 768px) {
  .nav-button {
    width: 40px;
    height: 40px;
  }
  
  .nav-button svg {
    width: 20px;
    height: 20px;
  }
  
  .nav-button-left {
    left: 8px;
  }
  
  .nav-button-right {
    right: 8px;
  }
}

#searchInput {
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 240px;
}

/* Центрирование формы входа */
#loginSection {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  min-height: 100vh;
  margin: 0 auto;
  padding-top: 15vh;
}

#loginSection h1 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 2rem;
  font-weight: 700;
}

#loginSection .form {
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Стили для сообщений в форме входа */
#loginSection .message {
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.error-button {
  margin-top: 15px;
  width: 100%;
  padding: 10px;
  background-color: #ff4444;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
}

.error-button:hover {
  background-color: #cc3333;
}

.error-button:disabled {
  background-color: #999;
  cursor: not-allowed;
}