:root {
  --bg: #0b0b12;
  --panel: #14141f;
  --panel-hi: #1c1c2b;
  --line: #262636;
  --text: #f2f2f7;
  --muted: #9a9aae;
  --accent: #7c5cff;
  --danger: #ff6b6b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* Every layout rule below sets display, which would otherwise beat the browser
   default for [hidden] and leave invisible panels swallowing taps. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: calc(var(--safe-top) + 20px) 20px calc(var(--safe-bottom) + 24px);
  -webkit-tap-highlight-color: transparent;
}

h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }

/* Boot ------------------------------------------------------------ */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}

/* Login ----------------------------------------------------------- */

.login {
  min-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 44px);
  display: grid;
  place-items: center;
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.mark {
  width: 60px;
  height: 60px;
  margin: 0 auto 18px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #7c5cff, #5a8bff);
  box-shadow: 0 10px 30px rgba(124, 92, 255, 0.3);
}

.login form { margin-top: 26px; text-align: left; }

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

input {
  width: 100%;
  margin: 0 0 16px;
  padding: 13px 14px;
  font-size: 16px; /* below 16px iOS zooms the page on focus */
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  appearance: none;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

button {
  font: inherit;
  cursor: pointer;
}

#login-btn {
  width: 100%;
  padding: 14px;
  margin-top: 4px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
}

#login-btn:disabled { opacity: 0.6; }

.error {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--danger);
  text-align: center;
}

/* Home ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.ghost {
  flex: none;
  min-height: 44px;
  padding: 8px 15px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.ghost:active { background: var(--panel); }

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .grid { grid-template-columns: 1fr 1fr; }
  body { max-width: 760px; margin: 0 auto; }
}

.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: transform 0.12s ease, background 0.12s ease;
}

.tile:active { transform: scale(0.985); background: var(--panel-hi); }

.tile.locked { opacity: 0.45; }

.tile-icon {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
}

.tile-icon svg { width: 22px; height: 22px; }

.tile-text { display: flex; flex-direction: column; min-width: 0; }
.tile-label { font-weight: 600; font-size: 16px; }
.tile-desc { font-size: 13px; color: var(--muted); }

.offline {
  margin-top: 20px;
  padding: 11px 14px;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}
