:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --danger: #f87171;
  --danger-strong: #ef4444;
  --ok: #4ade80;
  --border: #334155;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); }

/* ----- buttons & inputs ----- */
button {
  background: var(--accent-strong);
  color: #04263a;
  border: none;
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--accent); }
button.secondary { background: var(--panel-2); color: var(--text); }
button.secondary:hover { background: #344256; }
button.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
button.danger { background: var(--danger-strong); color: #2a0606; }
button.danger:hover { background: var(--danger); }

input, textarea {
  width: 100%;
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  font-size: 0.95rem;
}
textarea {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  resize: vertical;
}
label { display: block; font-size: 0.85rem; color: var(--muted); }
label input { margin-top: 0.25rem; }

/* ----- layout ----- */
.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.card {
  background: var(--panel);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.login-card { width: min(360px, 92vw); }
.login-card h1 { margin-top: 0; }
.login-card form { display: grid; gap: 1rem; }
.login-card button { margin-top: 0.5rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-right #who { color: var(--muted); font-size: 0.9rem; }

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.panel-head h2, .panel-head h3 { margin: 0; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.list li {
  padding: 0.6rem 0.7rem;
  border-radius: 7px;
  background: var(--panel-2);
  cursor: pointer;
  border: 1px solid transparent;
}
.list li:hover { border-color: var(--border); }
.list li.active { border-color: var(--accent); }
.list li .ds-name { font-weight: 600; }
.list li .ds-meta { font-size: 0.78rem; color: var(--muted); }

.detail.empty { color: var(--muted); display: grid; place-items: center; min-height: 200px; }

.name-input { font-size: 1.05rem; font-weight: 600; max-width: 70%; }
.block { display: block; margin-bottom: 0.5rem; }
.block textarea { margin-top: 0.3rem; }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.hint { font-size: 0.85rem; color: var(--muted); }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--danger); }

hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

.token-reveal {
  background: #06283a;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
}
.token-reveal code {
  background: #04121c;
  padding: 0.35rem 0.55rem;
  border-radius: 5px;
  word-break: break-all;
  font-size: 0.85rem;
}

.tokens-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; font-size: 0.88rem; }
.tokens-table th, .tokens-table td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.tokens-table th { color: var(--muted); font-weight: 600; }
.tokens-table code { font-size: 0.85rem; }
.badge { padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge.active { background: rgba(74, 222, 128, 0.15); color: var(--ok); }
.badge.revoked { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.badge:not(.active):not(.revoked) { background: var(--panel-2); color: var(--muted); }
.checkbox-inline { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.checkbox-inline input { width: auto; }

.chips { list-style: none; margin: 0.6rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.4rem 0.2rem 0.7rem;
  font-size: 0.85rem;
}
.chips li button {
  background: transparent;
  color: var(--muted);
  padding: 0 0.25rem;
  font-size: 1rem;
  line-height: 1;
}
.chips li button:hover { background: transparent; color: var(--danger); }
.word-select { width: auto; min-width: 160px; }
.preview-summary { justify-content: space-between; margin: 0.5rem 0; }
.chips li.is-used span:first-child { text-decoration: line-through; color: var(--muted); }
.chips.used li { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.4); padding: 0.2rem 0.7rem; }
.chips.used li.muted-chip { background: var(--panel-2); border-color: var(--border); color: var(--muted); }

.error { color: var(--danger); min-height: 1.2em; margin: 0.5rem 0 0; }
.error.floating {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--danger-strong);
  color: #2a0606;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-weight: 600;
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
}
