:root {
  --bg: #07080b;
  --panel: #10131a;
  --panel-2: #171b24;
  --panel-3: #202632;
  --text: #f3f5f7;
  --muted: #aeb7c6;
  --quiet: #737d8f;
  --line: #2b3240;
  --accent: #d5303d;
  --accent-2: #ffbf66;
  --good: #39c37d;
  --bad: #ee5c63;
  --focus: #7ab7ff;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(213, 48, 61, 0.16), transparent 34%),
    linear-gradient(180deg, #07080b 0%, #0c0f14 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(10, 12, 17, 0.94);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  font-size: 1.35rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
}

.nav-list,
.admin-list {
  display: grid;
  gap: 8px;
}

.nav-item,
.btn,
.chip,
.icon-btn {
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
}

.nav-item:hover,
.nav-item.active {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--line);
}

.nav-item i {
  width: 20px;
  color: var(--accent-2);
  text-align: center;
}

.session-card {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.session-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.main {
  min-width: 0;
  padding: 24px 28px 48px;
}

.topbar,
.section-heading,
.wiki-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  align-items: center;
  margin-bottom: 18px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 3vw, 3rem);
}

h2 {
  margin-bottom: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent-2);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-actions,
.button-row,
.hero-actions,
.card-actions,
.wiki-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions {
  justify-content: flex-end;
}

.search-box {
  width: min(360px, 40vw);
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border-radius: var(--radius);
  background: var(--panel);
  border-color: var(--line);
  font-weight: 700;
}

.btn:hover,
.chip:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

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

.btn.secondary {
  background: var(--accent-2);
  border-color: #ffd08c;
  color: #17110b;
}

.btn.danger {
  color: #ffc3c6;
  background: rgba(238, 92, 99, 0.14);
  border-color: rgba(238, 92, 99, 0.46);
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 191, 102, 0.38);
  border-radius: var(--radius);
  background: rgba(255, 191, 102, 0.1);
  color: #ffe2b7;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 420px);
  gap: 18px;
  min-height: 340px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(7, 8, 11, 0.7), rgba(7, 8, 11, 0.94)),
    url("https://images.unsplash.com/photo-1519608487953-e999c86e7455?auto=format&fit=crop&w=1800&q=80") center/cover;
  box-shadow: var(--shadow);
}

.hero-copy {
  align-self: end;
  max-width: 780px;
}

.hero-copy h2 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 1.02;
}

.hero-copy p:not(.eyebrow),
.page-card p,
.admin-card p,
.article-body,
.empty-state {
  color: var(--muted);
  line-height: 1.6;
}

.hero-stats {
  align-self: end;
  display: grid;
  gap: 10px;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(16, 19, 26, 0.88);
}

.stat span {
  color: var(--muted);
}

.stat strong {
  font-size: 1.5rem;
}

.section-heading {
  margin: 28px 0 14px;
}

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

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

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

.page-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.page-card,
.admin-card,
.dashboard-card,
.wiki-page,
.inline-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.page-card,
.admin-card,
.dashboard-card {
  padding: 18px;
}

.page-card {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-card h3 {
  margin-bottom: 0;
  font-size: 1.18rem;
}

.card-meta,
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-actions {
  margin-top: auto;
}

.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 0.78rem;
  font-weight: 700;
}

.pill.good {
  color: #a7f4c9;
  border-color: rgba(57, 195, 125, 0.38);
}

.pill.warn {
  color: #ffe0a8;
  border-color: rgba(255, 191, 102, 0.42);
}

.toolbar {
  margin-bottom: 14px;
}

.chip {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--panel);
  border-color: var(--line);
  color: var(--muted);
  font-weight: 700;
}

.chip.active {
  color: var(--text);
  background: var(--panel-3);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(16, 19, 26, 0.48);
}

.wiki-page,
.inline-editor {
  padding: 22px;
}

.inline-editor {
  display: grid;
  gap: 22px;
}

.wiki-header {
  margin-bottom: 18px;
}

.wiki-header h2 {
  font-size: clamp(2rem, 4vw, 3.6rem);
}

.wiki-header p:not(.eyebrow) {
  max-width: 820px;
  color: var(--muted);
  line-height: 1.6;
}

.wiki-header .update-line {
  margin-top: 8px;
  color: var(--quiet);
  font-size: 0.92rem;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  align-items: start;
  gap: 18px;
}

.article-summary,
.content-section {
  margin-bottom: 18px;
}

.article-summary {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.article-summary p:first-child {
  color: var(--text);
  font-size: 1.32rem;
  font-weight: 800;
  line-height: 1.45;
}

.content-section h3 {
  margin-bottom: 8px;
  color: var(--text);
}

.article-image {
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrap th,
.table-wrap td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table-wrap th {
  color: var(--text);
  background: var(--panel-2);
}

.table-wrap tr:last-child th,
.table-wrap tr:last-child td {
  border-bottom: 0;
}

.infobox {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 14px;
}

.infobox dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.infobox dt {
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.infobox dd {
  margin: 2px 0 0;
}

code {
  color: #ffd08c;
  overflow-wrap: anywhere;
}

.modal {
  width: min(620px, calc(100% - 26px));
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.modal-panel {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border-color: var(--line);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.info-fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.section-fieldset {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.section-fieldset legend {
  padding: 0 6px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.section-tools,
.section-editor-list {
  display: grid;
  gap: 10px;
}

.section-tools {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.section-editor {
  display: grid;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.section-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.visual-table-editor {
  display: grid;
  gap: 10px;
}

.table-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  opacity: 0.72;
  transition: opacity 0.16s ease;
}

.visual-table-editor:hover .table-toolbar,
.visual-table-editor:focus-within .table-toolbar {
  opacity: 1;
}

.visual-table-editor .table-wrap {
  overflow: visible;
}

.visual-table-editor table {
  table-layout: fixed;
}

.visual-table-editor td {
  position: relative;
  padding: 6px;
}

.visual-table-editor input {
  min-height: 38px;
}

.table-cell-editor {
  position: relative;
}

.table-col-remove,
.icon-btn.mini {
  width: 28px;
  height: 28px;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-3);
  color: var(--muted);
  cursor: pointer;
}

.table-col-remove {
  position: absolute;
  top: -17px;
  right: -13px;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.table-cell-editor:hover .table-col-remove,
.table-cell-editor:focus-within .table-col-remove {
  opacity: 1;
  transform: translateY(0);
}

.table-row-actions {
  width: 42px;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.visual-table-editor tr:hover .table-row-actions,
.visual-table-editor tr:focus-within .table-row-actions {
  opacity: 1;
}

.info-fieldset legend {
  padding: 0 6px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b0e13;
  color: var(--text);
  outline: 0;
}

input,
select {
  min-height: 42px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 11px;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(122, 183, 255, 0.13);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-hint {
  margin: -3px 0 0;
  color: var(--quiet);
  font-size: 0.86rem;
}

.split {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .topbar,
  .hero-panel,
  .article-layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .search-box {
    width: 100%;
  }
}

@media (max-width: 680px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .nav-list,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .wiki-header {
    display: grid;
  }

  .hero-panel,
  .wiki-page,
  .inline-editor {
    padding: 18px;
  }

  .modal-actions,
  .button-row,
  .hero-actions,
  .card-actions,
  .wiki-actions,
  .split {
    display: grid;
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
  }
}
