:root {
  --black: #030603;
  --bg-panel: rgba(4, 14, 6, 0.88);
  --green: #00ff41;
  --green-dim: #0a7a2c;
  --green-glow: rgba(0, 255, 65, 0.55);
  --red: #ff003c;
  --red-glow: rgba(255, 0, 60, 0.6);
  --amber: #ffb000;
  --text-dim: #6fae7c;
  --font-mono: 'Share Tech Mono', 'JetBrains Mono', 'Courier New', monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  background: var(--black);
  color: var(--green);
  font-family: var(--font-mono);
  overflow-x: hidden;
}

body {
  min-height: 100vh;
}

/* ---------- background fx ---------- */

#matrix-rain {
  position: fixed;
  inset: 0;
  z-index: -3;
  width: 100%;
  height: 100%;
  opacity: 0.5;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.35) 3px,
    rgba(0, 0, 0, 0) 4px
  );
  mix-blend-mode: multiply;
  animation: scan-drift 9s linear infinite;
}

@keyframes scan-drift {
  0% { background-position: 0 0; }
  100% { background-position: 0 40px; }
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  box-shadow: inset 0 0 18vw 2vw rgba(0, 0, 0, 0.85);
}

/* ---------- shared ---------- */

.screen {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#dashboard.screen {
  display: block;
  min-height: 100vh;
}

.terminal-window {
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--bg-panel);
  box-shadow: 0 0 2px var(--green), 0 0 24px var(--green-glow), 0 0 70px rgba(0, 255, 65, 0.15);
  backdrop-filter: blur(3px);
  overflow: hidden;
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(0, 40, 12, 0.9), rgba(0, 20, 6, 0.9));
  border-bottom: 1px solid var(--green-dim);
}

.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; box-shadow: 0 0 6px currentColor; }
.dot-red { background: var(--red); color: var(--red); }
.dot-amber { background: var(--amber); color: var(--amber); }
.dot-green { background: var(--green); color: var(--green); }

.titlebar-text {
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.terminal-body { padding: 28px 30px 30px; }

.btn {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 12px 20px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--green);
  background: transparent;
  color: var(--green);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  min-height: 44px;
}

.btn:hover, .btn:focus-visible { box-shadow: 0 0 14px var(--green-glow); }
.btn:active { transform: scale(0.97); }

.btn-primary { background: rgba(0, 255, 65, 0.1); font-weight: 700; }
.btn-primary:hover { background: rgba(0, 255, 65, 0.22); }

.btn-ghost { border-color: var(--green-dim); color: var(--text-dim); background: transparent; }
.btn-ghost:hover { color: var(--green); border-color: var(--green); }

.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(255, 0, 60, 0.14); box-shadow: 0 0 14px var(--red-glow); }

label {
  display: block;
  margin: 18px 0 6px;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

input[type="password"],
input[type="text"],
input[type="url"] {
  width: 100%;
  padding: 12px 12px;
  background: rgba(0, 20, 8, 0.6);
  border: 1px solid var(--green-dim);
  border-radius: 4px;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 15px;
  min-height: 44px;
}

input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 10px var(--green-glow);
}

.login-message {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--red);
  color: var(--red);
  background: rgba(255, 0, 60, 0.08);
  border-radius: 4px;
  font-size: 13px;
  letter-spacing: 0.04em;
}

/* ---------- glitch title ---------- */

.glitch {
  position: relative;
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 0;
  color: var(--green);
  text-shadow: 0 0 10px var(--green-glow), 0 0 30px var(--green-glow);
}

.glitch.small { font-size: 24px; letter-spacing: 0.08em; }

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  overflow: hidden;
  clip-path: inset(0 0 0 0);
}

.glitch::before {
  color: var(--red);
  animation: glitch-1 3.2s infinite linear alternate-reverse;
  opacity: 0.7;
}

.glitch::after {
  color: var(--amber);
  animation: glitch-2 2.6s infinite linear alternate-reverse;
  opacity: 0.6;
}

