:root {
  --gold:          #C5A811;
  --gold-light:    #e0c435;
  --black:         #000000;
  --surface:       #0a0a0a;
  --surface-2:     #111111;
  --surface-3:     #1a1a1a;
  --border:        rgba(197,168,17,0.3);
  --border-bright: rgba(197,168,17,0.7);
  --text:          #e8e8e8;
  --text-muted:    #888888;
  --radius:        8px;
  --radius-lg:     16px;
  --broken-red:    #ff6b6b;
}

/* Base */
body,
#wiki-wrapper,
.wiki-base,
.container,
#article-container,
.wiki-article,
.wiki-content {
  background-color: var(--black) !important;
  color: var(--text) !important;
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  font-size: 1.05rem;
  line-height: 1.7;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Audiowide', sans-serif;
  color: #ffffff;
  letter-spacing: 0.03em;
}

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

a:hover {
  color: var(--gold-light) !important;
}

hr {
  border-color: var(--border) !important;
}

/* Scrollbar */
::-webkit-scrollbar { background: var(--surface-2); width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 4px; }

/* ---- NAVBAR ---- */
nav.navbar,
.navbar.navbar-dark,
.navbar-expand-lg {
  background-color: rgba(0,0,0,0.92) !important;
  border-bottom: 1px solid var(--border) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.navbar-brand,
.nav-link,
.dropdown-toggle,
.navbar-nav > li > a {
  color: var(--text-muted) !important;
  font-family: 'Audiowide', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.2s;
}

.navbar-brand:hover,
.nav-link:hover,
.dropdown-toggle:hover {
  color: var(--gold) !important;
}

.navbar-toggler {
  border: 1.5px solid var(--border-bright) !important;
  border-radius: var(--radius) !important;
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28197%2C168%2C17%2C1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* ---- DROPDOWNS ---- */
.dropdown-menu {
  background-color: var(--surface-2) !important;
  border: 1px solid var(--border-bright) !important;
  border-radius: var(--radius) !important;
  padding: 0.4rem !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}

.dropdown-item {
  color: var(--text-muted) !important;
  font-family: 'Audiowide', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.dropdown-item:hover {
  background-color: rgba(197,168,17,0.12) !important;
  color: var(--gold) !important;
}

/* ---- SEARCH ---- */
.input-group .form-control,
.directory-toolbar input[type="search"],
.form-control {
  background-color: var(--surface-2) !important;
  border: 1.5px solid var(--border-bright) !important;
  color: var(--text) !important;
  border-radius: var(--radius) !important;
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 3px rgba(197,168,17,0.15) !important;
  background-color: var(--surface-3) !important;
  outline: none;
}

.form-control::placeholder { color: var(--text-muted) !important; }

/* ---- BUTTONS ---- */
.btn {
  font-family: 'Audiowide', sans-serif !important;
  font-size: 0.72rem !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius) !important;
  padding: 0.45rem 1.2rem !important;
  transition: all 0.2s !important;
  background-color: transparent !important;
  color: var(--gold) !important;
  border: 1.5px solid var(--gold) !important;
}

.btn:hover {
  background-color: var(--gold-light) !important;
  color: var(--black) !important;
  border-color: var(--gold-light) !important;
  box-shadow: 0 0 16px rgba(197,168,17,0.25) !important;
  transform: translateY(-1px);
}

.btn-outline-light {
  border-color: var(--border-bright) !important;
  color: var(--gold) !important;
}

/* ---- ARTICLE MENU / NAV PILLS ---- */
#article-menu,
.nav-pills {
  background-color: var(--surface-2) !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.5rem;
}

#article-menu .nav-link {
  color: var(--text-muted) !important;
  font-family: 'Audiowide', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  transition: background 0.2s, color 0.2s;
}

#article-menu .nav-link:hover {
  color: var(--gold) !important;
  background-color: rgba(197,168,17,0.08);
}

#article-menu .nav-link.active {
  color: var(--gold) !important;
  background-color: rgba(197,168,17,0.14) !important;
}

