/* ========== Переменные тем ========== */
:root.light {
  --bg-page: #f5f7fa;
  --bg-card: #ffffff;
  --fg-text: #333333;
  --fg-muted: #666666;
  --btn-bg: #3366ff;
  --btn-hover: #274db3;
  --shadow-light: rgba(0,0,0,0.1);
  --toast-success-bg: #4caf50;
  --toast-error-bg: #f44336;
}
:root.dark {
  --bg-page: #1e1e1e;
  --bg-card: #2a2a2a;
  --fg-text: #f0f0f0;
  --fg-muted: #aaaaaa;
  --btn-bg: #5a8dff;
  --btn-hover: #3f66cc;
  --shadow-light: rgba(0,0,0,0.5);
  --toast-success-bg: #388e3c;
  --toast-error-bg: #c62828;
}

* {
  box-sizing: border-box;
  margin: 0; padding: 0;
}
html, body {
  height: 100%;
}
body {
  font-family: 'Roboto', sans-serif;
  background: var(--bg-page);
  color: var(--fg-text);
  line-height: 1.6;
}

/* Центрируем контент с max-width */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}

/* Заголовок */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}
header h1 {
  font-weight: 500;
  font-size: 1.75rem;
}
#theme-toggle {
  font-size: 1.25rem;
  background: transparent;
  border: 2px solid var(--fg-muted);
  border-radius: 50%;
  width: 2.5rem; height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}
#theme-toggle:hover {
  background: var(--btn-bg);
  color: #fff;
  border-color: var(--btn-bg);
}

/* Карточки-секции */
.card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow-light);
  margin-bottom: 2rem;
}

/* Кнопки */
button {
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  background: var(--btn-bg);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  transition: background 0.3s, box-shadow 0.3s;
}
button:hover:not(#theme-toggle) {
  background: var(--btn-hover);
  box-shadow: 0 2px 8px var(--shadow-light);
}

/* Форма */
form .form-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}
form label {
  margin-bottom: 0.25rem;
  color: var(--fg-muted);
}
form input {
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  transition: border-color 0.3s;
}
form input:focus {
  border-color: var(--btn-bg);
  outline: none;
}

/* Loader */
.loader {
  display: none;
  margin: 1rem auto;
  width: 40px; height: 40px;
  border: 4px solid #ddd;
  border-top-color: var(--btn-bg);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty message */
.empty-message {
  display: none;
  text-align: center;
  color: var(--fg-muted);
  font-style: italic;
  margin-top: 1rem;
}

/* Галерея */
.gallery-controls {
  text-align: right;
  margin-bottom: 1rem;
}
.grid-container {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.card .card-img {
  width: 100%;
  height: 0;
  padding-bottom: 75%;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #e0e0e0;
}
.card .card-img img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}
.card .card-img:hover img {
  transform: scale(1.05);
}
.card .card-desc {
  padding-top: 0.5rem;
  color: var(--fg-text);
  font-size: 0.95rem;
}

/* Toasts */
#toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}
.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 220px;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  color: #fff;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.success { background: var(--toast-success-bg); }
.toast.error   { background: var(--toast-error-bg); }
.toast button {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: #fff;
  line-height: 1;
  cursor: pointer;
}