/* =========================================================================
   白樺リゾート 点検 — 現場で使うことだけを考えた画面
   直射日光下での可読性、手袋での操作、片手保持を前提に組んでいる。
   ========================================================================= */

:root {
  --paper:        #F6F6F1;
  --field:        #FFFFFF;
  --ink:          #191C17;
  --ink-soft:     #565D53;
  --rule:         #D3D6CA;
  --rule-strong:  #A8AD9C;

  --accent:       #1F5C3D;
  --accent-press: #164430;

  --good:         #1F7A4D;
  --observation:  #8A6100;
  --improvement:  #B4460F;
  --unusable:     #A31B1B;

  --error-bg:     #FCEDEA;
  --error-line:   #A31B1B;

  --tap:          56px;
  --gutter:       clamp(16px, 4.5vw, 24px);
  --measure:      560px;

  --shadow-lift:  0 1px 0 var(--rule), 0 2px 6px rgb(25 28 23 / 6%);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { margin: 0; line-height: 1.35; font-weight: 700; }

/* ------------------------------------------------------------- masthead */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--accent);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) 12px;
}

.masthead__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--measure);
  margin-inline: auto;
}

.masthead__title {
  font-size: 1.0625rem;
  letter-spacing: 0.04em;
}

.masthead__meta {
  max-width: var(--measure);
  margin: 2px auto 0;
  font-size: 0.8125rem;
  color: #D6E5DC;
}

.masthead__spacer { width: 44px; }

