@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #0f172a;
  --bg-soft: #172033;
  --surface: #182235;
  --surface-2: #202c41;
  --border: rgba(148, 163, 184, 0.18);
  --text: #f8fafc;
  --muted: #94a3b8;
  --brand: #60a5fa;
  --brand-strong: #3b82f6;
  --danger: #ff7b7b;
  --shadow: 0 18px 40px rgba(2, 6, 23, 0.28);
  --radius: 24px;
  --radius-sm: 16px;
  --input-bg: rgba(255, 255, 255, 0.04);
  --panel-bg: rgba(15, 23, 42, 0.82);
  --panel-bg-strong: rgba(15, 23, 42, 0.92);
  --body-grad-top: rgba(96, 165, 250, 0.16);
  --body-grad-bottom: #0b1120;
  --tab-active-bg: rgba(96, 165, 250, 0.16);
  --button-secondary-bg: rgba(255, 255, 255, 0.06);
  --switch-track: rgba(255, 255, 255, 0.16);
  --meta-theme: #0f172a;
}

html[data-theme="light"] {
  --bg: #f3f6fb;
  --bg-soft: #e8eef7;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #64748b;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 18px 36px rgba(15, 23, 42, 0.08);
  --input-bg: rgba(255, 255, 255, 0.92);
  --panel-bg: rgba(255, 255, 255, 0.9);
  --panel-bg-strong: rgba(255, 255, 255, 0.96);
  --body-grad-top: rgba(37, 99, 235, 0.08);
  --body-grad-bottom: #edf3fb;
  --tab-active-bg: rgba(37, 99, 235, 0.12);
  --button-secondary-bg: rgba(15, 23, 42, 0.06);
  --switch-track: rgba(148, 163, 184, 0.4);
  --meta-theme: #f3f6fb;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(circle at top, var(--body-grad-top), transparent 34%),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--body-grad-bottom) 100%);
  color: var(--text);
  font: 400 15px/1.5 "Inter", system-ui, sans-serif;
  transition: background 180ms ease, color 180ms ease;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--input-bg);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

.mobile-app {
  min-height: 100vh;
  min-height: 100svh;
}

.auth-screen,
.app-screen {
  width: min(100%, 480px);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(24px + env(safe-area-inset-top)) 18px calc(32px + env(safe-area-inset-bottom));
}

.auth-screen {
  display: grid;
  align-content: center;
  gap: 20px;
}

.auth-hero,
.auth-card,
.screen-intro,
.connection-pill,
.panel,
.metric {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.auth-hero {
  border-radius: 28px;
  padding: 26px 22px;
}

.auth-badge,
.eyebrow {
  display: inline-flex;
  align-items: center;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-hero h1 {
  margin: 12px 0 10px;
  font-size: 34px;
  line-height: 1.02;
}

.auth-hero p,
.auth-copy,
.welcome-card p,
.note,
.site-item button,
.activity-item small,
.journal-item small,
.connection-pill small {
  color: var(--muted);
}

.auth-card {
  border-radius: 28px;
  padding: 22px;
  display: grid;
  gap: 18px;
}

.auth-card h2,
.app-header h2,
.panel h3,
.welcome-card h3 {
  margin: 6px 0 0;
  font-size: 24px;
  line-height: 1.1;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: var(--button-secondary-bg);
}

.auth-tabs button,
.button,
.ghost-button,
.site-item button,
.tab-bar-button {
  border: 0;
  cursor: pointer;
}

.auth-tabs button {
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  padding: 12px 10px;
  font-weight: 700;
}

.auth-tabs button.is-active {
  background: var(--brand);
  color: #eff6ff;
}

.auth-form,
.stack-form,
.journal-form,
.settings-form {
  display: grid;
  gap: 14px;
}

.button {
  width: 100%;
  border-radius: 16px;
  padding: 14px 16px;
  font-weight: 800;
}

.button-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #eff6ff;
}

.button-secondary,
.ghost-button,
.site-item button {
  background: var(--button-secondary-bg);
  color: var(--text);
}

.app-screen {
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.ghost-button {
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 700;
}

.connection-pill,
.screen-intro,
.panel {
  border-radius: var(--radius);
}

.connection-pill {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #d9a643;
  box-shadow: 0 0 10px currentColor;
}

.status-dot.is-online {
  background: var(--brand);
}

.status-dot.is-offline {
  background: var(--danger);
}

.screen-intro {
  padding: 20px 18px;
}

.screen-intro h3 {
  margin: 6px 0 8px;
  font-size: 24px;
  line-height: 1.1;
}

.screen-intro p:last-child {
  color: var(--muted);
}

.theme-block {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.theme-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.theme-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: var(--button-secondary-bg);
}

.theme-option {
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  padding: 12px 10px;
  font-weight: 700;
}

.theme-option.is-active {
  background: var(--brand);
  color: #eff6ff;
}

.app-content {
  display: grid;
  gap: 14px;
}

.tab-panel {
  display: grid;
  gap: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  border-radius: 20px;
  padding: 18px 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.panel {
  padding: 18px;
}

.panel-heading {
  margin-bottom: 14px;
}

.category-grid,
.activity-list,
.journal-history,
.site-list {
  display: grid;
  gap: 12px;
}

.category-card,
.activity-item,
.journal-item,
.site-item {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.category-card {
  padding: 16px;
}

.category-card.is-enabled {
  border-color: rgba(29, 207, 159, 0.35);
  background: rgba(29, 207, 159, 0.08);
}

.category-title,
.site-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-title p,
.activity-item p,
.journal-item p {
  margin: 6px 0 0;
  color: var(--muted);
}

.risk-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 50px;
  height: 30px;
}

.switch input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.switch span {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--switch-track);
  transition: background 160ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--brand);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.site-item,
.activity-item,
.journal-item {
  padding: 14px 16px;
}

.site-item button {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.empty-message {
  color: var(--muted);
  margin: 0;
}

.tab-bar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 5;
  width: min(calc(100% - 24px), 444px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel-bg-strong);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.tab-bar-button {
  display: grid;
  justify-items: center;
  gap: 6px;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  padding: 10px 6px;
  text-align: center;
}

.tab-bar-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-bar-button span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.tab-bar-button.is-active {
  background: var(--tab-active-bg);
  color: var(--brand);
}

[hidden] {
  display: none !important;
}

@media (min-width: 760px) {
  .auth-screen,
  .app-screen {
    width: min(100%, 920px);
    padding-left: 24px;
    padding-right: 24px;
  }

  .auth-screen {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: center;
  }

  .auth-hero h1 {
    font-size: 48px;
  }

  .tab-panel[data-tab-panel="protection"],
  .tab-panel[data-tab-panel="journal"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