/* ---- BREADCRUMBS ---- */
.breadcrumb {
  background-color: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  padding: 0.6rem 1rem !important;
  margin-bottom: 1.5rem;
}

.breadcrumb-item a { color: var(--gold) !important; }
.breadcrumb-item.active { color: var(--text-muted) !important; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--border-bright) !important; }

/* ---- PAGE HEADER ---- */
.page-header,
h1.page-header {
  color: #ffffff !important;
  border-bottom: 1px solid var(--border) !important;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}

/* ---- FORMS (create/edit articles) ---- */
.form-horizontal,
.form-group,
.row.form-group {
  background-color: transparent !important;
}

label,
.wiki-label label,
.control-label {
  font-family: 'Audiowide', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted) !important;
  margin-bottom: 0.35rem;
  display: block;
  font-weight: normal !important;
}

.wiki-control input[type="text"],
.wiki-control textarea,
.wiki-control select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
  background-color: var(--surface-2) !important;
  border: 1.5px solid var(--border-bright) !important;
  color: var(--text) !important;
  border-radius: var(--radius) !important;
  padding: 0.5rem 0.85rem !important;
  font-family: 'Rajdhani', sans-serif !important;
  font-size: 1rem !important;
  transition: border-color 0.2s, box-shadow 0.2s !important;
  outline: none !important;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 3px rgba(197,168,17,0.15) !important;
  background-color: var(--surface-3) !important;
}

.form-text.text-muted,
#hint_id_slug,
#hint_id_summary {
  color: var(--text-muted) !important;
  font-size: 0.85rem;
}

/* Form actions bar */
.form-actions,
.form-group.form-actions {
  background-color: var(--surface-2) !important;
  border-top: 1px solid var(--border) !important;
  padding: 1rem 0;
}

/* ---- MARKITUP EDITOR ---- */
.markItUp {
  background-color: var(--surface-2) !important;
  border: 1.5px solid var(--border-bright) !important;
  color: var(--text) !important;
  font-family: 'Space Mono', monospace;
}

.markItUpHeader {
  background-color: var(--surface-3) !important;
  border-bottom: 1px solid var(--border) !important;
}

.markItUpHeader a {
  color: var(--gold) !important;
}

/* ---- CARDS ---- */
.card {
  background-color: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  color: var(--text) !important;
}

.card-title { color: #ffffff !important; }
.wiki-card-toggle { color: var(--text) !important; }

/* ---- TABLES ---- */
.table th {
  background-color: var(--surface-3) !important;
  color: var(--gold) !important;
  font-family: 'Audiowide', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border) !important;
}

.table td {
  color: var(--text) !important;
  border-color: rgba(197,168,17,0.1) !important;
}

.table tbody tr:hover {
  background-color: rgba(197,168,17,0.05) !important;
}

.table, .wiki-article table {
  color: white;
}

/* ---- CODE BLOCKS ---- */
pre, code {
  background-color: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  color: var(--gold-light) !important;
  font-family: 'Space Mono', monospace !important;
  font-size: 0.88rem;
}

pre { padding: 1rem; overflow-x: auto; }

/* ---- DIRECTORY TOOLBAR ---- */
.directory-toolbar,
.form-search,
.directory-toolbar .form-inline {
  background-color: var(--surface-2) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 0.75rem 0;
}

/* ---- BADGES / NOTIFICATIONS ---- */
.badge-light, .badge {
  background-color: rgba(197,168,17,0.2) !important;
  color: var(--gold) !important;
  font-family: 'Audiowide', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
}

/* ---- ALERTS ---- */
.alert {
  border-radius: var(--radius) !important;
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
}

.alert-success {
  background-color: rgba(68,204,119,0.12) !important;
  border-color: rgba(68,204,119,0.4) !important;
  color: #44cc77 !important;
}

.alert-danger {
  background-color: rgba(255,68,68,0.12) !important;
  border-color: rgba(255,68,68,0.4) !important;
  color: #ff6666 !important;
}

