:root {
  color-scheme: dark;
  --bg: #101513;
  --panel: #161d1a;
  --panel-2: #1d2723;
  --line: #2d3833;
  --text: #e9f1ed;
  --muted: #99aaa2;
  --green: #1bd96a;
  --green-2: #0fa958;
  --yellow: #e9be52;
  --red: #ec6a5e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.auth-page {
  grid-template-columns: 1fr;
  place-items: center;
}

.auth-shell {
  width: min(520px, calc(100vw - 28px));
}

.auth-panel {
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-panel h1,
.auth-panel p {
  margin: 0;
}

.auth-panel form {
  display: grid;
  gap: 14px;
}

.auth-brand {
  margin-bottom: 4px;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  background: #0d1210;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #06220f;
  font-weight: 900;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 6px;
}

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

button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}

button:hover {
  border-color: #52635b;
}

.primary {
  background: var(--green);
  border-color: var(--green);
  color: #06220f;
  font-weight: 800;
}

.nav-item {
  text-align: left;
  width: 100%;
}

.nav-item.active {
  border-color: var(--green);
  color: var(--green);
}

main {
  padding: 28px;
  overflow: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topline.compact {
  align-items: center;
}

h1 {
  margin: 0;
  font-size: 32px;
}

p {
  color: var(--muted);
  margin: 8px 0 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

article,
.table-wrap,
.plan,
.editor-panel,
.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

article {
  padding: 18px;
}

article span {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

article strong {
  font-size: 30px;
}

.notice {
  position: relative;
  padding: 14px;
  margin-bottom: 16px;
  border-color: var(--yellow);
  color: #ffe3a1;
}

.notice.danger {
  border-color: #7f2d2d;
  color: #ffc9c9;
  background: rgba(127, 45, 45, 0.18);
}

.notice-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
}

.hidden {
  display: none;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: #102018;
  color: var(--text);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 12px 14px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #243129;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.badge.warn {
  color: var(--yellow);
}

.protected-row {
  background: rgba(233, 190, 82, 0.035);
}

.critical-note,
.warning-line {
  margin-top: 7px;
  color: #ffe3a1;
  font-size: 13px;
  line-height: 1.35;
}

.warning-line-danger {
  color: #ff8f8f;
}

.warning-button {
  display: block;
  width: fit-content;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.warning-list {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.mod-identity {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 260px;
}

.mod-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: #0c1110;
}

.mod-icon-fallback {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--green);
  font-weight: 900;
}

.mod-name {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.mod-subline {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.compact-tags {
  margin-top: 6px;
  min-width: 0;
}

.searchbox {
  display: flex;
  gap: 10px;
  min-width: min(640px, 100%);
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: #0c1110;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
}

select {
  min-width: 220px;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 14px;
}

.search-filter {
  width: fit-content;
  margin: -10px 0 16px;
}

.result {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result.known {
  opacity: 0.72;
}

.result > div {
  min-width: 0;
}

.result img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: #0c1110;
}

.result h2 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.mod-title-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  text-align: left;
}

.mod-title-button:hover {
  color: var(--green);
}

.result p {
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.actions select {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
}

.actions button {
  min-width: 0;
  padding-left: 10px;
  padding-right: 10px;
}

.actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.search-status {
  grid-column: 1 / -1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(3, 6, 5, 0.72);
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(1480px, 98vw);
  height: min(980px, 96vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mod-preview-body {
  display: grid;
  align-content: start;
  gap: 16px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1110;
}

.mod-preview-hero {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.mod-preview-hero img {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel);
}

.mod-preview-hero p,
.mod-preview-copy p {
  line-height: 1.6;
  color: #d8e4de;
}

.mod-preview-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.mod-preview-stats span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.mod-preview-stats strong {
  color: var(--text);
}

.external-link {
  color: var(--green);
  font-weight: 800;
}

.mod-preview-copy {
  max-width: 980px;
}

.mod-preview-copy img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.mod-preview-copy iframe {
  display: block;
  width: min(900px, 100%);
  aspect-ratio: 16 / 9;
  height: auto;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #000;
}

.mod-preview-copy h2,
.mod-preview-copy h3,
.mod-preview-copy h4,
.mod-preview-copy h5,
.mod-preview-copy h6 {
  margin: 24px 0 10px;
}

.mod-preview-copy ul,
.mod-preview-copy ol {
  display: grid;
  gap: 6px;
  padding-left: 24px;
}

.mod-preview-copy blockquote {
  margin: 16px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--green);
  background: var(--panel);
  color: var(--muted);
}

.mod-preview-copy code {
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--panel);
  font-family: Consolas, Cascadia Mono, monospace;
}

.mod-preview-copy pre {
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel);
}

.mod-preview-copy table {
  min-width: 0;
  margin: 14px 0;
}

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

.dependency-summary > div,
.dependency-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.dependency-section {
  display: grid;
  gap: 10px;
}

.dependency-section h3 {
  margin: 0 0 4px;
}

.dependency-section p {
  margin: 0;
}

.dependency-card {
  display: grid;
  gap: 14px;
}

.dependency-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.dependency-grid > div {
  min-width: 0;
}

.dependency-summary strong,
.dependency-grid strong {
  display: block;
  margin: 6px 0 4px;
}

.button-row,
.footer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.footer-actions {
  margin-top: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.settings-section {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

.plan {
  padding: 16px;
}

.plan.empty {
  color: var(--muted);
}

.step {
  display: grid;
  grid-template-columns: 130px 80px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.step:last-child {
  border-bottom: 0;
}

details summary {
  color: var(--text);
  cursor: pointer;
}

.file-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  min-width: 220px;
}

.file-list div {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.tag-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 180px;
}

.stage-plan {
  border-bottom: 1px solid var(--line);
  padding: 0 0 20px;
  margin-bottom: 22px;
}

.stage-plan:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.stage-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.stage-heading h2 {
  margin: 4px 0 0;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.change-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.change-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: #111815;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.technical-steps {
  margin-top: 12px;
}

.plan-change-details {
  margin-bottom: 12px;
}

.plan-change-details summary,
.preview-card > details summary {
  padding: 8px 0;
  color: var(--muted);
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-chips.compact {
  margin-top: 8px;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #101815;
  color: var(--muted);
  font-size: 13px;
}

.summary-chip strong {
  color: var(--accent);
  font-size: 14px;
}

.apply-preview {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.scan-progress {
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.apply-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.preview-card {
  display: grid;
  gap: 12px;
}

.preview-card h2 {
  margin: 0;
  font-size: 20px;
}

.preview-row,
.history-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.preview-row:last-child,
.history-row:last-child {
  border-bottom: 0;
}

.preview-row span,
.history-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-row .muted {
  display: block;
  margin-top: 3px;
}

.inline-diff {
  margin-top: 8px;
}

.inline-diff pre {
  max-height: 260px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1110;
  color: var(--text);
  font-family: Consolas, Cascadia Mono, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre;
}

.editor-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
}

.editor-panel textarea {
  display: block;
  min-width: 0;
  min-height: 440px;
  max-height: 70vh;
  resize: vertical;
  font-family: Consolas, Cascadia Mono, monospace;
  font-size: 13px;
  line-height: 1.45;
  overflow: auto;
  tab-size: 2;
}

.mini-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 210px;
}

.mini-actions button {
  padding: 6px 8px;
  font-size: 12px;
}

.config-tree {
  display: grid;
  gap: 16px;
}

.config-side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.config-side-heading,
.config-file-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.config-side-heading {
  margin-bottom: 14px;
}

.config-side-heading h2 {
  margin: 0;
  font-size: 22px;
}

.config-folder-list,
.config-folder-children {
  display: grid;
  gap: 8px;
}

.config-folder-children {
  margin-top: 8px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.config-folder summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #111815;
  cursor: pointer;
  list-style: none;
}

.config-folder summary::-webkit-details-marker {
  display: none;
}

.folder-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #243129;
  color: var(--green);
  font-weight: 900;
}

.config-folder[open] > summary .folder-icon::before {
  content: "-";
}

.config-folder:not([open]) > summary .folder-icon::before {
  content: "+";
}

.config-file {
  display: grid;
  gap: 12px;
  padding: 12px;
  background: #111815;
}

.config-file-main {
  align-items: flex-start;
}

.config-file-name {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.config-file-meta {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(110px, auto));
  gap: 12px;
  align-items: end;
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
  }

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

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

  .nav-item {
    text-align: center;
    padding-inline: 8px;
  }

  main {
    padding: 18px;
  }

  .topline,
  .searchbox {
    align-items: stretch;
    flex-direction: column;
  }

  .stats,
  .settings-grid,
  .apply-grid,
  .config-file-meta {
    grid-template-columns: 1fr;
  }

  .config-side-heading,
  .config-file-main {
    align-items: flex-start;
    flex-direction: column;
  }
}
