:root {
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-elevated: #243044;
  --border: #2d3a4f;
  --text: #e8eef6;
  --text-muted: #8b9cb3;
  --accent: #3d9cfd;
  --accent-soft: rgba(61, 156, 253, 0.15);
  --success: #34c759;
  --success-soft: rgba(52, 199, 89, 0.15);
  --warning: #ffb340;
  --warning-soft: rgba(255, 179, 64, 0.15);
  --danger: #ff6b6b;
  --latuda: #7c6af5;
  --lamotrigine: #2ec4b6;
  --pantoprazole: #f0a202;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(124, 106, 245, 0.18), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(46, 196, 182, 0.12), transparent);
}

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

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.nav-tabs button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-tabs button.active {
  background: var(--bg-elevated);
  color: var(--text);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.card p.lead {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Forms */
label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

input[type="email"],
input[type="password"],
input[type="text"],
textarea,
select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  margin-bottom: 14px;
  font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #061018;
}

.btn-success {
  background: var(--success);
  color: #06210f;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #1a0606;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  width: auto;
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* Status / scan screens */
.status-screen {
  text-align: center;
  padding: 28px 12px;
}

.status-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  font-size: 2rem;
}

.status-icon.ok {
  background: var(--success-soft);
  color: var(--success);
}

.status-icon.warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-icon.info {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-screen h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.status-screen .meta {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.med-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.med-badge.latuda {
  background: rgba(124, 106, 245, 0.2);
  color: #c4bbff;
}

.med-badge.lamotrigine {
  background: rgba(46, 196, 182, 0.2);
  color: #8ef0e6;
}

.med-badge.pantoprazole {
  background: rgba(240, 162, 2, 0.2);
  color: #ffd78a;
}

/* Food prompt modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  display: grid;
  place-items: end center;
  padding: 16px;
  z-index: 50;
}

@media (min-width: 600px) {
  .overlay {
    place-items: center;
  }
}

.modal {
  width: min(480px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.modal p {
  color: var(--text-muted);
  margin: 0 0 20px;
}

/* Dashboard */
.today-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 420px) {
  .today-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.today-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.today-pill .name {
  font-weight: 700;
  margin-bottom: 4px;
}

.today-pill .state {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.today-pill.taken {
  border-color: rgba(52, 199, 89, 0.45);
  background: var(--success-soft);
}

.today-pill.taken .state {
  color: var(--success);
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.log-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.log-list li:last-child {
  border-bottom: none;
}

.log-list .title {
  font-weight: 600;
}

.log-list .sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.log-list .time {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  text-align: right;
}

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

.error-banner {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: #ffb4b4;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Mood */
.mood-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.mood-scale button {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.mood-scale button.selected {
  background: var(--accent);
  color: #061018;
  border-color: var(--accent);
}

.emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.emoji-chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.95rem;
  cursor: pointer;
}

.emoji-chip.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.footer-note {
  margin-top: 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}

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