/* 高齢の方でも読みやすく、押しやすく。ボタンは最低でも高さ56px */
:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1d1d1b;
  --sub: #55534e;
  --line: #d9d5cc;
  --main: #1f6f5c;
  --main-ink: #ffffff;
  --main-soft: #e3f1ec;
  --ok: #1f7a3a;
  --ok-soft: #e4f4e8;
  --ng: #b3261e;
  --ng-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --radius: 14px;
  font-size: 21px;
}
html[data-size='normal'] { font-size: 18px; }
html[data-size='large'] { font-size: 21px; }
html[data-size='xlarge'] { font-size: 25px; }

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'BIZ UDPGothic', 'Noto Sans JP', 'Yu Gothic', sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px calc(110px + env(safe-area-inset-bottom));
}
main.sub { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }

h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 .4em; }
p { margin: .5em 0; }
b { font-weight: 700; }

button, .filebtn {
  font: inherit;
  min-height: 56px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  padding: .45em 1em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3em;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible, input:focus-visible, .filebtn:focus-within, summary:focus-visible {
  outline: 3px solid #f0a500;
  outline-offset: 2px;
}
.primary { background: var(--main); color: var(--main-ink); font-weight: 700; width: 100%; margin: .6em 0; }
.secondary { background: var(--card); color: var(--main); border-color: var(--main); font-weight: 700; width: 100%; margin: .6em 0; }
.danger { background: var(--card); color: var(--ng); border-color: var(--ng); width: 100%; margin: 1.6em 0 .6em; }
.big { min-height: 72px; font-size: 1.1rem; }
button:active, .filebtn:active { transform: translateY(1px); filter: brightness(.95); }

/* 上の帯 */
.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: .5em;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.bar h1 { flex: 1; }
.bar .back, .bar .gear {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
  min-height: 48px;
  font-size: .9rem;
  padding: .2em .7em;
  flex-shrink: 0;
}

/* 下のタブ */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.tabs button {
  flex-direction: column;
  gap: 0;
  min-height: 72px;
  background: none;
  border-radius: 0;
  color: var(--sub);
  font-size: .85rem;
  font-weight: 700;
}
.tabs .ico { font-size: 1.4rem; line-height: 1.2; }
.tabs button.on { color: var(--main); background: var(--main-soft); box-shadow: inset 0 4px 0 var(--main); }

/* カード */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0;
}
.card[role='button'] { cursor: pointer; }
.card.done { border-color: var(--ok); background: var(--ok-soft); }
.card.late { border: 3px solid var(--ng); background: var(--ng-soft); }

.appt-next { border-left: 8px solid var(--main); }
.appt-next.soon { background: var(--warn-soft); border-left-color: var(--warn); }
.appt-next .label { color: var(--sub); font-size: .85rem; font-weight: 700; }
.when { font-size: 1.15rem; font-weight: 700; }
.rel {
  display: inline-block;
  background: var(--main);
  color: #fff;
  border-radius: 8px;
  padding: 0 .45em;
  margin-right: .3em;
  font-size: .95rem;
}
.appt-next.soon .rel { background: var(--warn); }
.where { font-size: 1.05rem; }
.memo { color: var(--sub); font-size: .95rem; }
.appt.past { opacity: .75; }
.row { display: flex; gap: 8px; }
.row button { margin-bottom: 0; }

