:root {
  --bg: #fefaf3;
  --text: #1a1a2e;
  --muted: #4a4a5a;
  --primary: #0b3d91;
  --primary-dark: #082a63;
  --good: #1b8a5a;
  --good-dark: #146b45;
  --warn: #d68910;
  --danger: #c0392b;
  --danger-dark: #9c2d21;
  --card: #ffffff;
  --border: #d9d3c5;
  --focus: #0b3d91;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 22px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
}

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
}

header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: var(--primary);
  color: #fff;
}

header.app-header h1 {
  font-size: 26px;
  margin: 0;
}

.icon-button {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 14px;
  color: #fff;
  font-size: 26px;
  padding: 8px 12px;
  min-width: 56px;
  min-height: 56px;
}

main.view {
  flex: 1;
  padding: 24px 20px 100px;
  display: none;
}

main.view.active {
  display: block;
}

/* HOME */
.home-status {
  text-align: center;
  font-size: 26px;
  font-weight: 600;
  min-height: 40px;
  margin-bottom: 20px;
}

.mic-wrap {
  display: flex;
  justify-content: center;
  margin: 20px 0 24px;
}

#mic-button {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 96px;
  box-shadow: 0 8px 24px rgba(11,61,145,0.35);
  transition: transform 0.15s ease, background 0.2s ease;
}

#mic-button:active {
  transform: scale(0.96);
}

#mic-button.listening {
  background: var(--danger);
  animation: pulse 1.2s infinite;
}

#mic-button.speaking {
  background: var(--good);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(192,57,43,0.5); }
  70% { box-shadow: 0 0 0 30px rgba(192,57,43,0); }
  100% { box-shadow: 0 0 0 0 rgba(192,57,43,0); }
}

.transcript {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  min-height: 100px;
  margin-bottom: 20px;
}

.transcript .you-said {
  color: var(--muted);
  font-size: 20px;
  margin: 0 0 8px;
}

.transcript .helper-said {
  font-size: 26px;
  margin: 0;
  font-weight: 600;
}

.secondary-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.pill-button {
  border: 2px solid var(--primary);
  background: #fff;
  color: var(--primary);
  border-radius: 999px;
  padding: 14px 22px;
  font-size: 20px;
  min-height: 56px;
}

.emergency-call {
  display: block;
  width: 100%;
  margin-top: 24px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 20px;
  font-size: 26px;
  font-weight: 700;
  min-height: 76px;
}

/* Generic big buttons and cards */
.big-button {
  display: block;
  width: 100%;
  border: none;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  font-weight: 600;
  padding: 18px;
  margin-top: 14px;
  min-height: 64px;
}

.big-button.secondary {
  background: var(--good);
}

.big-button.danger {
  background: var(--danger);
}

.list-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-card .info {
  flex: 1;
}

.list-card .info .name {
  font-size: 24px;
  font-weight: 700;
}

.list-card .info .meta {
  color: var(--muted);
  font-size: 19px;
}

.list-card .actions {
  display: flex;
  gap: 8px;
}

.icon-action {
  border: 2px solid var(--border);
  background: #fff;
  border-radius: 12px;
  font-size: 22px;
  padding: 10px 14px;
  min-height: 52px;
}

.icon-action.call { border-color: var(--good); color: var(--good-dark); }
.icon-action.edit { border-color: var(--primary); color: var(--primary); }
.icon-action.delete { border-color: var(--danger); color: var(--danger-dark); }

fieldset {
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin: 0 0 20px;
}

legend {
  font-weight: 700;
  padding: 0 8px;
}

label {
  display: block;
  font-weight: 600;
  margin: 12px 0 6px;
}

input[type="text"], input[type="tel"], input[type="password"], input[type="time"], select {
  width: 100%;
  font-size: 22px;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #fff;
  color: var(--text);
  min-height: 56px;
}

.time-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
}

.time-chip {
  background: #fff;
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 18px;
}

.time-chip button {
  background: none;
  border: none;
  color: var(--danger);
  font-weight: 700;
  margin-left: 8px;
  font-size: 18px;
}

.hint {
  color: var(--muted);
  font-size: 18px;
  margin-top: 4px;
}

.empty-note {
  text-align: center;
  color: var(--muted);
  padding: 30px 10px;
  font-size: 21px;
}

/* Bottom nav */
nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #fff;
  border-top: 2px solid var(--border);
  max-width: 640px;
  margin: 0 auto;
}

nav.bottom-nav button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 4px 10px;
  font-size: 15px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 64px;
}

nav.bottom-nav button .nav-icon {
  font-size: 26px;
}

nav.bottom-nav button.active {
  color: var(--primary);
  font-weight: 700;
}

/* Reminder overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,11,20,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.overlay[hidden] { display: none; }

.overlay-card {
  background: #fff;
  border-radius: 22px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  text-align: center;
}

.overlay-card .pill-emoji {
  font-size: 64px;
}

.overlay-card h2 {
  font-size: 28px;
  margin: 10px 0;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
}

.switch-row input[type="checkbox"] {
  width: 32px;
  height: 32px;
}

.status-banner {
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 19px;
}

.status-banner.ok { background: #e2f3e9; color: var(--good-dark); }
.status-banner.warn { background: #fbeecb; color: #8a5e08; }

.stack-gap > * + * { margin-top: 10px; }

.ad-container {
  margin-top: 24px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14141f;
    --text: #f1efe6;
    --muted: #b7b3a6;
    --card: #1f1f2e;
    --border: #35354a;
  }
  nav.bottom-nav { background: #1f1f2e; }
  input[type="text"], input[type="tel"], input[type="password"], input[type="time"], select {
    background: #1f1f2e;
    color: var(--text);
  }
  .icon-action { background: #1f1f2e; }
  .overlay-card { background: #1f1f2e; }
}
