:root {
  --bg-0: #061105;
  --bg-1: #0a1c08;
  --panel: rgba(14, 28, 14, 0.9);
  --panel-strong: rgba(12, 24, 12, 0.96);
  --line: #295d1f;
  --text: #ebffd8;
  --muted: #b8d2a4;
  --green: #9eff00;
  --orange: #ff8f1f;
  --red: #ff341f;
  --yellow: #ffd447;
  --shadow-green: rgba(158, 255, 0, 0.28);
  --shadow-red: rgba(255, 52, 31, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 10% 12%, rgba(158, 255, 0, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 88% 8%, rgba(255, 143, 31, 0.12) 0%, transparent 36%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  color: var(--text);
  font-family: "Rajdhani", "Segoe UI", Tahoma, sans-serif;
  line-height: 1.35;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(158, 255, 0, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(158, 255, 0, 0.05) 1px, transparent 1px);
  background-size: 30px 30px;
  opacity: 0.35;
  pointer-events: none;
  z-index: -2;
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: 0.18;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.08) 0,
    rgba(255, 255, 255, 0.08) 1px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 4px
  );
  animation: scan-drift 6s linear infinite;
}

.app-shell {
  width: min(1280px, calc(100vw - 2rem));
  margin: 1rem auto 2rem;
  display: grid;
  gap: 1rem;
}

.top-nav {
  padding: 0.72rem 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.top-nav a {
  border: 1px solid #4a7b39;
  border-radius: 999px;
  padding: 0.35rem 0.78rem;
  text-decoration: none;
  color: #e8ffd0;
  background: rgba(18, 35, 15, 0.85);
  font-weight: 700;
  transition: transform 110ms ease, box-shadow 110ms ease, border-color 110ms ease;
}

.top-nav a:hover {
  transform: translateY(-1px);
  border-color: #9eff00;
  box-shadow: 0 0 14px rgba(158, 255, 0, 0.22);
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-strong));
  border: 2px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(8, 18, 8, 0.8), 0 14px 28px rgba(0, 0, 0, 0.45);
}

.hero {
  padding: 1rem 1.25rem 1.2rem;
  border-color: #3b801f;
  box-shadow: 0 0 26px var(--shadow-green), 0 12px 28px rgba(0, 0, 0, 0.5);
}

.kicker {
  margin: 0;
  color: var(--orange);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0.2rem 0 0.35rem;
  font-family: "Bangers", Impact, sans-serif;
  font-size: clamp(2rem, 4.4vw, 3.25rem);
  letter-spacing: 0.04em;
  color: var(--green);
  text-shadow: 0 0 10px rgba(158, 255, 0, 0.44), 0 0 22px rgba(158, 255, 0, 0.25);
  animation: title-flicker 2.8s infinite;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.control-panel {
  padding: 0.9rem 1rem 1rem;
}

.control-panel label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--yellow);
  font-weight: 700;
}

.root-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  align-items: center;
}

.status {
  margin: 0.65rem 0 0;
  color: var(--muted);
  min-height: 1.35em;
}