.masthead .linkbtn { color: #D6E5DC; }
.masthead .linkbtn:hover { color: #fff; }

/* ------------------------------------------------------------ メニュー */

.iconbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: -10px;
  border: 0;
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

.iconbtn__bars,
.iconbtn__bars::before,
.iconbtn__bars::after {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  content: '';
}

.iconbtn__bars { position: relative; }
.iconbtn__bars::before { position: absolute; top: -7px; }
.iconbtn__bars::after  { position: absolute; top: 7px; }

.drawer { position: fixed; inset: 0; z-index: 40; }

.drawer__scrim {
  position: absolute;
  inset: 0;
  background: rgb(25 28 23 / 45%);
}

.drawer__panel {
  position: absolute;
  inset: 0 auto 0 0;
  width: min(300px, 84vw);
  padding: calc(env(safe-area-inset-top) + 16px) 16px 16px;
  background: var(--paper);
  box-shadow: 2px 0 12px rgb(25 28 23 / 18%);
  overflow-y: auto;
}

.drawer__close {
  min-height: 44px;
  margin-bottom: 8px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.drawer__list { margin: 0; padding: 0; list-style: none; }

.drawer__item {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 14px 8px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.drawer__item:hover { background: #EDEEE7; }
.drawer__item--danger { color: var(--unusable); }

.drawer__ext {
  display: block;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

/* --------------------------------------------------- signature: 方眼タリー
   20項目を測量野帳の方眼に見立てて並べる。評価すると色が入る。
   「あと何個」が常に視界に入ることが、この画面の一番の仕事。 */

.tally {
  position: sticky;
  top: 0;
  z-index: 19;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  max-width: var(--measure);
  margin-inline: auto;
  padding: 10px var(--gutter);
  background: var(--paper);
  box-shadow: var(--shadow-lift);
}

.tally__cell {
  aspect-ratio: 1;
  border: 1px solid var(--rule-strong);
  background: var(--field);
  padding: 0;
  font: inherit;
  font-size: 0.625rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.tally__cell[data-rating]      { color: #fff; border-color: transparent; }
.tally__cell[data-rating="good"]        { background: var(--good); }
.tally__cell[data-rating="observation"] { background: var(--observation); }
.tally__cell[data-rating="improvement"] { background: var(--improvement); }
.tally__cell[data-rating="unusable"]    { background: var(--unusable); }

.tally__cell[aria-current="true"] {
  outline: 3px solid var(--ink);
  outline-offset: -1px;
}

/* ---------------------------------------------------------------- layout */

.screen { padding: 0 0 40px; }

.pane {
  max-width: var(--measure);
  margin-inline: auto;
  padding: 20px var(--gutter) 0;
}

.pane--center { text-align: center; padding-top: 32px; }

.pane__title { font-size: 1.25rem; margin-bottom: 14px; }

.pane__foot { margin-top: 24px; }

.pane__foot--split {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}

.lede {
  margin: 0 0 22px;
  color: var(--ink-soft);
}

.note {
  margin: 14px 0 0;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.crumb {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 14px;
}

.crumb__pos {
  min-width: 0;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- 入力 */

.field { margin-bottom: 22px; }

.field__label {
  display: block;
  margin-bottom: 7px;
  font-weight: 700;
  font-size: 0.9375rem;
}

.field__opt {
  margin-left: 8px;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.field__input {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 2px solid var(--rule-strong);
  border-radius: 4px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
}

.field__input--area { min-height: 96px; resize: vertical; }

/* 日付欄は中身の幅に合わせる。100%だと日付の右に空白が大きく空いて不格好になる。
   iOS Safari は appearance を戻さないと内側の余白が崩れる。 */
.field__input--date {
  width: auto;
  max-width: 100%;
  min-width: 11em;
  -webkit-appearance: none;
  appearance: none;
}

.field__input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* --------------------------------------------------------------- ボタン */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 14px 20px;
  border: 2px solid transparent;
  border-radius: 4px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.btn--block { width: 100%; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-press); }

.btn--ghost {
  background: var(--field);
  color: var(--ink);
  border-color: var(--rule-strong);
}
.btn--ghost:hover { border-color: var(--ink-soft); }

.btn--danger { background: var(--unusable); color: #fff; }
.btn--danger:hover { background: #871616; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn:focus-visible,
.tally__cell:focus-visible,
.linkbtn:focus-visible,
.itemlist__row:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.linkbtn {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  font-size: 0.9375rem;
  cursor: pointer;
}

/* ----------------------------------------------------------- 評価ボタン */

.ratings {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.rating {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 12px 16px;
  border: 2px solid var(--rule-strong);
  border-radius: 4px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.rating__mark {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 2px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--field);
}

.rating[aria-checked="true"] { color: #fff; border-color: transparent; }
.rating[aria-checked="true"] .rating__mark {
  border-color: #fff;
  background: #fff;
  box-shadow: inset 0 0 0 5px currentColor;
}

.rating[data-rating="good"][aria-checked="true"]        { background: var(--good); }
.rating[data-rating="observation"][aria-checked="true"] { background: var(--observation); }
.rating[data-rating="improvement"][aria-checked="true"] { background: var(--improvement); }
.rating[data-rating="unusable"][aria-checked="true"]    { background: var(--unusable); }

/* --------------------------------------------------------------- ホーム */

.bigaction {
  display: block;
  width: 100%;
  padding: 22px 20px;
  border: 0;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.bigaction:hover { background: var(--accent-press); }

.bigaction__label {
  display: block;
  font-size: 1.375rem;
  font-weight: 700;
}

.bigaction__sub {
  display: block;
  margin-top: 4px;
  font-size: 0.875rem;
  color: #D6E5DC;
}

.pane__title--section {
  margin-top: 30px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.historylist { margin: 0; padding: 0; list-style: none; }

.historylist__row {
  display: grid;
  grid-template-columns: 1fr 72px;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: var(--tap);
  padding: 13px 4px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.historylist__row:hover { background: #EDEEE7; }
.historylist__row.is-loading { opacity: 0.55; }

.historylist__date {
  display: block;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.historylist__sub {
  display: block;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.minibar {
  display: flex;
  height: 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  overflow: hidden;
  background: var(--field);
}

.minibar span { display: block; }

.minibar .seg--good        { background: var(--good); }
.minibar .seg--observation { background: var(--observation); }
.minibar .seg--improvement { background: var(--improvement); }
.minibar .seg--unusable    { background: var(--unusable); }

/* --------------------------------------------------------------- 項目一覧 */

.itemlist { margin: 0; padding: 0; list-style: none; }

.itemlist__row {
  display: grid;
  grid-template-columns: 2.25rem 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 4px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.itemlist__no {
  font-size: 0.8125rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.itemlist__name { font-weight: 700; }

.itemlist__area {
  display: block;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ink-soft);
}

.chip {
  padding: 5px 10px;
  border-radius: 3px;
  font-size: 0.8125rem;
  font-weight: 700;
  white-space: nowrap;
}

.chip--pending {
  border: 1px dashed var(--rule-strong);
  color: var(--ink-soft);
}

.chip--good        { background: var(--good);        color: #fff; }
.chip--observation { background: var(--observation); color: #fff; }
.chip--improvement { background: var(--improvement); color: #fff; }
.chip--unusable    { background: var(--unusable);    color: #fff; }

.itemlist__cam {
  margin-left: 6px;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

/* ----------------------------------------------------------------- 写真 */

.photo__preview {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  margin-bottom: 10px;
}

.photo__actions { display: flex; gap: 10px; }
.photo__actions .btn { flex: 1; }

.photo__sent {
  margin: 8px 0 0;
  font-size: 0.8125rem;
  color: var(--good);
  font-weight: 700;
}

/* 過去の点検を開いたときは、Driveに保存済みの写真へのリンクだけを持つ */
.photo__link {
  display: inline-block;
  min-height: 44px;
  margin-bottom: 10px;
  padding: 10px 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9375rem;
}

.btn--link { text-decoration: none; }

/* --------------------------------------------------------------- 確認画面 */

.summary {
  margin: 0 0 20px;
  border-top: 1px solid var(--rule);
}

.summary div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--rule);
}

.summary dt { color: var(--ink-soft); font-size: 0.9375rem; }
.summary dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.tallybar {
  display: flex;
  height: 12px;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
  background: var(--field);
  border: 1px solid var(--rule-strong);
}

.tallybar span { display: block; }
.tallybar .seg--good        { background: var(--good); }
.tallybar .seg--observation { background: var(--observation); }
.tallybar .seg--improvement { background: var(--improvement); }
.tallybar .seg--unusable    { background: var(--unusable); }

/* --------------------------------------------------------- 送信中・エラー */

.progress { margin-top: 18px; }

.progress__bar {
  height: 8px;
  border-radius: 2px;
  background: var(--rule);
  overflow: hidden;
}

.progress__bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 220ms ease;
}

.progress__label {
  margin: 8px 0 0;
  font-size: 0.875rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.alert {
  margin-top: 20px;
  padding: 16px;
  border-radius: 4px;
}

.alert--error {
  background: var(--error-bg);
  border-left: 6px solid var(--error-line);
}

.alert__title { font-size: 1rem; margin-bottom: 6px; }

.alert__body {
  margin: 0 0 14px;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.alert__note {
  margin: 10px 0 0;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------- 完了画面 */

.receipt {
  padding: 26px 20px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: var(--field);
}

.receipt__eyebrow {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.receipt__count {
  margin: 0 0 16px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.receipt__count strong {
  font-size: 3rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.receipt__detail {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 0.9375rem;
  text-align: left;
}

.receipt__detail div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 0;
}

.receipt__detail dt { color: var(--ink-soft); }
.receipt__detail dd { margin: 0; font-weight: 700; }

/* -------------------------------------------------------------- オフライン */

.offline-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--observation);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  text-align: center;
}

/* ------------------------------------------------------------------ 環境 */

@media (min-width: 600px) {
  body { font-size: 18px; }
  .tally { gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
