:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-hi: #1b2027;
  --line: #232a33;
  --accent: #3d8bff;
  --accent-dim: #3d8bff26;
  --brand: #df0000;
  --text: #ffffff;
  --secondary: #a8b2bd;
  --tertiary: #6b7683;
  --ok: #2e9e6b;
  --error: #ff6b6b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #16233a 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: #0b0d10cc;
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.wordmark { height: 30px; }
.who { color: var(--tertiary); font-size: 12.5px; font-family: ui-monospace, Menlo, monospace; }
.grow { flex: 1; }

main { padding: 36px 32px 64px; max-width: 1080px; }
h1 { font-size: 28px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0; }
.intro p { color: var(--secondary); margin: 0 0 28px; max-width: 70ch; }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--secondary);
  padding: 12px 22px;
  font-size: 16px;
  font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); background: var(--accent-dim); }

/* ---------------------------------------------------------------- panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 20px;
}
.panel.hidden { display: none; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 820px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.field { display: grid; gap: 7px; }
.field > span { color: var(--secondary); font-size: 13px; }

input[type="text"], input[type="password"], input[type="file"], input[type="date"], select {
  background: var(--panel-hi);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
  font-size: 14.5px;
  width: 100%;
}
input:focus, select:focus, input[type="file"]:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}
input::placeholder { color: #4d5763; }
input[type="file"] { padding: 9px; }

.switches { display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--secondary);
  cursor: pointer;
  user-select: none;
}
.switch input { width: 17px; height: 17px; accent-color: var(--accent); }
.switch:hover { color: var(--text); }
.switch.protect { color: #ffc9c9; }
.switch.protect input { accent-color: var(--brand); }

.note {
  background: var(--accent-dim);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--secondary);
  font-size: 13.5px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

button.primary {
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 34px;
  margin-left: auto;
  cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: .5; cursor: progress; }

button.ghost {
  background: var(--panel-hi);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--secondary);
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
button.ghost:hover { color: var(--text); border-color: var(--accent); }
button.ghost.danger:hover { color: #ffc9c9; border-color: var(--brand); }
button.ghost.locked { border-color: var(--brand); color: #ffc9c9; }

.result { min-height: 22px; margin: 18px 0 0; font-size: 14px; }
.result.ok { color: var(--ok); }
.result.error { color: var(--error); }
.result code {
  display: inline-block;
  margin-top: 6px;
  padding: 7px 12px;
  background: var(--panel-hi);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  word-break: break-all;
  cursor: pointer;
}

/* --------------------------------------------------------------- library */
.library { margin-top: 40px; }
.debug { margin-top: 40px; border-top: 1px dashed var(--line); padding-top: 24px; }
.debug-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.library-head { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.list { display: grid; gap: 10px; }

.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}
.item .title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.item .meta { color: var(--tertiary); font-size: 12.5px; margin-top: 3px; }
.item .meta.owner { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--secondary); }
.badge {
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--panel-hi);
  color: var(--secondary);
}
.badge.live { background: var(--brand); color: #fff; }
.badge.shield { background: #2a3f6b; color: #cfe0ff; }
.item .actions { display: flex; gap: 8px; flex-shrink: 0; }

.hint { color: var(--tertiary); font-size: 13.5px; }

/* ----------------------------------------------------------- TV id panel */
.tvpanel {
  border-color: var(--accent);
  margin-bottom: 26px;
}
.tvpanel h2 { margin-bottom: 4px; }
.tvpanel .hint { margin: 0 0 18px; max-width: 78ch; }
.tvpanel .hint strong { color: var(--secondary); }
.tvpanel .field > span { font-weight: 600; color: var(--text); }
.tvpanel input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 17px; letter-spacing: .02em; }
.tvpanel .result { margin: 12px 0 0; }

/* ---------------------------------------------------------- confirm modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #000000cc;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 28px;
  width: min(520px, calc(100vw - 48px));
  display: grid;
  gap: 12px;
}
.modal h2 { margin: 0; }
.modal p { margin: 0; color: var(--secondary); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
button.danger-btn {
  background: var(--brand);
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  padding: 10px 26px;
  cursor: pointer;
}
button.danger-btn:hover { filter: brightness(1.1); }

footer { padding: 24px 32px 48px; color: var(--tertiary); font-size: 13px; border-top: 1px solid var(--line); }
footer a { color: var(--secondary); }