.alert-info {
  background-color: rgba(100,160,255,0.1) !important;
  border-color: rgba(100,160,255,0.3) !important;
  color: #88bbff !important;
}

/* ---- WIKI FOOTER ---- */
#wiki-footer {
  color: var(--text-muted) !important;
  border-top: 1px solid var(--border) !important;
  margin-top: 3rem;
  padding-top: 1rem;
}

/* ---- SELECT2 (tag selectors) ---- */
.select2-container--default .select2-selection--multiple,
.select2-container--default .select2-selection--single {
  background-color: var(--surface-2) !important;
  border: 1.5px solid var(--border-bright) !important;
  border-radius: var(--radius) !important;
  color: var(--text) !important;
}

.select2-container--default .select2-results__option--highlighted {
  background-color: rgba(197,168,17,0.18) !important;
  color: var(--gold) !important;
}

.select2-dropdown {
  background-color: var(--surface-2) !important;
  border: 1px solid var(--border-bright) !important;
  border-radius: var(--radius) !important;
}

.select2-results__option { color: var(--text) !important; }

/* ---- CONTAINER SPACING ---- */
.container[style*="margin-top"] {
  margin-top: 1.5rem !important;
}

.navbar .dropdown-menu {
  z-index: 1040 !important;
  position: absolute !important;
}

#article-menu {
  position: relative;
}

#article-menu .dropdown-menu {
  z-index: 1025 !important;
}

.modal-backdrop,
.modal-backdrop.show {
  background-color: #000 !important;
  z-index: -1 !important;
}

.modal {
  z-index: 1060 !important;
}

.modal-dialog {
  margin-top: 4rem;
}

.modal-content {
  background-color: var(--surface-2) !important;
  border: 1px solid var(--border-bright) !important;
  border-radius: var(--radius-lg) !important;
  color: var(--text) !important;
  box-shadow: 0 25px 80px rgba(0,0,0,0.7),
              0 0 24px rgba(197,168,17,0.18) !important;
}

.modal-header {
  border-bottom: 1px solid var(--border) !important;
  padding: 1rem 1.5rem !important;
  background-color: var(--surface-3) !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}

.modal-header .modal-title,
.modal-title {
  font-family: 'Audiowide', sans-serif !important;
  font-size: 0.95rem !important;
  letter-spacing: 0.05em !important;
  color: #fff !important;
  text-transform: uppercase;
}

.modal-header .close,
.modal-header button.close {
  color: var(--text-muted) !important;
  text-shadow: none !important;
  opacity: 0.8;
  background: transparent;
  border: none;
  font-size: 1.5rem;
}

.modal-header .close:hover { color: var(--gold) !important; opacity: 1; }

.modal-body {
  background-color: var(--surface-2) !important;
  color: var(--text) !important;
  padding: 1.25rem 1.5rem !important;
  font-family: 'Rajdhani', sans-serif;
  max-height: 70vh;
  overflow-y: auto;
}

/* Markdown-rendered preview content inside the modal */
.modal-body h1,
.modal-body h2,
.modal-body h3,
.modal-body h4,
.modal-body h5,
.modal-body h6 {
  color: #fff !important;
  font-family: 'Audiowide', sans-serif;
}

.modal-body a { color: var(--gold) !important; }
.modal-body a:hover { color: var(--gold-light) !important; }

.modal-body pre,
.modal-body code {
  background-color: var(--surface-3) !important;
  border: 1px solid var(--border) !important;
  color: var(--gold-light) !important;
  font-family: 'Space Mono', monospace !important;
}

.modal-body table {
  background-color: var(--surface-2) !important;
  color: var(--text) !important;
}
.modal-body table th {
  background-color: var(--surface-3) !important;
  color: var(--gold) !important;
}
.modal-body table td,
.modal-body table th {
  border-color: var(--border) !important;
}

.modal-footer {
  background-color: var(--surface-3) !important;
  border-top: 1px solid var(--border) !important;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
  padding: 0.75rem 1.5rem !important;
}

