:root {
  --bg: #060606;
  --page-glow: #171717;
  --panel: #101010;
  --panel-2: #141414;
  --text: #b9b9b9;
  --muted: #7d7d7d;
  --accent: #f5c542;
  --accent-strong: #ffd966;
  --border: #232323;
  --shell-max-width: 1480px;
  --page-padding: 24px;
  --card-radius: 18px;
  --card-padding: 28px;
  --control-radius: 999px;
  --input-radius: 10px;
  --surface-opacity: 0.95;
  --shadow-strength: 0.35;
  --rail-width: 290px;
}

body[data-layout-theme="aurora"] {
  --bg: #060606;
  --page-glow: #171717;
  --panel: #101010;
  --panel-2: #141414;
  --text: #b9b9b9;
  --muted: #7d7d7d;
  --accent: #f5c542;
  --accent-strong: #ffd966;
  --border: #232323;
  --shell-max-width: 1480px;
  --page-padding: 24px;
  --card-radius: 18px;
  --card-padding: 28px;
  --control-radius: 999px;
  --input-radius: 10px;
  --surface-opacity: 0.95;
  --shadow-strength: 0.35;
  --rail-width: 290px;
}

body[data-layout-theme="graphite"] {
  --bg: #05070a;
  --page-glow: #101722;
  --panel: #0e1218;
  --panel-2: #151b24;
  --text: #d5dde7;
  --muted: #8c98a6;
  --accent: #79d6ff;
  --accent-strong: #b7ecff;
  --border: #233244;
  --shell-max-width: 1540px;
  --page-padding: 20px;
  --card-radius: 14px;
  --card-padding: 24px;
  --control-radius: 12px;
  --input-radius: 12px;
  --surface-opacity: 0.92;
  --shadow-strength: 0.28;
  --rail-width: 276px;
}

body[data-layout-theme="signal"] {
  --bg: #07110b;
  --page-glow: #17331f;
  --panel: #0f1712;
  --panel-2: #16231a;
  --text: #d5eed7;
  --muted: #8ea695;
  --accent: #7cff6b;
  --accent-strong: #bcffb3;
  --border: #23402b;
  --shell-max-width: 1520px;
  --page-padding: 26px;
  --card-radius: 22px;
  --card-padding: 30px;
  --control-radius: 18px;
  --input-radius: 14px;
  --surface-opacity: 0.93;
  --shadow-strength: 0.32;
  --rail-width: 304px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
  padding: var(--page-padding);
  background:
    radial-gradient(circle at top, var(--page-glow), var(--bg));
}

body:not([data-layout-mode="sidebar-left"]):not([data-layout-mode="sidebar-right"]) .page-shell {
  width: min(var(--shell-max-width), calc(100vw - (var(--page-padding) * 2)));
  margin: 0 auto;
}

body[data-layout-mode="sidebar-left"] .page-shell,
body[data-layout-mode="sidebar-right"] .page-shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  max-width: 1440px;
  margin: 0 auto;
}

body[data-layout-mode="sidebar-left"] .page-shell {
  grid-template-areas: "topbar hero";
}

body[data-layout-mode="sidebar-right"] .page-shell {
  grid-template-areas: "hero topbar";
}

.topbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--shell-max-width);
  width: 100%;
  margin: 0 auto 24px;
}

body[data-layout-mode="sidebar-left"] .topbar,
body[data-layout-mode="sidebar-right"] .topbar {
  grid-area: topbar;
  position: sticky;
  top: var(--page-padding);
  width: var(--rail-width);
  max-width: none;
  min-height: calc(100vh - (var(--page-padding) * 2));
  margin: 0;
  padding: 20px;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 20px;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: rgba(16, 16, 16, var(--surface-opacity));
  box-shadow: 0 20px 50px rgba(0, 0, 0, var(--shadow-strength));
}

body[data-layout-mode="sidebar-right"] .topbar {
  justify-self: end;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.menu-toggle {
  display: inline-flex;
}

.site-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  display: grid;
  gap: 8px;
  min-width: 220px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(14, 14, 14, 0.98);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.36);
  z-index: 20;
}

.site-menu a {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.02);
}

.site-menu a[aria-current="page"],
.site-menu a:hover {
  color: #f2f2f2;
  background: rgba(245, 197, 66, 0.12);
}

body[data-layout-mode="sidebar-left"] .topbar-actions,
body[data-layout-mode="sidebar-right"] .topbar-actions {
  flex-direction: column;
  align-items: stretch;
  margin-top: auto;
}

.brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero {
  max-width: var(--shell-max-width);
  width: 100%;
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

body[data-layout-mode="sidebar-left"] .hero,
body[data-layout-mode="sidebar-right"] .hero {
  grid-area: hero;
  max-width: none;
  margin: 0;
}

.card {
  background: rgba(16, 16, 16, var(--surface-opacity));
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  box-shadow: 0 20px 50px rgba(0, 0, 0, var(--shadow-strength));
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.8rem;
  margin-bottom: 8px;
}

h1,
h2 {
  margin: 0 0 10px;
  color: #f2f2f2;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.tabs {
  display: flex;
  gap: 12px;
  margin: 24px 0;
}

.tab,
.primary-btn,
.ghost-btn,
.claim-btn,
select {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: var(--control-radius);
  padding: 10px 16px;
  cursor: pointer;
  transition: 180ms ease;
}

.tab.active,
.primary-btn,
.claim-btn {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.ghost-btn {
  background: transparent;
}

select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.form-panel {
  display: none;
}

.form-panel.active-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
}

input {
  background: #0b0b0b;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--input-radius);
  padding: 12px 14px;
}

.hidden {
  display: none !important;
}

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.balance-pill {
  padding: 12px 16px;
  border-radius: 999px;
  background: #171717;
  border: 1px solid var(--border);
}

.balance-pill span {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0 24px;
}

.stat-box {
  background: #171717;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.profile-card {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #121212;
}

.dashboard-note {
  margin-top: 8px;
  padding: 6px 2px 0;
}

.profile-page {
  display: grid;
  gap: 22px;
}

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

.profile-panel {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #121212;
}

.profile-panel h2 {
  margin-bottom: 6px;
}

.profile-details {
  margin: 18px 0 0;
  display: grid;
  gap: 14px;
}

.profile-details div {
  display: grid;
  gap: 4px;
}

.profile-details dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.profile-details dd {
  margin: 0;
  color: #f2f2f2;
  font-size: 1rem;
}

.profile-links {
  margin-top: 18px;
}

.profile-timezone-summary {
  margin-top: 10px;
}

.profile-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.profile-head h3 {
  margin: 0;
  color: #f2f2f2;
  font-size: 1.2rem;
}

.timezone-summary {
  text-align: right;
  display: grid;
  gap: 4px;
}

.timezone-summary strong {
  color: #f2f2f2;
  font-size: 0.95rem;
}

.timezone-summary span {
  color: var(--muted);
  font-size: 0.84rem;
}

.profile-note {
  margin: 12px 0 16px;
}

.profile-controls {
  display: grid;
  gap: 12px;
}

.profile-input {
  display: grid;
  gap: 6px;
}

.profile-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.message {
  min-height: 1.4em;
  margin-top: 12px;
  color: var(--accent-strong);
}

.popup {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid rgba(245, 197, 66, 0.4);
  border-radius: 18px;
  padding: 16px 20px;
  max-width: 90%;
  width: auto;
  color: #f2f2f2;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  text-align: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.popup.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.popup.hidden {
  display: none;
}

.popup.error {
  border-color: #ff5e5e;
}

.popup.success {
  border-color: #80ff90;
}

.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
}

.theme-picker span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.theme-picker select {
  border: none;
  background-color: transparent;
  padding: 0 22px 0 0;
  min-width: 120px;
}

body[data-layout-mode="sidebar-left"] .theme-picker,
body[data-layout-mode="sidebar-right"] .theme-picker {
  width: 100%;
  justify-content: space-between;
}

body[data-layout-mode="sidebar-left"] .theme-picker select,
body[data-layout-mode="sidebar-right"] .theme-picker select {
  min-width: 0;
  width: 100%;
}

.theme-picker select:focus {
  outline: none;
}

.admin-panel {
  display: grid;
  gap: 20px;
}

.admin-tabs {
  margin-top: 0;
}

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