.slot-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3em; }
.slot-head h2 { font-size: 1.35rem; margin: 0; }
.slot-head small { font-size: .85rem; color: var(--sub); font-weight: 400; margin-left: .5em; }
.badge { font-weight: 700; border-radius: 8px; padding: .1em .5em; font-size: .9rem; }
.badge.ok { color: var(--ok); }
.badge.ng { color: #fff; background: var(--ng); }

.medlist { list-style: none; margin: 8px 0 0; padding: 0; }
.medlist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px dashed var(--line);
}
.medlist li:first-child { border-top: 0; }
.medname { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.medname b { font-size: 1.1rem; overflow-wrap: anywhere; }
.medname span { color: var(--sub); font-size: .95rem; }
.take {
  min-width: 6.2em;
  min-height: 64px;
  background: var(--card);
  border: 3px solid var(--main);
  color: var(--main);
  font-weight: 700;
  font-size: 1.05rem;
  flex-direction: column;
  gap: 0;
  line-height: 1.2;
}
.take.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.take small { font-size: .75rem; font-weight: 400; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; flex-shrink: 0; background: var(--line); }
.thumb.big { width: 96px; height: 96px; }

.card.med { display: flex; gap: 12px; align-items: flex-start; }
.card.med .medname { flex-direction: row; flex-wrap: wrap; gap: .5em; align-items: baseline; }
.period { font-size: .9rem; color: var(--sub); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  min-height: 48px;
  padding: .2em .8em;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  font-size: .95rem;
  display: inline-flex;
  align-items: center;
  width: auto;
  margin: 0;
}
.chip.on, .chip.radio:has(input:checked) { border-color: var(--main); background: var(--main-soft); color: var(--main); font-weight: 700; }
.chip.static { min-height: 0; padding: .05em .6em; background: var(--main-soft); border-color: transparent; color: var(--main); font-weight: 700; }
.chip.radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip.radio { position: relative; cursor: pointer; }

.info {
  background: var(--warn-soft);
  border: 1px solid #e6c766;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 10px 0;
}
.notice {
  background: var(--warn-soft);
  border-left: 6px solid var(--warn);
  padding: 12px 14px;
  border-radius: 8px;
  margin: 12px 0;
}
.notice.soft { background: var(--main-soft); border-left-color: var(--main); }
.empty { text-align: center; padding: 20px 0; color: var(--sub); }
.hint { color: var(--sub); font-size: .9rem; display: block; }
.disclaimer { color: var(--sub); font-size: .82rem; margin-top: 28px; border-top: 1px solid var(--line); padding-top: 12px; }
.lead { font-size: 1.05rem; }

/* 入力 */
.form label { display: block; margin: 14px 0; font-weight: 700; }
.form label.check, .form label.chip { font-weight: 400; }
input[type='text'], input[type='date'], input[type='time'], input[type='number'], textarea {
  display: block;
  width: 100%;
  font: inherit;
  font-weight: 400;
  min-height: 56px;
  margin-top: 4px;
  padding: .3em .6em;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
}
input:disabled { background: #eeece6; color: #9a978f; }
textarea { min-height: 3.5em; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px 12px; margin: 14px 0; background: var(--card); }
legend { font-weight: 700; padding: 0 .3em; }
.check { display: flex !important; align-items: center; gap: .5em; min-height: 56px; cursor: pointer; margin: 0 !important; }
.check input { width: 32px; height: 32px; accent-color: var(--main); flex-shrink: 0; }
.slotrow { display: grid; grid-template-columns: 7em 1fr; align-items: center; gap: 8px; padding: 4px 0; border-top: 1px dashed var(--line); }
.slotrow:first-of-type { border-top: 0; }
.slotrow input[type='text'] { margin: 0; }
.form label.inline { display: grid; grid-template-columns: 5em 1fr; align-items: center; margin: 8px 0; }
.form label.inline input { margin: 0; }
.photo-pick { display: flex; align-items: center; gap: 12px; }
.photo-pick .filebtn { flex: 1; }

/* 予約票の読み取り */
.tips { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; margin: 12px 0; font-size: 1.05rem; }
.tips ul { margin: .2em 0; padding-left: 1.2em; }
img.ref { display: block; max-width: 100%; max-height: 50vh; margin: 8px auto; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.reading { text-align: center; padding: 12px 0; }
.progress { height: 20px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--main); transition: width .3s; }
.cand { background: var(--card); }
.cand.past { background: #f1efea; }
.cand-title { font-size: 1.3rem; font-weight: 700; margin: 4px 0 0; }
.cand .warn { color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: .3em .6em; font-weight: 700; margin: 4px 0; }
.cand .src { color: var(--sub); font-size: .85rem; overflow-wrap: anywhere; }
.raw pre { white-space: pre-wrap; font-size: .8rem; background: #fff; padding: 8px; border-radius: 8px; border: 1px solid var(--line); }

details { margin: 12px 0; }
summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; font-weight: 700; color: var(--main); }
details.photo img { width: 100%; border-radius: 8px; margin-top: 6px; }

/* きろく */
.hist { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; margin: 12px 0; }
.hist th, .hist td { border-bottom: 1px solid var(--line); padding: 10px 4px; text-align: center; }
.hist thead th { background: var(--main-soft); color: var(--main); font-size: .9rem; }
.hist tbody th { text-align: left; font-weight: 400; font-size: .9rem; white-space: nowrap; padding-left: 10px; }
.hist tbody tr { cursor: pointer; }
.hist td { font-size: 1.3rem; font-weight: 700; }
.hist .ok { color: var(--ok); }
.hist .part { color: var(--warn); }
.hist .ng { color: var(--ng); background: var(--ng-soft); }
.hist .wait { color: var(--sub); }

/* はじめての画面 */
.welcome { padding-top: calc(28px + env(safe-area-inset-top)); }
.welcome h1 { font-size: 1.6rem; color: var(--main); }
.points { padding-left: 1.2em; font-size: 1.05rem; }
.points li { margin: .5em 0; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #222;
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
  width: max-content;
  max-width: calc(100% - 32px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
