* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f1115;
  color: #e6e6e6;
}
a, button, input, textarea { font-family: inherit; }
.centered {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.card {
  background: #1a1d24;
  padding: 2.5rem 3rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.button, .link-button {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1.4rem;
  background: #4285f4;
  color: white;
  border: none;
  border-radius: 6px;
  text-decoration: none;
  font-size: 1rem;
  cursor: pointer;
}
.link-button {
  background: transparent;
  color: #9aa0a6;
  padding: 0;
  margin: 0;
}
.error { color: #f28b82; }
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 1rem 1.5rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
  background: #1a1d24;
  border-bottom: 1px solid #2a2d34;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.brand { font-weight: 600; white-space: nowrap; }
.nav { display: flex; gap: 1rem; }
.nav a {
  color: #9aa0a6;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.25rem 0;
}
.nav a.active, .nav a:hover { color: #e6e6e6; }
.user-email { font-size: 0.85rem; color: #9aa0a6; white-space: nowrap; }
.content {
  padding: 2rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
  max-width: 1100px;
  margin: 0 auto;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: #1a1d24;
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa0a6;
}
.stat-value { font-size: 1.4rem; margin-top: 0.25rem; }
.stat-sub { font-size: 0.8rem; color: #9aa0a6; margin-top: 0.15rem; }
.sparkline { display: block; width: 100%; height: 40px; margin-top: 0.5rem; }

.service-strip { display: flex; flex-direction: column; gap: 0.5rem; }
.service-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #1a1d24;
  border-radius: 8px;
  padding: 0.6rem 1rem;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5f6368;
  flex-shrink: 0;
}
.status-dot.ok { background: #34a853; }
.status-dot.bad { background: #ea4335; }
.service-name { font-weight: 500; flex-shrink: 0; }
.service-state {
  color: #9aa0a6;
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}
.service-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.mini-button {
  background: #2a2d34;
  color: #e6e6e6;
  border: none;
  border-radius: 5px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.mini-button:hover { background: #363a42; }
.mini-button:disabled { opacity: 0.5; cursor: default; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.tile {
  display: block;
  background: #1a1d24;
  border-radius: 10px;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.tile:hover { background: #21252d; }
.tile-name { font-size: 1.1rem; font-weight: 600; }
.tile-desc { font-size: 0.85rem; color: #9aa0a6; margin-top: 0.35rem; }

.hint { color: #9aa0a6; font-size: 0.9rem; }
.project-form {
  background: #1a1d24;
  border-radius: 10px;
  padding: 1.25rem;
  margin: 1rem 0 1.5rem;
  max-width: 480px;
}
.form-row { margin-bottom: 0.75rem; display: flex; flex-direction: column; gap: 0.3rem; }
.form-row label { font-size: 0.8rem; color: #9aa0a6; }
.form-row input[type="text"], .form-row input[type="number"] {
  padding: 0.55rem 0.7rem;
  background: #0f1115;
  border: 1px solid #2a2d34;
  border-radius: 6px;
  color: #e6e6e6;
  /* 16px minimum — anything smaller triggers iOS Safari's forced zoom-on-focus */
  font-size: 1rem;
}
.project-list { display: flex; flex-direction: column; gap: 0.5rem; }
.mini-button.danger { background: #442326; color: #f28b82; }
.mini-button.danger:hover { background: #5a2c30; }

.security-card { max-width: 480px; }
.security-card .button { display: block; width: max-content; }
.qr-image { display: block; margin: 1rem 0; border-radius: 8px; background: #fff; padding: 0.5rem; width: 220px; max-width: 100%; height: auto; aspect-ratio: 1; }
.totp-form { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; max-width: 220px; }
.totp-form label { font-size: 0.8rem; color: #9aa0a6; }
.totp-form input {
  padding: 0.6rem 0.7rem;
  background: #0f1115;
  border: 1px solid #2a2d34;
  border-radius: 6px;
  color: #e6e6e6;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  text-align: center;
}
.danger-button { background: #ea4335; }
code { background: #0f1115; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.9em; word-break: break-all; }

textarea {
  width: 100%;
  padding: 0.75rem;
  background: #1a1d24;
  color: #e6e6e6;
  border: 1px solid #2a2d34;
  border-radius: 6px;
  font-size: 1rem;
  resize: vertical;
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}
.job-card {
  background: #1a1d24;
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.job-status {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa0a6;
}
.job-prompt {
  font-size: 0.9rem;
  color: #cfd2d8;
}
.progress-bar {
  height: 6px;
  background: #0f1115;
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: #4285f4;
  transition: width 0.3s ease;
}
.job-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.job-card img, .job-card video {
  width: 100%;
  border-radius: 6px;
}
.mode-toggle {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}
.mode-toggle label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.image-ref-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.75rem 0; }
.image-ref-row label.mini-button { cursor: pointer; }
#ref-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.feedback-form {
  display: flex;
  gap: 0.5rem;
}
.feedback-form input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  background: #0f1115;
  border: 1px solid #2a2d34;
  border-radius: 6px;
  color: #e6e6e6;
  font-size: 1rem;
}
.feedback-form button {
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 6px;
  background: #4285f4;
  color: white;
  cursor: pointer;
}

/* Tablet and down */
@media (max-width: 720px) {
  .content { padding: 1.25rem; padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); }
  .card { padding: 2rem 1.75rem; }
  .card-grid, .tile-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* Phones */
@media (max-width: 480px) {
  .topbar { padding: 0.75rem 1rem; }
  .user-email { display: none; }
  .card-grid, .tile-grid, .gallery { grid-template-columns: 1fr; }
  .service-row { flex-wrap: wrap; }
  .service-actions { width: 100%; justify-content: flex-end; margin-top: 0.25rem; }
  .stat-value { font-size: 1.25rem; }
}

/* Comfortable touch targets on touch devices */
@media (pointer: coarse) {
  .button, .link-button, .mini-button, .feedback-form button {
    min-height: 44px;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
  }
  .mini-button { min-height: 38px; padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .nav a { padding: 0.5rem 0; }
}
