:root {
  --bg: #0b0f1a;
  --bg-accent: #0f1526;
  --surface: #141b2f;
  --surface-2: #1a223a;
  --border: #1e2742;
  --text: #f2f4f8;
  --text-muted: #b6c2d1;
  --text-soft: #94a3b8;
  --accent: #7aa2ff;
  --accent-2: #6ee7d8;
  --danger: #ff6b6b;
  --shadow: 0 10px 24px rgba(5, 10, 20, 0.45);
  --radius: 16px;
  --radius-sm: 12px;
  --sidebar-width: 320px;
  --transition: 220ms ease;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #151c32 0%, #0b0f1a 55%), var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow-x: hidden;
  width: 100%;
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

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

a:hover {
  color: #a4c3ff;
}

button, input, select, textarea {
  font-family: inherit;
}

/* Layout principale */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgba(11, 15, 26, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand-logo {
  max-height: 28px;
  width: auto;
  height: 24px;
  object-fit: contain;
  border-radius: unset !important;
}

.search-wrap {
  flex: 1;
  max-width: 600px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  border-color: rgba(122, 162, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.2);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.btn {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border var(--transition);
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: rgba(122, 162, 255, 0.4);
  color: var(--text);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(122, 162, 255, 0.2), rgba(110, 231, 216, 0.2));
  border-color: rgba(122, 162, 255, 0.4);
}

.btn-play {
  background: #f7c948;
  border-color: #f7c948;
  color: #1a1a1a;
  font-weight: 600;
}

.btn-play:hover {
  color: #1a1a1a;
}

.select {
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1.5rem;
  flex-shrink: 0;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(85vw, var(--sidebar-width));
  background: var(--bg-accent);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform var(--transition);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-body {
  overflow-y: auto;
  padding: 1rem;
}

.tree-group {
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.tree-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  cursor: pointer;
}

.tree-header h4 {
  margin: 0;
  font-size: 0.95rem;
}

.tree-content {
  padding: 0 0.75rem 0.75rem;
  display: none;
}

.tree-group.open .tree-content {
  display: block;
  animation: fadeIn 240ms ease;
}

.tree-item {
  padding: 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  word-wrap: break-word;
}

.tree-item a {
  color: inherit;
  word-wrap: break-word;
}

.tree-item a:hover {
  color: var(--text);
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 1035;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* Main content */
.layout {
  width: 100%;
  flex: 1;
}

.main {
  flex: 1;
  width: 100%;
}

/* Hero section */
.hero {
  padding: 1.5rem;
  border-radius: var(--radius);
  background: linear-gradient(130deg, rgba(122, 162, 255, 0.15), rgba(110, 231, 216, 0.08));
  border: 1px solid rgba(122, 162, 255, 0.2);
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
  word-wrap: break-word;
}

.hero p {
  margin: 0;
  color: var(--text-muted);
  word-wrap: break-word;
}

/* Section title */
.section-title h2 {
  margin: 0;
  font-size: 1.2rem;
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.mobile-search {
  display: block;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform var(--transition), border var(--transition);
  opacity: 0;
  transform: translateY(10px);
  cursor: pointer;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.card.show {
  opacity: 1;
  transform: translateY(0);
}

.card:hover {
  border-color: rgba(122, 162, 255, 0.4);
}

.card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  color: var(--bs-light);
}

.card p {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(122, 162, 255, 0.12);
  white-space: nowrap;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-soft);
}

/* Article */
.article {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  word-wrap: break-word;
  overflow-wrap: break-word;

}

.article h1 {
  margin-top: 0;
  font-size: 1.6rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.article .content {
  color: var(--text-muted);
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.article .content p {
  margin-top: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.article .content pre {
  background: #0a0f1c;
  padding: 1rem;
  border-radius: 12px;
  overflow-x: auto;
  border: 1px solid var(--border);
  max-width: 100%;
}

.article .content img,
.article .content iframe,
.article .content video {
  max-width: 100%;
  height: auto;
}

.article .content table {
  display: block;
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
}

/* Attachments */
.attachments {
  margin-top: 1rem;
  display: grid;
  gap: 0.5rem;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  word-wrap: break-word;
}

/* Footer */
.footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Notice */
.notice {
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.08);
  color: #ffd6d6;
}

/* Admin form */
.admin-form {
  display: grid;
  gap: 1rem;
}

.input, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  min-height: 44px;
}

textarea {
  min-height: 200px;
}

/* Animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Desktop styles */
@media (min-width: 900px) {
  .layout {
    display: flex;
    align-items: flex-start;
  }

  .search-wrap {
    display: flex;
  }

  .mobile-search {
    display: none;
  }

  .sidebar {
    position: sticky;
    top: 73px;
    height: calc(100vh - 73px);
    transform: translateX(0);
    z-index: 10;
    width: var(--sidebar-width);
    flex-shrink: 0;
  }

  .overlay, 
  .menu-btn {
    display: none;
  }

  .main {
    flex: 1;
    margin-left: 0;
  }
}

/* Mobile styles */
@media (max-width: 899px) {
  .search-wrap {
    display: none;
  }

  .topbar {
    padding: 0.75rem;
  }

  .brand-logo {
    max-width: 120px;
  }

  .btn-play {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }

  .menu-btn {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
}

/* Extra small devices */
@media (max-width: 375px) {
  .topbar {
    padding: 0.5rem;
  }
  
  .brand-logo {
    max-width: 100px;
    max-height: 22px;
  }

  .btn-play {
    padding: 0.5rem 0.625rem;
    font-size: 0.85rem;
  }
  
  .menu-btn {
    width: 36px;
    height: 36px;
    font-size: 1.125rem;
  }
  
  .hero {
    padding: 1rem;
  }
  
  .hero h1 {
    font-size: 1.4rem;
  }
  
  .card {
    padding: 1rem;
  }
  
  .article {
    padding: 1rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
