*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 9999;
  transition: opacity 0.4s, visibility 0.4s;
}

.loading-screen--hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-logo {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-navy);
  letter-spacing: -0.03em;
}

.loading-logo span {
  color: var(--color-primary);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-navy);
}

.page-subtitle {
  color: var(--color-text-muted);
  margin-top: 4px;
  font-size: 0.95rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin: 32px 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-success {
  color: var(--color-success);
}

.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}

.empty-state ion-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.hide-mobile {
  display: inline;
}

.hide-desktop {
  display: none;
}

/* Boot failure overlay (only when scripts truly fail) */
.boot-error {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 25, 49, 0.6);
  backdrop-filter: blur(6px);
}

.boot-error[hidden] {
  display: none !important;
}

.boot-error__card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.boot-error__card h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
  color: var(--color-danger);
}

.boot-error__hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 12px;
}

.boot-error code {
  display: block;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .hide-mobile { display: none; }
  .page-header h1 { font-size: 1.4rem; }
  .main { padding: 16px 14px 32px; }
}