.summary-card {
  background: linear-gradient(180deg, #191919, #121212);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 6px;
}

.summary-card span {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-card strong {
  font-size: 1.6rem;
  color: #f7f7f7;
}

.admin-panel-body {
  display: grid;
  gap: 16px;
}

.admin-pane {
  display: none;
}

.admin-pane.active-panel {
  display: block;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0f0f0f;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.admin-table th,
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #212121;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.02);
}

.admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.activity-list {
  display: grid;
  gap: 12px;
}

.activity-item {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 14px;
  padding: 14px 16px;
  background: #101010;
  display: grid;
  gap: 8px;
}

.activity-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.activity-head time,
.activity-meta,
.activity-details {
  color: var(--muted);
  font-size: 0.92rem;
}

.activity-details {
  line-height: 1.45;
}

.tone-success {
  border-left-color: #59d96b;
}

.tone-warning {
  border-left-color: #f5c542;
}

.tone-danger {
  border-left-color: #ff6464;
}

.tone-info {
  border-left-color: #64b5ff;
}

.tone-muted {
  border-left-color: #7d7d7d;
}

.tone-neutral {
  border-left-color: #9a9a9a;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-success,
.badge-admin {
  background: rgba(89, 217, 107, 0.14);
  color: #8df09a;
}

.badge-warning {
  background: rgba(245, 197, 66, 0.14);
  color: #ffd86f;
}

.badge-danger {
  background: rgba(255, 100, 100, 0.14);
  color: #ff9090;
}

.badge-info {
  background: rgba(100, 181, 255, 0.14);
  color: #9fcbff;
}

.badge-muted,
.badge-user,
.badge-neutral {
  background: rgba(125, 125, 125, 0.14);
  color: #c7c7c7;
}

.summary-detail {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  background: #101010;
}

.summary-copy h3 {
  margin: 0 0 8px;
  color: #f2f2f2;
}

.content-editor {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
}

.content-file-list,
.content-editor-main {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0f0f0f;
  min-height: 420px;
}

.content-file-list {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.content-file-items {
  display: grid;
  gap: 10px;
}

.content-file-item {
  text-align: left;
  border: 1px solid var(--border);
  background: #151515;
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 4px;
}

.content-file-item strong {
  color: #f2f2f2;
  font-size: 0.95rem;
}

.content-file-item span,
.content-meta,
.content-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.content-file-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(245, 197, 66, 0.2);
}

.content-file-item.malformed {
  border-left: 4px solid #ff6464;
}

.content-editor-main {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.content-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.content-editor-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.content-preview-box,
.content-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #121212;
  padding: 12px;
}

.content-box-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.content-preview {
  min-height: 220px;
}

.content-preview p,
.content-preview li,
.content-preview h1,
.content-preview h2,
.content-preview h3 {
  margin-top: 0;
}

.content-preview img {
  max-width: 100%;
}

.content-source {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0b0b0b;
  color: var(--text);
  padding: 12px;
  font: inherit;
  line-height: 1.5;
}

.content-source:focus {
  outline: 1px solid rgba(245, 197, 66, 0.4);
}

.content-destination {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0b0b0b;
  color: var(--text);
  padding: 12px;
  font: inherit;
}

.wiki-image {
  margin: 1rem 0;
  max-width: 100%;
}

.wiki-image img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.wiki-image-thumb {
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.wiki-image figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.wiki-image-left {
  float: left;
  margin: 0 1rem 1rem 0;
  max-width: min(360px, 100%);
}

.wiki-image-right {
  float: right;
  margin: 0 0 1rem 1rem;
  max-width: min(360px, 100%);
}

.wiki-image-center {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.wiki-image-center img {
  margin-left: auto;
  margin-right: auto;
}

.content-clear {
  clear: both;
}

.hero::after {
  content: "";
  display: table;
  clear: both;
}

.page-shell::after {
  content: "";
  display: table;
  clear: both;
}

@media (max-width: 700px) {
  .page-shell {
    padding: 16px;
  }

  body[data-layout-mode="sidebar-left"] .page-shell,
  body[data-layout-mode="sidebar-right"] .page-shell {
    display: block;
    max-width: none;
  }

  .card {
    padding: 20px;
  }

  .dashboard-head,
  .stats-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar,
  .topbar-actions,
  .activity-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .site-menu {
    position: static;
    width: 100%;
    min-width: 0;
    margin-top: 12px;
  }

  body[data-layout-mode="sidebar-left"] .topbar,
  body[data-layout-mode="sidebar-right"] .topbar {
    position: static;
    width: auto;
    min-height: auto;
    margin: 0 auto 24px;
  }

  body[data-layout-mode="sidebar-left"] .topbar-actions,
  body[data-layout-mode="sidebar-right"] .topbar-actions {
    margin-top: 0;
  }

  .profile-page-grid {
    grid-template-columns: 1fr;
  }

  .admin-summary-grid {
    grid-template-columns: 1fr;
  }

  .content-editor {
    grid-template-columns: 1fr;
  }

  .content-editor-head {
    flex-direction: column;
  }

  .wiki-image-left,
  .wiki-image-right {
    float: none;
    margin: 1rem 0;
    max-width: 100%;
  }
}
