:root {
  --bg: #0f1115;
  --panel: rgba(20, 23, 30, 0.88);
  --panel-border: rgba(255, 255, 255, 0.10);
  --text: #e8ecf1;
  --muted: #9aa4b2;
  --accent: #0a84ff;
  --danger: #ff453a;
  --ok: #30d158;
  --warn: #ffd60a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.hidden { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 24px max(6vw, 28px) 24px max(6vw, 28px);
  background: var(--bg);
  overflow: hidden;
}

body.auth-page::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 24% 34%, rgba(2, 8, 16, 0) 0%, rgba(2, 8, 16, 0.28) 62%, rgba(2, 8, 16, 0.55) 100%);
}

.blueprint-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.blueprint-svg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}

a { color: var(--accent); }

.lang-fixed {
  z-index: 6;
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  z-index: 5;
}

.icon-btn {
  appearance: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--panel-border);
  background: rgba(20, 23, 30, 0.7);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.icon-btn:hover { border-color: rgba(255, 255, 255, 0.25); }

.auth-card {
  position: relative;
  z-index: 3;
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 28px 26px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
}
.brand .logo {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(135deg, #0a84ff, #bf5af2);
  box-shadow: 0 0 14px rgba(10, 132, 255, 0.7);
}

.auth-card h1 {
  margin: 20px 0 6px;
  font-size: 24px;
  letter-spacing: -0.3px;
}
.auth-card .subtitle {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

form { display: grid; gap: 14px; }

label.field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(8, 10, 14, 0.8);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.18); }

.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.25); }
.btn.primary { background: var(--accent); border-color: transparent; color: white; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.danger { color: var(--danger); }

.error {
  color: #ffb4ae;
  background: rgba(255, 69, 58, 0.12);
  border: 1px solid rgba(255, 69, 58, 0.3);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
}

.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* Projects */
body.projects-page {
  min-height: 100vh;
  padding: 0 calc(18px + env(safe-area-inset-right)) 40px calc(18px + env(safe-area-inset-left));
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(10, 132, 255, 0.12), transparent 60%),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(18px + env(safe-area-inset-top)) 0 18px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 26px;
}
.topbar .spacer { flex: 1; }
.topbar .who {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}
.topbar .who b { color: var(--text); font-weight: 600; }

.projects-wrap { width: min(1040px, 100%); margin: 0 auto; }
.projects-wrap h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.4px; }
.projects-wrap .lead { margin: 0 0 24px; color: var(--muted); font-size: 13px; }

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

.project-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px;
}
.project-card h2 {
  margin: 0;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.project-slug { color: var(--muted); font-size: 12px; margin: 2px 0 12px; }
.drawings { display: grid; gap: 7px; }
.drawing-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(8, 10, 14, 0.45);
  color: var(--text);
  text-decoration: none;
}
.drawing-row:hover { border-color: rgba(10, 132, 255, 0.6); }
.drawing-row .name { flex: 1; font-size: 14px; }
.drawing-row .open {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.drawing-row.disabled { opacity: 0.55; pointer-events: none; }

.badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  color: var(--muted);
}
.badge.admin { color: #ff9f0a; border-color: rgba(255, 159, 10, 0.4); }
.badge.viewer { color: var(--warn); border-color: rgba(255, 214, 10, 0.4); }
.badge.disabled { color: var(--danger); border-color: rgba(255, 69, 58, 0.35); }

.empty {
  border: 1px dashed var(--panel-border);
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}
.empty b { display: block; color: var(--text); margin-bottom: 6px; }

@media (max-width: 900px) {
  body.auth-page {
    justify-content: center;
    align-items: flex-end;
    padding-bottom: max(5vh, 24px);
  }
}

@media (max-width: 560px) {
  .auth-card { padding: 24px 18px; }
  .topbar .who { display: none; }
  .projects-wrap h1 { font-size: 22px; }
  .project-grid { grid-template-columns: 1fr; }
}

/* Project entry splash */
body.entry-page {
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.entry-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  margin: 0;
  padding: calc(16px + env(safe-area-inset-top)) max(4vw, 18px) 14px max(4vw, 18px);
  border-bottom: 1px solid rgba(120, 200, 255, 0.12);
  background: linear-gradient(to bottom, rgba(3, 12, 24, 0.88), rgba(3, 12, 24, 0));
}

.entry-main {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  pointer-events: none;
}

.entry-actions {
  position: fixed;
  left: 50%;
  bottom: calc(6vh + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  width: min(560px, calc(100% - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(120, 200, 255, 0.18);
  border-radius: 16px;
  background: rgba(5, 14, 26, 0.62);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}
.entry-actions .btn {
  text-decoration: none;
  text-align: center;
  min-width: 150px;
}
.entry-actions .hint {
  width: 100%;
  margin: 0;
  text-align: center;
  min-height: 1em;
}
body.entry-page.leaving .entry-actions { opacity: 0; transition: opacity .25s; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .entry-actions {
    bottom: calc(3vh + env(safe-area-inset-bottom));
    flex-direction: column;
  }
  .entry-actions .btn { width: 100%; }
}

@media (max-height: 620px) {
  body.auth-page {
    overflow-y: auto;
    align-items: flex-start;
    padding-top: 14px;
    padding-bottom: 14px;
  }
  body.auth-page .auth-card {
    padding: 18px 20px;
  }
  body.auth-page .auth-card h1 {
    margin-top: 12px;
    font-size: 20px;
  }
  body.auth-page .auth-card .subtitle {
    margin-bottom: 14px;
  }
}
