/* CBH ビールDB 入力アプリ — iPhone片手操作を前提にしたスタイル */

:root {
  --navy:   #0A1A39;   /* CBHブランド 紺 */
  --gold:   #F1BD3C;   /* CBHブランド 金 */
  --bg:     #F6F4EF;
  --card:   #FFFFFF;
  --ink:    #1B2430;
  --ink-2:  #5C6673;
  --line:   #DFDAD0;
  --danger: #B4342B;
  --ok:     #2E7D52;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden属性を必ず効かせる。下で .busy に display:flex を書いているため、
   これが無いと読み込み中の覆いが出たままになる */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px; line-height: 1.6;
  overscroll-behavior-y: none;
}

/* ── 画面切り替え ───────────────────────────────── */
.view { display: none; flex-direction: column; height: 100%; }
.view.is-active { display: flex; }

/* ── 上のバー ───────────────────────────────────── */
.bar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 10px) 12px 10px;
  background: var(--navy); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.bar h1 { font-size: 17px; margin: 0; flex: 1; font-weight: 600; letter-spacing: .02em; }
.bar-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.12); color: #fff; font-size: 19px; cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,.26); }
.pill {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: rgba(255,255,255,.16);
}
.pill.is-fixed { background: var(--gold); color: var(--navy); font-weight: 700; }

/* ── 一覧 ───────────────────────────────────────── */
.listtools { padding: 10px 12px 4px; background: var(--bg); position: sticky;
             top: calc(var(--safe-t) + 60px); z-index: 15; }
#search {
  width: 100%; padding: 11px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.chips { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip {
  flex: 0 0 auto; padding: 6px 13px; font-size: 13px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer;
}
.chip.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }

.list { flex: 1; overflow-y: auto; padding: 6px 12px calc(96px + var(--safe-b)); }
.row {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; margin-bottom: 8px; cursor: pointer;
}
.row:active { background: #FAF8F4; }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 600; font-size: 15px; }
.row-sub { font-size: 12.5px; color: var(--ink-2); overflow: hidden;
           text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.score { font-size: 17px; font-weight: 700; color: var(--navy); }
.tag { font-size: 10.5px; padding: 2px 7px; border-radius: 4px; }
.tag.draft { background: #FFF1D6; color: #8A5A00; }
.tag.fixed { background: #E7F1EA; color: var(--ok); }
.tag.nophoto { background: #F1EFEA; color: var(--ink-2); }

.empty { text-align: center; color: var(--ink-2); padding: 40px 20px; font-size: 14px; }

.banner {
  margin: 0 12px 8px; padding: 10px 12px; border-radius: 10px;
  background: #FFF1D6; color: #8A5A00; font-size: 13px;
}

.fab {
  position: fixed; right: 18px; bottom: calc(20px + var(--safe-b));
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--gold); color: var(--navy);
  font-size: 30px; line-height: 1; font-weight: 300;
  box-shadow: 0 6px 18px rgba(10,26,57,.28); cursor: pointer; z-index: 25;
}
.fab:active { transform: scale(.94); }

/* ── タブ ───────────────────────────────────────── */
.tabs { display: flex; background: var(--navy); padding: 0 8px 8px; position: sticky;
        top: calc(var(--safe-t) + 60px); z-index: 15; }
.tab {
  flex: 1; padding: 9px 0; font-size: 14px; border: 0; cursor: pointer;
  background: transparent; color: rgba(255,255,255,.6); border-bottom: 2px solid transparent;
}
.tab.is-on { color: #fff; border-bottom-color: var(--gold); font-weight: 600; }

/* ── フォーム ───────────────────────────────────── */
#edit-form { flex: 1; overflow-y: auto; }
.pane { display: none; padding: 14px 12px calc(20px + var(--safe-b)); }
.pane.is-on { display: block; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2);
               margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 12px; font-size: 16px; /* 16px未満だとiOSが勝手に拡大する */
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  color: var(--ink); font-family: inherit;
}
.field textarea { min-height: 72px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
.field.is-required label::after { content: ' *'; color: var(--danger); }
.hint { font-size: 11.5px; color: var(--ink-2); margin: 5px 0 0; line-height: 1.5; }
.counter { float: right; font-size: 11.5px; color: var(--ink-2); font-weight: 400; }
.counter.over { color: var(--danger); font-weight: 700; }

.choice { display: flex; flex-wrap: wrap; gap: 6px; }
.choice button {
  padding: 9px 14px; font-size: 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer;
}
.choice button.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* 採点 */
.scores { border: 1px solid var(--line); border-radius: 12px; background: var(--card);
          padding: 12px; margin: 4px 0 18px; }
.scores legend { font-size: 13px; font-weight: 700; color: var(--navy); padding: 0 6px; }
.score-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.score-row > span { width: 74px; font-size: 13.5px; font-weight: 600; flex: 0 0 auto; }
.score-btns { display: flex; gap: 5px; flex: 1; }
.score-btns button {
  flex: 1; height: 42px; border-radius: 9px; font-size: 15px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
}
.score-btns button.is-on { background: var(--gold); border-color: var(--gold);
                            color: var(--navy); font-weight: 700; }
.total { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); }
.total strong { font-size: 22px; color: var(--navy); margin: 0 4px; }
.total .note { display: block; font-size: 11px; }

.reasons { border: 1px solid var(--line); border-radius: 12px; background: var(--card);
           padding: 4px 12px; margin-bottom: 16px; }
.reasons summary { padding: 10px 0; font-size: 14px; font-weight: 600; cursor: pointer; }

.idbox { border: 1px dashed var(--line); border-radius: 12px; padding: 12px;
         background: #FBFAF7; }
.idbox label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2);
               margin-bottom: 5px; }
.idbox input { width: 100%; padding: 11px 12px; font-size: 16px; border-radius: 10px;
               border: 1px solid var(--line); font-family: ui-monospace, monospace; }
.idbox input:disabled { background: #EFEDE8; color: var(--ink-2); }

/* 写真 */
.photo-area { text-align: center; margin-bottom: 14px; }
#photo-preview { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }

/* ── ボタン・下部 ───────────────────────────────── */
.actions {
  display: flex; gap: 10px; padding: 10px 12px calc(10px + var(--safe-b));
  background: var(--card); border-top: 1px solid var(--line);
}
.btn {
  flex: 1; padding: 14px 12px; font-size: 15px; font-weight: 600;
  border-radius: 12px; border: 1px solid var(--line); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit;
}
/* .actions の外（設定画面・写真タブ）では flex:1 が効かないので幅を指定する */
.pane > .btn, .pane > label.btn { width: 100%; margin: 2px 0 6px; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-ghost   { background: #fff; color: var(--navy); }
.btn:active  { opacity: .8; }
.btn:disabled { opacity: .45; }

.result { font-size: 13.5px; padding: 10px 0; }
.result.ok { color: var(--ok); }
.result.ng { color: var(--danger); }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
h2 { font-size: 15px; margin: 0 0 6px; }

/* ── トースト・待ち ─────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 13.5px; max-width: 88vw; text-align: center; z-index: 60;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast.ng { background: var(--danger); }

.busy {
  position: fixed; inset: 0; background: rgba(246,244,239,.66); z-index: 70;
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--navy);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