@keyframes glitch-1 {
  0% { clip-path: inset(0 0 90% 0); transform: translate(-2px, -1px); }
  20% { clip-path: inset(20% 0 50% 0); transform: translate(2px, 1px); }
  40% { clip-path: inset(60% 0 10% 0); transform: translate(-1px, 2px); }
  60% { clip-path: inset(10% 0 70% 0); transform: translate(2px, -2px); }
  80% { clip-path: inset(80% 0 5% 0); transform: translate(-2px, 1px); }
  100% { clip-path: inset(40% 0 40% 0); transform: translate(1px, -1px); }
}

@keyframes glitch-2 {
  0% { clip-path: inset(70% 0 5% 0); transform: translate(2px, 1px); }
  25% { clip-path: inset(10% 0 80% 0); transform: translate(-2px, -1px); }
  50% { clip-path: inset(45% 0 30% 0); transform: translate(1px, 2px); }
  75% { clip-path: inset(5% 0 85% 0); transform: translate(-1px, -2px); }
  100% { clip-path: inset(60% 0 15% 0); transform: translate(2px, 1px); }
}

.subtitle {
  margin: 10px 0 0;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.15em;
}

.cursor { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- login layout ---------- */

.login-window { width: min(440px, 100%); }

/* ---------- dashboard ---------- */

.dash-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--green-dim);
  background: linear-gradient(180deg, rgba(0, 25, 8, 0.85), rgba(0, 8, 3, 0.6));
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
}

.dash-title { display: flex; align-items: baseline; gap: 10px; }
.dash-subtitle { color: var(--text-dim); font-size: 13px; letter-spacing: 0.1em; }

.status-bar { display: flex; gap: 10px; flex-wrap: wrap; }

.status-chip {
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  border-radius: 3px;
  border: 1px solid currentColor;
}

.status-online { color: var(--green); animation: pulse-green 2s ease-in-out infinite; }
.status-threat { color: var(--red); animation: pulse-red 1.4s ease-in-out infinite; }

@keyframes pulse-green { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes pulse-red { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.dash-actions { display: flex; gap: 10px; }

.bookmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
  padding: 26px;
  max-width: 1400px;
  margin: 0 auto;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.tile-btn {
  width: 100%;
  height: clamp(84px, 11vw, 116px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: var(--tile-bg, #14213d);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-mono);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.15s, transform 0.1s, filter 0.15s;
}

.tile-btn:hover, .tile-btn:focus-visible {
  filter: brightness(1.15);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 22px var(--tile-glow, var(--green-glow));
}

.tile-btn:active { transform: scale(0.96); }

.tile-icon-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tile-favicon {
  width: clamp(40px, 6vw, 60px);
  height: clamp(40px, 6vw, 60px);
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.6));
}

.tile-fallback {
  font-size: clamp(26px, 3.2vw, 38px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.tile-label {
  font-size: 11.5px;
  letter-spacing: 0.03em;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  color: var(--text-dim);
}

.tile-edit-overlay {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 6px;
}

.tile-edit-btn, .tile-delete-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--green);
  background: rgba(0, 0, 0, 0.75);
  color: var(--green);
  cursor: pointer;
  font-size: 14px;
}

.tile-delete-btn { border-color: var(--red); color: var(--red); }

.tile-add .tile-btn {
  background: transparent;
  border: 1px dashed var(--green-dim);
  box-shadow: none;
  color: var(--text-dim);
}

.tile-add .tile-btn:hover, .tile-add .tile-btn:focus-visible {
  color: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 18px var(--green-glow);
}

.tile-add .tile-fallback { color: var(--text-dim); text-shadow: none; }
.tile-add .tile-btn:hover .tile-fallback { color: var(--green); }

/* ---------- modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-window { width: min(460px, 100%); }

.terminal-body h2 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: 0.08em;
}

.danger-heading { color: var(--red); }

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

#confirm-text { color: var(--text-dim); font-size: 14px; }

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  .glitch { font-size: 40px; }
  .terminal-body { padding: 22px 18px 24px; }
  .dash-header { padding: 14px 16px; }
  .bookmark-grid { padding: 16px; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

[hidden] { display: none !important; }
