:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0ea5e9;
  --danger: #dc2626;
  --warning: #d97706;
  --border: #e2e8f0;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: calc(16px + var(--safe-bottom));
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(244, 247, 251, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.1rem;
}

.app-header p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.container {
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
}

.screen[hidden] {
  display: none !important;
}

.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.time-btn,
.symptom-btn,
.back-btn,
.logout-btn {
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.time-btn {
  min-height: 88px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

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

.time-btn .emoji {
  font-size: 1.6rem;
}

.section-title {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 10px;
}

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

.symptom-btn {
  min-height: 56px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.back-btn {
  background: transparent;
  color: var(--primary);
  padding: 8px 0;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.child-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.child-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 10px;
  font-weight: 700;
  cursor: pointer;
}

.child-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.med-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.med-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.med-card.checked {
  opacity: 0.55;
}

.med-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.med-check {
  width: 24px;
  height: 24px;
  margin-top: 2px;
  flex-shrink: 0;
}

.med-name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.4;
}

.med-dose {
  margin-top: 6px;
  font-size: 1.05rem;
  color: var(--primary-dark);
  font-weight: 700;
}

.med-meta {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  margin-top: 8px;
}

.badge-regular {
  background: #dbeafe;
  color: #1e40af;
}

.badge-as-needed {
  background: #ffedd5;
  color: #9a3412;
}

.badge-hospital {
  background: #fee2e2;
  color: var(--danger);
}

.badge-conflict {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.med-card.has-conflict {
  box-shadow: 0 0 0 2px #fca5a5, var(--shadow);
}

.conflict-notice {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fef2f2;
  border-radius: 10px;
  border-left: 4px solid #dc2626;
  font-size: 0.88rem;
  color: #991b1b;
  font-weight: 700;
  line-height: 1.5;
}

.list-conflict-banner {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: #fff1f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #9f1239;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.5;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
}

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

.logout-btn {
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 4px 8px;
}

.footer-note {
  margin-top: 24px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.6;
  text-align: center;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.login-card input {
  width: 100%;
  font-size: 1rem;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
}

.login-card button[type='submit'] {
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 12px;
  min-height: 1.2em;
}

@media (min-width: 480px) {
  .time-btn {
    min-height: 96px;
    font-size: 1.05rem;
  }
}
