:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #121720;
  --panel-2: #171d28;
  --line: #273244;
  --text: #f4f7fb;
  --muted: #98a5b8;
  --brand: #f6b334;
  --brand-2: #1ec978;
  --danger: #ff5d5d;
  --focus: #75a7ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.94);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 760;
  text-decoration: none;
}

.brand.big {
  font-size: 26px;
  margin-bottom: 8px;
}

.logo {
  display: inline-grid;
  grid-template-columns: repeat(2, 8px);
  grid-auto-rows: 8px;
  gap: 3px;
}

.logo i {
  width: 8px;
  height: 8px;
  background: var(--brand);
}

.logo i:nth-child(3),
.logo i:nth-child(4) { background: var(--brand-2); }

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

nav a,
.tabs a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 8px 11px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
}

nav a[aria-current="page"],
.tabs a[aria-current="page"] {
  color: var(--text);
  background: var(--panel-2);
}

#view {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1, h2, h3 {
  margin: 0 0 10px;
  letter-spacing: 0;
}

h1 { font-size: 28px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.card {
  display: block;
  padding: 16px;
  text-decoration: none;
}

.card:hover { border-color: #3b4b63; }

.panel { padding: 18px; }

.stack {
  display: grid;
  gap: 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 16px;
  align-items: start;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d1118;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--brand-2);
}

input[type="range"] { padding: 0; }

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn,
button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.btn.primary {
  border-color: #b47a12;
  background: #d9951d;
  color: #14100a;
  font-weight: 720;
}

.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 5px 9px; font-size: 13px; }
.btn.danger { border-color: #81343b; background: #331217; color: #ffb9b9; }

button:disabled,
.btn[disabled] {
  cursor: default;
  opacity: 0.55;
}

.meta {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #203044;
  color: #dbe8ff;
  font-size: 12px;
}

.badge.warn { background: #3c2d16; color: #ffdba1; }
.badge.err { background: #3a171d; color: #ffb0b0; }

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tabs a {
  border-radius: 7px 7px 0 0;
  white-space: nowrap;
}

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

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

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1118;
}

.form-error {
  min-height: 20px;
  color: #ffb0b0;
}

.confirm-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
}

#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 50;
}

.toast {
  max-width: 360px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
}

.toast.error { border-color: #81343b; }
.toast.out { opacity: 0; transform: translateY(6px); transition: 0.25s ease; }

canvas.frame-preview {
  width: 256px;
  height: 128px;
  max-width: 100%;
  image-rendering: pixelated;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #000;
}

@media (max-width: 760px) {
  #topbar { align-items: flex-start; flex-direction: column; }
  #view { width: min(100vw - 20px, 1180px); padding-top: 18px; }
  .page-head { display: grid; }
  .split { grid-template-columns: 1fr; }
  .table { font-size: 13px; }
}
