/* ============================
   Командорские острова — Ocean Theme
   ============================ */

:root {
  --color-deep-teal: #0d5e6e;
  --color-teal: #1a8a9c;
  --color-teal-light: #e0f0f2;
  --color-coral: #e88d67;
  --color-coral-light: #fdf0e8;
  --color-bg: #faf8f4;
  --color-white: #ffffff;
  --color-text: #2c3e50;
  --color-text-light: #6b7a80;
  --color-border: #dce4e4;
  --color-sand: #e8d5c0;

  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --max-width: 800px;
  --max-width-wide: 1000px;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

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

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-teal);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-deep-teal);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.container-wide {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 20px;
}

/* ============================
   Header
   ============================ */

.site-header {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 20px;
}

.logo {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--color-deep-teal);
  white-space: nowrap;
}

.logo:hover {
  color: var(--color-teal);
}

.main-nav {
  display: flex;
  gap: 8px;
}

.main-nav a {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--color-text-light);
  transition: all 0.2s;
}

.main-nav a:hover {
  background: var(--color-teal-light);
  color: var(--color-deep-teal);
}

/* ============================
   Main Content
   ============================ */

.main-content {
  flex: 1;
  padding: 40px 0 60px;
}

/* ============================
   Footer
   ============================ */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 24px 0;
  color: var(--color-text-light);
  font-size: 0.8rem;
  text-align: center;
}

/* ============================
   Typography
   ============================ */

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  color: var(--color-deep-teal);
  line-height: 1.3;
}

h1 { font-size: 2rem; margin-bottom: 1rem; }
h2 { font-size: 1.5rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }

p {
  margin-bottom: 1.2rem;
}

.content {
  font-size: 1rem;
  line-height: 1.8;
}

.content p {
  margin-bottom: 1.2rem;
}

.content img {
  margin: 1.5rem auto;
  border-radius: var(--radius);
}

/* ============================
   Buttons
   ============================ */

.btn {
  display: inline-block;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--color-deep-teal);
  color: var(--color-white);
}

.btn-primary:hover {
  background: var(--color-teal);
  color: var(--color-white);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-teal);
  color: var(--color-teal);
}

.btn-outline:hover {
  background: var(--color-teal);
  color: var(--color-white);
}

/* ============================
   Cards
   ============================ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.card-image {
  aspect-ratio: 3/2;
  overflow: hidden;
  background: var(--color-teal-light);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 16px 20px 20px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.card-text {
  color: var(--color-text-light);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ============================
   Homepage
   ============================ */

.hero {
  text-align: center;
  padding: 60px 0 40px;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.hero p {
  font-size: 1.1rem;
  color: var(--color-text-light);
  max-width: 600px;
  margin: 0 auto;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--color-deep-teal);
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-teal-light);
}

/* ============================
   Book Page
   ============================ */

.book-info {
  max-width: var(--max-width);
  margin: 0 auto;
}

.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--color-text-light);
  margin-bottom: 20px;
}

.back-link:hover {
  color: var(--color-teal);
}

.book-cover {
  margin: 24px 0;
  text-align: center;
}

.book-cover img {
  max-height: 70vh;
  margin: 0 auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.book-meta {
  color: var(--color-text-light);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.book-actions {
  margin: 24px 0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================
   Book Reader
   ============================ */

.book-reader .site-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
}

.book-reader .main-content {
  padding: 20px 0 40px;
}

.book-page-image {
  text-align: center;
  margin-bottom: 24px;
}

.book-page-image img {
  max-width: 100%;
  margin: 0 auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.book-page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  transition: all 0.2s;
}

.nav-btn:hover {
  background: var(--color-teal-light);
  border-color: var(--color-teal);
  color: var(--color-deep-teal);
}

.nav-btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.page-num {
  font-size: 0.8rem;
  color: var(--color-text-light);
  padding: 0 8px;
  min-width: 80px;
  text-align: center;
}

/* ============================
   Photo View
   ============================ */

.photo-view {
  text-align: center;
}

.photo-view img {
  max-height: 80vh;
  margin: 0 auto 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.photo-caption {
  color: var(--color-text-light);
  font-size: 0.9rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ============================
   Admin
   ============================ */

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

.admin-sidebar {
  width: 220px;
  background: var(--color-deep-teal);
  color: var(--color-white);
  padding: 20px 0;
  flex-shrink: 0;
}

.admin-sidebar a {
  display: block;
  padding: 10px 20px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-white);
}

.admin-sidebar .logo {
  color: var(--color-white);
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 12px;
  display: block;
}

.admin-main {
  flex: 1;
  padding: 32px;
  background: var(--color-bg);
  min-width: 0;
}

.admin-main h1 {
  margin-bottom: 24px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.admin-table th,
.admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
}

.admin-table th {
  background: var(--color-teal-light);
  font-weight: 600;
  color: var(--color-deep-teal);
}

.admin-table tr:hover td {
  background: var(--color-coral-light);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-deep-teal);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(26, 138, 156, 0.1);
}

textarea.form-control {
  min-height: 300px;
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
}

.login-form {
  background: var(--color-white);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
}

.login-form h1 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 1.5rem;
}

.login-form .form-control {
  background: var(--color-bg);
}

/* ============================
   Responsive
   ============================ */

@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  .site-header .container {
    height: auto;
    padding: 12px 16px;
    flex-direction: column;
    gap: 8px;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .book-page-nav {
    gap: 8px;
  }

  .nav-btn {
    font-size: 0.8rem;
    padding: 8px 12px;
  }

  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    padding: 12px 0;
  }

  .admin-sidebar .logo {
    display: inline-block;
    border-bottom: none;
    padding: 0 16px 8px;
  }

  .admin-sidebar a {
    display: inline-block;
    padding: 6px 12px;
  }

  .admin-main {
    padding: 20px;
  }

  .admin-table {
    font-size: 0.8rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 8px 10px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .book-cover img {
    max-height: 50vh;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 40px 0 24px;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .main-content {
    padding: 24px 0 40px;
  }
}
