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

:root {
  --primary: #2c3e50;
  --primary-light: #34495e;
  --accent: #c8a45c;
  --accent-hover: #b8943c;
  --bg: #faf8f5;
  --bg-sidebar: #f0ece6;
  --bg-card: #fff;
  --text: #333;
  --text-light: #666;
  --border: #ddd;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --radius: 6px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Header */
header {
  background: var(--primary);
  color: #fff;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-left h1 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

#sidebar-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  display: none;
}

#sidebar-toggle:hover {
  background: rgba(255,255,255,0.1);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-right .user-info {
  font-size: 0.85rem;
  opacity: 0.9;
}

.header-right .btn {
  font-size: 0.8rem;
  padding: 5px 14px;
}

/* Container */
.container {
  display: flex;
  margin-top: 56px;
  min-height: calc(100vh - 56px);
}

/* Sidebar */
#sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  height: calc(100vh - 56px);
  position: sticky;
  top: 56px;
  padding: 0.75rem 0;
}

.topic-item {
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  font-size: 0.88rem;
  line-height: 1.4;
}

.topic-item:hover {
  background: rgba(0,0,0,0.04);
}

.topic-item.active {
  background: rgba(200, 164, 92, 0.12);
  border-left-color: var(--accent);
  font-weight: 500;
}

.topic-item .topic-num {
  font-weight: 700;
  color: var(--primary);
  margin-right: 0.3rem;
}

/* Main */
#content-area {
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 900px;
  min-width: 0;
}

/* Welcome */
.welcome {
  text-align: center;
  padding: 3rem 1rem;
}

.welcome h2 {
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.welcome p {
  color: var(--text-light);
  margin-bottom: 2rem;
}

.welcome-info {
  text-align: left;
  max-width: 400px;
  margin: 0 auto;
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.welcome-info h3 {
  margin-bottom: 0.75rem;
  color: var(--primary);
  font-size: 1rem;
}

.welcome-info ul {
  list-style: none;
  padding: 0;
}

.welcome-info li {
  padding: 0.3rem 0;
  font-size: 0.9rem;
}

/* Topic header */
.topic-header {
  margin-bottom: 1.5rem;
}

.topic-header h2 {
  color: var(--primary);
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.subtitle {
  color: var(--text-light);
  font-size: 0.95rem;
  font-style: italic;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* Part tabs */
.part-tabs {
  display: flex;
  gap: 2px;
}

.part-tab {
  padding: 6px 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.15s;
}

.part-tab:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.part-tab:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.part-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.part-tab:hover:not(.active) {
  background: #eee;
}

/* Version select */
.version-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.version-select label {
  color: var(--text-light);
}

.version-select select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--bg-card);
}

/* Level tabs */
.level-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 0.5rem;
}

.level-tab {
  padding: 8px 16px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all 0.15s;
  position: relative;
}

.level-tab:hover:not(.active) {
  border-color: var(--accent);
  background: rgba(200, 164, 92, 0.05);
}

.level-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.level-tab[data-level="1"]::after { content: "~½ oldal"; }
.level-tab[data-level="2"]::after { content: "~1 oldal"; }
.level-tab[data-level="3"]::after { content: "~1½ oldal"; }
.level-tab[data-level="4"]::after { content: "~2 oldal"; }

.level-tab::after {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.7;
  margin-top: 1px;
}

.level-info {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* Content */
.content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  line-height: 1.8;
  font-size: 0.95rem;
}

.content h1, .content h2, .content h3, .content h4 {
  color: var(--primary);
  margin: 1.2rem 0 0.5rem;
}

.content h1:first-child, .content h2:first-child, .content h3:first-child {
  margin-top: 0;
}

.content h2 { font-size: 1.2rem; }
.content h3 { font-size: 1.05rem; }

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

.content ul, .content ol {
  margin: 0.5rem 0 1rem 1.5rem;
}

.content li {
  margin-bottom: 0.3rem;
}

.content strong {
  color: var(--primary);
}

.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: rgba(200, 164, 92, 0.06);
  font-style: italic;
}

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.content code {
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
}

/* References */
.references {
  margin-top: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 2rem;
}

.references h3 {
  color: var(--primary);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.references ul {
  list-style: none;
  padding: 0;
}

.references li {
  font-size: 0.85rem;
  color: var(--text-light);
  padding: 0.2rem 0;
  padding-left: 1rem;
  text-indent: -1rem;
}

.references li::before {
  content: "\2022 ";
  color: var(--accent);
}

/* Suggestion area */
#suggestion-area {
  margin-top: 1rem;
  text-align: right;
}

/* Buttons */
.btn {
  padding: 7px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.btn:hover {
  background: #eee;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-light);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-suggest {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-suggest:hover {
  background: var(--accent-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-small {
  padding: 4px 10px;
  font-size: 0.78rem;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 2rem;
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-large {
  max-width: 700px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-content h3 {
  margin-bottom: 1rem;
  color: var(--primary);
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.modal-content input[type="text"],
.modal-content input[type="password"],
.modal-content textarea,
.modal-content select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
}

.modal-content textarea {
  resize: vertical;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}

.modal-content input + input,
.modal-content input + select {
  margin-top: 0.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: var(--text-light);
}

.modal-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Admin */
.admin-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 1.5rem;
}

.admin-tab {
  padding: 8px 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.15s;
}

.admin-tab:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.admin-tab:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.admin-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.add-user-form {
  background: var(--bg);
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.add-user-form h4 {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.add-user-form input,
.add-user-form select {
  margin-bottom: 0.5rem;
}

.add-user-form button {
  margin-top: 0.25rem;
}

.user-row, .suggestion-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.user-row:last-child, .suggestion-row:last-child {
  border-bottom: none;
}

.user-role {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: #eee;
}

.user-role.admin {
  background: var(--accent);
  color: #fff;
}

.suggestion-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 0;
}

.suggestion-meta {
  font-size: 0.8rem;
  color: var(--text-light);
}

.suggestion-actions {
  display: flex;
  gap: 0.5rem;
}

.suggestion-status {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.suggestion-status.pending { background: #fff3cd; color: #856404; }
.suggestion-status.approved { background: #d4edda; color: #155724; }
.suggestion-status.rejected { background: #f8d7da; color: #721c24; }

/* Loading */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 0.5rem;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
  #sidebar-toggle {
    display: block;
  }

  #sidebar {
    position: fixed;
    left: -280px;
    top: 56px;
    z-index: 50;
    transition: left 0.3s;
    box-shadow: none;
  }

  #sidebar.open {
    left: 0;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }

  #content-area {
    padding: 1rem;
  }

  .controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .content {
    padding: 1.25rem;
  }

  .level-tabs {
    flex-wrap: wrap;
  }

  .modal-content {
    width: 95%;
    padding: 1.5rem;
  }
}

/* Scrollbar */
#sidebar::-webkit-scrollbar {
  width: 6px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

/* Print */
@media print {
  header, #sidebar, .controls, .level-tabs, #suggestion-area, .modal {
    display: none !important;
  }

  .container { display: block; }

  #content-area {
    padding: 0;
    max-width: none;
  }

  .content {
    border: none;
    padding: 0;
    box-shadow: none;
  }
}
