:root {
  --bg: #0a0a0f;
  --bg-soft: #12121c;
  --panel: #16161f;
  --panel-2: #1d1d2b;
  --border: #262636;
  --border-bright: #34344a;
  --text: #ecedf5;
  --muted: #8a8ba3;
  --faint: #5a5b72;
  --accent: #c6f24e;
  --accent-soft: rgba(198, 242, 78, 0.12);
  --danger: #ff6b81;
  --radius: 14px;
  --radius-sm: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 18% -10%, rgba(198, 242, 78, 0.08), transparent 45%),
    radial-gradient(circle at 92% 8%, rgba(96, 165, 250, 0.07), transparent 40%),
    radial-gradient(var(--border) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px;
  background-position: 0 0, 0 0, -2px -2px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ---------- Layout ---------- */
.shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 36px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.brand .glyph {
  width: 34px;
  height: 34px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  padding: 4px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--border-bright);
}

.brand .glyph i {
  border-radius: 1.5px;
  background: var(--faint);
}

.brand .glyph i:nth-child(1),
.brand .glyph i:nth-child(3),
.brand .glyph i:nth-child(5),
.brand .glyph i:nth-child(7),
.brand .glyph i:nth-child(9) {
  background: var(--accent);
}

.brand .sub {
  color: var(--muted);
  font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  border: 1px solid var(--border-bright);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  border-color: var(--faint);
  background: #23233333;
}

.btn:active {
  transform: translateY(1px);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #10130a;
}

.btn-accent:hover {
  background: #d4ff5e;
  border-color: #d4ff5e;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 8px 10px;
}

.btn-ghost:hover {
  background: var(--panel-2);
  color: var(--text);
}

.btn-danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

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

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
}

/* ---------- Create panel ---------- */
.create {
  display: flex;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

input.field,
textarea.field {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input.field:focus,
textarea.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input.field::placeholder {
  color: var(--faint);
}

.create .label-field {
  flex: 1 1 200px;
}

.create .url-field {
  flex: 2 1 320px;
}

/* ---------- Cards list ---------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--border-bright);
}

.card .thumb {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 6px;
  flex-shrink: 0;
}

.card .thumb img {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.card .body {
  min-width: 0;
}

.card .label {
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .label.empty {
  color: var(--faint);
  font-style: italic;
  font-weight: 500;
}

.card .target {
  display: block;
  color: var(--muted);
  font-size: 13.5px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .target:hover {
  color: var(--accent);
}

.card .meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--faint);
}

.slug-chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(198, 242, 78, 0.2);
  padding: 2px 8px;
  border-radius: 6px;
}

.scans {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.scans b {
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.card .actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Empty / states ---------- */
.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}

.empty-state .glyph {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  opacity: 0.6;
}

.empty-state .glyph i {
  border-radius: 2px;
  background: var(--faint);
}

.empty-state h2 {
  color: var(--text);
  font-size: 18px;
  margin: 0 0 6px;
}

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

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 30px;
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9);
}

.login-card .brand {
  justify-content: center;
  margin-bottom: 6px;
}

.login-card p.hint {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 26px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card .field {
  width: 100%;
  text-align: center;
}

/* ---------- Misc ---------- */
.error {
  color: var(--danger);
  font-size: 13.5px;
  min-height: 18px;
  text-align: center;
}

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--border-bright);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 20px 50px -25px rgba(0, 0, 0, 0.9);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.err {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 9, 0.7);
  backdrop-filter: blur(3px);
  display: none;
  place-items: center;
  padding: 24px;
  z-index: 20;
}

.modal-backdrop.show {
  display: grid;
}

.modal {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--border-bright);
  border-radius: 18px;
  padding: 26px;
}

.modal h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.modal .modal-slug {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 13px;
  margin-bottom: 20px;
}

.modal .qr-big {
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
}

.modal .qr-big img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.modal label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}

.modal .field {
  width: 100%;
  margin-bottom: 16px;
}

.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

@media (max-width: 560px) {
  .card {
    grid-template-columns: auto 1fr;
  }
  .card .actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    padding-top: 12px;
  }
}
