:root {
  --teal: #0d9488;
  --bg: #ece7e1;
  --ink: #2b2420;
  --muted: #6b5f57;
  --line: #c9b8ae;
  --card: #ffffff;
  --danger: #c24141;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button, input { font-family: inherit; }

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen.intake-screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: var(--bg);
  overflow: hidden;
}

.top-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px 8px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.header-patient {
  min-width: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.intake-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 18px 16px 20px;
}

.intake-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 12px;
  background: rgba(255, 253, 248, 0.96);
  border-top: 1px solid #e7d5cf;
}

.intake-q {
  margin: 4px 0 16px;
  font-size: 1.55rem;
  line-height: 1.35;
}

.intake-choices { display: grid; gap: 12px; }
.intake-choices.is-yn { grid-template-columns: 1fr 1fr; }

.intake-choice {
  min-height: 4.6rem;
  border-radius: 16px;
  border: 2px solid #d7c4bc;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.3rem;
  font-weight: 800;
}

.intake-choice.is-yes { border-color: #0f766e; color: #0f766e; }
.intake-choice.is-no { border-color: #9a3412; color: #9a3412; }
.intake-choice.is-on { background: #0f766e; color: #fff; border-color: #0f766e; }

.intake-note {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font: inherit;
  font-size: 1.15rem;
}

.intake-next, .intake-back { width: 100%; margin-top: 14px; }
.intake-foot .intake-next, .intake-foot .intake-back { margin-top: 0; }

.intake-review {
  display: block;
  margin-top: 16px;
  text-align: center;
  text-decoration: none;
}

.intake-summary, .intake-done {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  font-size: 1.25rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary { background: var(--teal); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-lg { padding: 12px 28px; font-size: 1.05rem; }
.search-error { color: var(--danger); margin: 0; }
.hidden { display: none; }