.wiki-article a.wiki-broken,
.wiki-article a.wiki-broken:hover,
.modal-body a.wiki-broken,
.modal-body a.wiki-broken:hover,
a.wiki-broken,
a.wiki-broken:hover,
a.wiki-broken:visited {
  color: var(--broken-red) !important;
  text-decoration: underline dashed var(--broken-red) !important;
  text-underline-offset: 3px;
  font-style: italic;
}
.wiki-article a.wiki-broken::after,
a.wiki-broken::after {
  content: " ?";
  font-style: normal;
  font-weight: 700;
  opacity: 0.7;
}

@media (max-width: 767.98px) {

  /* Tighten the page container so we keep more horizontal room. */
  .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Top navbar: brand label can squeeze the search field off-screen. */
  nav.navbar .navbar-brand span {
    font-size: 0.62rem !important;
    letter-spacing: 0.08em !important;
  }
  nav.navbar .form-inline {
    width: 100%;
    margin-top: 0.5rem;
  }
  nav.navbar .form-inline .input-group {
    width: 100%;
  }

  /* ---- Article header (title + tabs) ---- */
  #article-container {
    overflow: visible;
  }
  #article-menu.navbar {
    flex-direction: column;
    align-items: stretch !important;
    padding: 0.5rem 0.5rem 0.25rem !important;
    /* Override the bootstrap navbar-expand-md flex behaviour. */
    flex-wrap: wrap;
  }
  #article-menu .navbar-nav {
    width: 100% !important;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start !important;
    margin: 0;
  }
  #article-menu #article-title-li {
    width: 100%;
    float: none !important;
    margin-bottom: 0.5rem;
  }
  #article-menu #article-title {
    font-size: 1.4rem;
    line-height: 1.25;
    margin: 0;
    word-break: break-word;
  }
  #article-menu #article-title small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem !important;
  }
  /* Tabs row: let it scroll horizontally instead of clipping. */
  #article-menu ul.justify-content-end {
    justify-content: flex-start !important;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Hide the scroll bar but keep scrollability. */
    scrollbar-width: none;
  }
  #article-menu ul.justify-content-end::-webkit-scrollbar {
    display: none;
  }
  #article-menu .nav-item {
    flex-shrink: 0;
  }
  #article-menu .nav-link {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.62rem !important;
  }

  #article-menu .hidden-xs {
    display: none !important;
  }

  /* ---- Breadcrumbs ---- */
  #article-breadcrumbs.row {
    flex-direction: column;
    align-items: stretch;
    margin-left: 0;
    margin-right: 0;
  }
  #article-breadcrumbs .breadcrumb {
    flex-wrap: wrap;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem !important;
  }
  #article-breadcrumbs .btn-group {
    margin-left: 0 !important;
    margin-top: 0.5rem;
    align-self: flex-start;
  }

  /* ---- Directory toolbar (Up one level / Add article + filter) ---- */
  .directory-toolbar .btn-group {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .directory-toolbar .float-right {
    float: none !important;
    margin-top: 0.75rem;
    width: 100%;
  }
  .directory-toolbar .float-right input {
    width: 100%;
  }

  /* ---- Tables: make them scroll instead of breaking the layout ---- */
  .wiki-article table,
  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* ---- History page: revision rows stack action button under title ---- */
  .card .card-body .float-right {
    float: none !important;
    margin-top: 0.5rem !important;
    margin-left: 0 !important;
    display: block;
  }

  /* ---- Forms (edit/create): generous tap targets ---- */
  .btn {
    padding: 0.55rem 1rem !important;
  }

  /* ---- Footer ---- */
  #wiki-footer {
    font-size: 0.85rem;
    text-align: left;
  }
  #wiki-footer img {
    float: none !important;
    margin-top: 0.5rem;
  }
}

/* Mobile-friendly modal sizing */
@media (max-width: 575.98px) {
  .modal-dialog {
    margin: 0.75rem;
    max-width: calc(100% - 1.5rem);
  }
  .modal-body { max-height: 75vh; }
}
