:root {
  --bg: #F8F9FA;
  --surface: #FFFFFF;
  --text: #191C1E;
  --text-muted: #49454F;
  --border: #E0E2EC;
  --primary: #005691;
  --primary-focus: #00325B;
  --gold-now: #E89B00;
  --gold-bg: #FFF3DA;
  --green-taken: #1E7E34;
  --green-bg: #EAF5EA;
  --neutral-skip: #5E6266;
  --skip-bg: #EDEDF0;
  --font-family: 'Atkinson Hyperlegible', sans-serif;
  --base-size: 18px;
  --letter-spacing: normal;
  --line-height: 1.5;
}

body.high-contrast {
  --bg: #000000;
  --surface: #121212;
  --text: #FFFF00;
  --text-muted: #FFFFFF;
  --border: #FFFF00;
  --primary: #FFFF00;
  --gold-now: #FFAA00;
  --gold-bg: #2B1D00;
  --green-taken: #00FF66;
  --green-bg: #002B11;
  --neutral-skip: #CCCCCC;
  --skip-bg: #222222;
}

body.calm-mode * {
  animation: none !important;
  transition: none !important;
}

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

body {
  font-family: var(--font-family);
  font-size: var(--base-size);
  letter-spacing: var(--letter-spacing);
  line-height: var(--line-height);
  background-color: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.device-shell {
  width: 100%;
  max-width: 440px;
  min-height: 720px;
  background: var(--surface);
  border-radius: 28px;
  border: 3px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(0,0,0,0.08);
  position: relative;
}

/* Tab bar */
.role-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  background: none;
  border: none;
  padding: 14px 4px;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-bottom: 4px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn .tab-sub {
  font-weight: normal;
  font-size: 0.8rem;
}

.tab-btn[aria-selected="true"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--surface);
}

.content-area {
  flex: 1;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

/* Screen headers */
.screen-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.screen-header p {
  color: var(--text-muted);
  font-size: 1rem;
}

.status-summary {
  font-weight: 700;
  color: var(--primary);
}

/* The Half-Circle Day Arc */
.arc-visual {
  background: var(--bg);
  border-radius: 20px;
  padding: 1.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 2px solid var(--border);
}

.arc-svg-wrap {
  width: 260px;
  height: 140px;
  position: relative;
}

.arc-counter {
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  margin-top: -8px;
}

.pulse {
  animation: pulse-ring 2s infinite ease-in-out;
}

@keyframes pulse-ring {
  0% { r: 12; opacity: 1; }
  50% { r: 17; opacity: 0.4; }
  100% { r: 12; opacity: 1; }
}

/* Card styling */
.card {
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 1.25rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card.now-card {
  border-color: var(--gold-now);
  background-color: var(--gold-bg);
  box-shadow: 0 4px 16px rgba(232, 155, 0, 0.15);
}

.section-title {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.sub-text {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 700;
  width: fit-content;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge.now {
  background: var(--gold-now);
  color: #000;
}

.badge.taken {
  background: var(--green-bg);
  color: var(--green-taken);
  border: 1px solid var(--green-taken);
}

.badge.skipped {
  background: var(--skip-bg);
  color: var(--neutral-skip);
  border: 1px solid var(--neutral-skip);
}

.dose-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.dose-meta {
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* Big buttons */
.btn-large {
  min-height: 62px;
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 16px;
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0.75rem 1rem;
  transition: transform 0.1s ease, filter 0.15s ease;
}

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

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

body.high-contrast .btn-primary {
  color: #000000;
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-small {
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 10px;
  cursor: pointer;
}

.actions-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

/* Dose list */
.dose-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.dose-row:last-child {
  border-bottom: none;
}

/* Toast notification */
.toast {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  background: #1E293B;
  color: #FFFFFF;
  padding: 14px 18px;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 100;
}

.toast-undo {
  background: #FFD166;
  color: #000;
  border: none;
  padding: 6px 14px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
}

/* 7-day history in Family View */
.history-bars {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 80px;
  padding-top: 10px;
}

.history-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
}

.bar {
  width: 24px;
  border-radius: 6px;
  background: var(--green-taken);
  transition: height 0.3s ease;
}

/* Settings rows */
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.setting-label {
  font-weight: 700;
  display: block;
}

.font-size-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.slider-wrapper {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
}

.slider-wrapper input[type="range"] {
  flex: 1;
}

.toggle-checkbox {
  width: 28px;
  height: 28px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-select {
  font-size: 1rem;
  padding: 6px 12px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.disclaimer-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem;
}
