:root {
  color-scheme: light;
  --background: #f2f2f7;
  --text: #050505;
  --muted: #8d8d92;
  --line: #dedee3;
  --blue: #10bfdf;
  --link: #007aff;
  --card: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  min-height: 100vh;
}

.view-container {
  padding: 24px;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 8vw, 48px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -1px;
}

h2 {
  margin: 0 0 18px;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 700;
}

/* Landing Page Styles */
.landing-header {
  margin-bottom: 40px;
  margin-top: 20px;
}

.user-selection-card {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.user-selection-card label {
  display: block;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 15px;
}

.user-selection-card select {
  width: 100%;
  height: 50px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f9f9fb;
  font-size: 17px;
  padding: 0 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238d8d92' d='M1 4l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

.user-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.primary-btn, .secondary-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border: none;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 700;
  text-align: left;
  transition: transform 0.1s active;
}

.primary-btn {
  background: var(--link);
  color: white;
}

.secondary-btn {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.btn-icon {
  font-size: 24px;
}

/* View Header Styles (Redesigned for Mobile) */
.view-header {
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
}

.back-btn {
  background: transparent;
  border: none;
  color: var(--link);
  font-size: 17px;
  padding: 8px 0;
  font-weight: 500;
}

.header-content {
  grid-column: 1 / -1;
}

.medication-selector-wrapper {
  grid-column: 1 / -1;
  margin-top: 12px;
}

.medication-selector-wrapper select {
  width: 100%;
  height: 44px;
  background: var(--card);
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23007aff' d='M1 4l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

/* Shared Components */
.status-panel {
  border-radius: 12px;
  background: var(--card);
  padding: 16px;
  color: #535359;
  margin-bottom: 20px;
  font-size: 15px;
  text-align: center;
}

.status-panel.is-error {
  color: #a52323;
  background: #fff5f5;
}

.placeholder-card {
  background: var(--card);
  border-radius: 20px;
  padding: 40px 24px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
}

.placeholder-card .muted {
  margin-top: 12px;
  font-size: 15px;
  color: var(--muted);
  font-weight: 400;
}

/* Phone Frame Components */
.phone-frame {
  width: 100%;
}

.highlight-card,
.details-card {
  border-radius: 24px;
  background: var(--card);
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.med-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--blue);
  font-size: 17px;
  font-weight: 800;
}

.pill-icon {
  position: relative;
  width: 24px;
  height: 20px;
  display: inline-block;
}

.pill-icon span:first-child {
  position: absolute; left: 0; top: 2px; width: 18px; height: 9px;
  border-radius: 999px; background: var(--blue); transform: rotate(-45deg);
}

.pill-icon span:last-child {
  position: absolute; right: 0; bottom: 2px; width: 13px; height: 13px;
  border-radius: 999px; border: 4px solid var(--blue); background: var(--card);
}

.headline {
  margin: 16px 0 20px;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 800;
}

.calendar-controls {
  display: grid;
  grid-template-columns: 38px 44px minmax(0, 1fr) 44px 38px;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}

.calendar-controls button {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: #eef9fc;
  color: var(--link);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.calendar-controls p {
  margin: 0;
  color: #535359;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px 4px;
  padding: 16px 0 8px;
}

.day-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.day-marker {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  background: transparent;
  transition: transform 0.1s ease;
}

.day-marker.is-today {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 6px #77797d;
}

.day-marker.is-selected {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 6px var(--link);
  z-index: 1;
}

.day-marker.is-today.is-selected {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 6px var(--link), 0 0 0 10px #77797d;
}

.month-marker {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.range-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

.selected-day-section {
  margin-top: 24px;
}

.selected-day-section h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

.selected-day-list {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: 16px;
  background: var(--line);
  overflow: hidden;
}

.selected-day-item, .selected-day-empty {
  background: var(--card);
  padding: 16px;
}

.selected-day-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.selected-day-medication {
  font-weight: 700;
  font-size: 16px;
}

.selected-day-time {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 32px 0 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.section-heading button {
  background: transparent;
  border: none;
  color: var(--link);
  font-weight: 600;
  font-size: 16px;
}

.details-card {
  display: flex;
  align-items: center;
  gap: 20px;
}

.tablet-art {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #1d6f99 0 52%, #2b91bb 53% 100%);
  display: grid;
  place-items: center;
}

.tablet-art span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #e5ef81, #c6d45a 68%, #9ead3b);
}

.details-card h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}

.details-card p {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
}

/* Responsive adjustments for non-mobile */
@media (min-width: 768px) {
  .app-shell {
    padding-top: 40px;
  }
  
  .view-container {
    max-width: 600px;
    margin: 0 auto;
  }
  
  .primary-btn:hover, .secondary-btn:hover {
    filter: brightness(0.95);
  }
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--card);
  border-radius: 24px;
  padding: 28px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  text-align: center;
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 22px;
}

.modal-content p {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 24px;
}

.password-input-wrapper {
  margin-bottom: 24px;
}

.password-input-wrapper input {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f9f9fb;
  font-size: 17px;
  padding: 0 16px;
  text-align: center;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-btn-primary, .modal-btn-secondary {
  height: 44px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
}

.modal-btn-primary {
  background: var(--link);
  color: white;
}

.modal-btn-secondary {
  background: var(--line);
  color: var(--text);
}

.error-text {
  color: #a52323;
  font-size: 14px;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 0;
}

/* Managed Medications List */
.managed-meds-list {
  display: grid;
  gap: 16px;
  padding-bottom: 40px;
}

.managed-med-card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
  border: 1px solid var(--line);
}

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

.med-header h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.med-header .raw-name {
  font-size: 12px;
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.med-edit-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.form-group input {
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f9f9fb;
  padding: 0 10px;
  font-size: 15px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.edit-actions {
  margin-top: 12px;
}

.secondary-btn.small {
  padding: 10px 16px;
  font-size: 14px;
  border-radius: 12px;
}

.save-status {
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
  display: block;
  min-height: 15px;
}

.save-status.success {
  color: #28a745;
}

.save-status.error {
  color: #dc3545;
}