.path-note {
  margin: 0.42rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.path-note code {
  color: #d5f6ac;
}

.warning {
  margin: 0.5rem 0 0.7rem;
  color: #ff7063;
  font-weight: 700;
  border-left: 4px solid #ff341f;
  padding: 0.35rem 0.5rem;
  background: rgba(66, 15, 12, 0.38);
  border-radius: 6px;
}

.status.is-error {
  color: #ff8c81;
}

.status.is-success {
  color: #c8ff76;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.file-panel,
.editor-panel {
  padding: 0.9rem;
  position: relative;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.panel-head h2 {
  margin: 0;
  font-family: "Bangers", Impact, sans-serif;
  letter-spacing: 0.04em;
  font-size: 1.7rem;
}

.file-list {
  display: grid;
  gap: 0.45rem;
  max-height: 70vh;
  overflow: auto;
  padding-right: 0.2rem;
}

.file-item {
  width: 100%;
  border: 1px solid #2d4628;
  border-left: 5px solid #4b6f42;
  border-radius: 10px;
  background: rgba(11, 20, 11, 0.85);
  color: inherit;
  text-align: left;
  padding: 0.5rem 0.62rem 0.56rem;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.file-item:hover {
  transform: translateY(-1px);
  border-color: #5d8a49;
}

.file-item.is-selected {
  border-color: var(--green);
  border-left-color: var(--green);
  box-shadow: 0 0 16px var(--shadow-green);
}

.file-item.role-save_slot {
  border-left-color: var(--green);
}

.file-item.role-telemetry_batch {
  border-left-color: var(--orange);
}

.file-item.role-error {
  border-left-color: var(--red);
}

.file-name {
  font-weight: 700;
  color: #f2ffd8;
  overflow-wrap: anywhere;
}

.file-meta {
  margin-top: 0.38rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.17rem 0.5rem;
  font-size: 0.78rem;
  line-height: 1;
  border: 1px solid #456f33;
  color: #d7f5c3;
  background: rgba(39, 74, 27, 0.5);
  text-transform: lowercase;
}

.badge-count {
  background: rgba(255, 212, 71, 0.18);
  color: #ffe486;
  border-color: rgba(255, 212, 71, 0.35);
}

.badge-role-save_slot {
  background: rgba(158, 255, 0, 0.18);
  border-color: rgba(158, 255, 0, 0.48);
  color: #d9ff87;
}

.badge-role-telemetry_batch {
  background: rgba(255, 143, 31, 0.2);
  border-color: rgba(255, 143, 31, 0.45);
  color: #ffd39a;
}

.badge-role-error {
  background: rgba(255, 52, 31, 0.2);
  border-color: rgba(255, 52, 31, 0.4);
  color: #ffb4a8;
}

.mode-tabs {
  display: inline-flex;
  gap: 0.35rem;
}

.tab-btn {
  background: rgba(13, 25, 13, 0.9);
  border: 1px solid #395a2e;
  border-radius: 999px;
  color: #deefca;
  font-weight: 700;
  font-size: 0.86rem;
  padding: 0.32rem 0.8rem;
  cursor: pointer;
}

.tab-btn.is-active {
  border-color: var(--orange);
  color: #fff3dd;
  box-shadow: 0 0 10px rgba(255, 143, 31, 0.35);
}

.meta {
  margin: 0.15rem 0 0.85rem;
  color: var(--muted);
  word-break: break-word;
}

.loading-overlay {
  position: absolute;
  inset: 0.7rem;
  border-radius: 12px;
  background: rgba(4, 10, 4, 0.85);
  border: 1px solid #395a2e;
  display: grid;
  place-content: center;
  gap: 0.7rem;
  z-index: 4;
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(158, 255, 0, 0.25);
  border-top-color: var(--green);
  margin: 0 auto;
  animation: spin 0.95s linear infinite;
}

.empty-state {
  border: 1px dashed #3a5f31;
  border-radius: 10px;
  padding: 1rem;
  color: var(--muted);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.7rem;
}

.card {
  border: 1px solid #355b2d;
  border-radius: 10px;
  padding: 0.65rem;
  background: rgba(9, 17, 9, 0.72);
}

.card h3 {
  margin: 0 0 0.48rem;
  font-family: "Bangers", Impact, sans-serif;
  letter-spacing: 0.04em;
  font-size: 1.25rem;
  color: #ddff8f;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.45rem;
}

.wide {
  grid-column: 1 / -1;
}

.grid {
  display: grid;
  gap: 0.44rem;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 0.2rem;
  font-weight: 600;
  color: #deefca;
}

input,
textarea {
  width: 100%;
  border: 1px solid #3f6338;
  background: #0d170d;
  color: #e7ffd0;
  border-radius: 8px;
  padding: 0.48rem 0.56rem;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  font-size: 1rem;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(158, 255, 0, 0.32);
  border-color: #76b850;
}

input.risky-locked,
textarea.risky-locked {
  border-color: rgba(255, 143, 31, 0.55);
  background: rgba(52, 28, 6, 0.58);
  color: #ffd8ad;
}

.upgrade-wrap {
  overflow-x: auto;
}

.upgrade-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.upgrade-table th,
.upgrade-table td {
  border-bottom: 1px solid #314f2c;
  padding: 0.34rem;
  text-align: left;
}

.upgrade-table th {
  color: #f0d787;
  font-weight: 700;
}

.upgrade-table td:first-child {
  width: 42px;
  color: var(--muted);
}

.symbol-name {
  font-weight: 700;
  color: #eaffbd;
}

.symbol-sub {
  margin-top: 0.1rem;
  color: #a7c18f;
  font-size: 0.82rem;
}

.id-input {
  max-width: 170px;
}

.hint {
  margin: -0.2rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.93rem;
}

.actions-row {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.risk-controls {
  display: grid;
  gap: 0.22rem;
}

.risk-state {
  margin: 0;
  color: #ffd59f;
  font-size: 0.9rem;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn {
  border: 1px solid #6f8a4a;
  border-radius: 8px;
  background: linear-gradient(180deg, #2a4524, #1f331c);
  color: #ecffd8;
  font-weight: 700;
  padding: 0.45rem 0.82rem;
  cursor: pointer;
  transition: transform 110ms ease, box-shadow 110ms ease, border-color 110ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(158, 255, 0, 0.2);
}

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

.btn-primary {
  border-color: rgba(158, 255, 0, 0.65);
  background: linear-gradient(180deg, rgba(104, 167, 52, 0.8), rgba(53, 84, 38, 0.92));
}

.btn-danger {
  border-color: rgba(255, 52, 31, 0.72);
  background: linear-gradient(180deg, rgba(180, 42, 27, 0.94), rgba(108, 26, 21, 0.96));
  box-shadow: 0 0 16px var(--shadow-red);
}

.toast-host {
  position: fixed;
  right: 0.8rem;
  bottom: 0.8rem;
  display: grid;
  gap: 0.45rem;
  z-index: 30;
}

.kofi-widget {
  position: fixed;
  right: 0.8rem;
  bottom: 4.3rem;
  z-index: 31;
  border: 1px solid rgba(255, 212, 71, 0.76);
  border-radius: 999px;
  padding: 0.48rem 0.82rem;
  text-decoration: none;
  color: #2e2106;
  font-weight: 700;
  background: linear-gradient(180deg, #ffeab4, #ffd779);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.4);
}

.kofi-widget:hover {
  transform: translateY(-1px);
}

.toast {
  min-width: min(360px, calc(100vw - 1.6rem));
  border-radius: 10px;
  padding: 0.55rem 0.72rem;
  border: 1px solid #38622d;
  background: rgba(10, 18, 10, 0.96);
  color: #e9ffd2;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.35);
  animation: toast-in 170ms ease-out;
}

.toast.is-success {
  border-color: rgba(158, 255, 0, 0.62);
}

.toast.is-error {
  border-color: rgba(255, 52, 31, 0.65);
  color: #ffc4bc;
}

.toast.is-info {
  border-color: rgba(255, 143, 31, 0.6);
}

.dir-modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 3, 0.75);
  display: grid;
  place-items: center;
  z-index: 35;
  padding: 0.8rem;
}

.dir-modal-card {
  width: min(900px, 100%);
  max-height: min(82vh, 900px);
  overflow: auto;
  border-radius: 12px;
  border: 2px solid #4a7f38;
  background: linear-gradient(180deg, rgba(10, 22, 10, 0.98), rgba(8, 16, 8, 0.98));
  box-shadow: 0 0 24px var(--shadow-green);
  padding: 0.8rem;
}

.dir-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.dir-head h3 {
  margin: 0;
  font-family: "Bangers", Impact, sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.04em;
}

.dir-current {
  margin: 0.6rem 0 0.4rem;
  color: var(--yellow);
  overflow-wrap: anywhere;
}

.dir-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.dir-roots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.dir-list {
  display: grid;
  gap: 0.42rem;
}

.dir-item {
  width: 100%;
  text-align: left;
  border: 1px solid #3d6135;
  border-radius: 8px;
  background: rgba(13, 23, 13, 0.84);
  color: #e7ffd0;
  padding: 0.44rem 0.52rem;
  cursor: pointer;
}

.dir-item:hover {
  border-color: #5e934e;
}

.hidden {
  display: none !important;
}

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

@keyframes scan-drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(12px);
  }
}

@keyframes title-flicker {
  0%,
  100% {
    opacity: 1;
  }
  4% {
    opacity: 0.92;
  }
  6% {
    opacity: 1;
  }
  36% {
    opacity: 0.95;
  }
  40% {
    opacity: 1;
  }
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

  .file-list {
    max-height: 42vh;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(1280px, calc(100vw - 1rem));
    margin: 0.5rem auto 1.2rem;
  }

  .root-row {
    grid-template-columns: 1fr;
  }

  .dir-actions {
    flex-direction: column;
  }

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

  .actions-row {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    width: 100%;
  }

  .actions .btn {
    flex: 1;
  }

  .panel-head {
    flex-wrap: wrap;
  }

  .kofi-widget {
    bottom: 4.6rem;
    right: 0.5rem;
    font-size: 0.86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
