:root {
  --crimson: #9e2b25;
  --crimson-dark: #7c1f1a;
  --gold: #b98a2f;
  --ink: #2b2622;
  --paper: #faf7f2;
  --card: #ffffff;
  --line: #e5ddd2;
  --ok: #2e7d4f;
  --add: #b98a2f;
  --ng: #b0a698;
  --danger: #c0392b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

/* ---------- header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--crimson);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  background: #fff;
  color: var(--crimson);
  border-radius: 50%;
  font-weight: 700;
}
.brand h1 { font-size: 18px; font-weight: 700; letter-spacing: 2px; }
.tabs { display: flex; gap: 8px; }
.tab {
  border: 1px solid rgba(255,255,255,.5);
  background: transparent;
  color: #fff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
}
.tab.active { background: #fff; color: var(--crimson); font-weight: 700; border-color: #fff; }

/* ---------- layout ---------- */
.mode { display: none; max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; }
.mode.active { display: block; }
.step { display: none; }
.step.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.step-label {
  color: var(--gold);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 3px;
  margin-bottom: 4px;
}
.step h2 { font-size: 22px; margin-bottom: 8px; }
.hint { color: #7a7065; font-size: 14px; line-height: 1.7; margin-bottom: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 2px 10px rgba(43,38,34,.05);
}
.form-card label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.form-card input[type="text"],
.form-card input[type="search"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  font-size: 18px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fffdf9;
}
.form-card input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.form-card input[type="file"] { margin-bottom: 14px; font-size: 14px; }

.center-card { text-align: center; }
.confirm-name { font-size: 24px; font-weight: 700; margin: 14px 0; }
.confirm-q { font-size: 20px; font-weight: 700; margin: 18px 0; }
.keep-target { font-size: 20px; font-weight: 700; margin: 10px 0; line-height: 1.6; }
.done-check {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 34px;
  line-height: 64px;
}

/* ---------- buttons ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 600;
}
.btn.big { width: 100%; padding: 16px; font-size: 18px; margin-top: 6px; }
.btn.primary { background: var(--crimson); color: #fff; }
.btn.primary:active { background: var(--crimson-dark); }
.btn.ghost {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
}
.btn.scan { background: var(--ink); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn-row { display: flex; gap: 12px; margin-top: 10px; }
.btn-row .btn { flex: 1; }

.or-divider {
  text-align: center;
  color: #a99f92;
  margin: 16px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.err { color: var(--danger); font-weight: 600; margin-top: 12px; }

/* ---------- year grid ---------- */
.year-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.year-btn {
  padding: 26px 10px;
  font-size: 22px;
  font-weight: 700;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  color: var(--ink);
}
.year-btn small { display: block; font-size: 12px; color: #a99f92; font-weight: 500; margin-top: 4px; }
.year-btn:active { border-color: var(--crimson); color: var(--crimson); }

/* ---------- context bar ---------- */
.context-bar {
  background: #f3ecdf;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  color: #6d5b31;
}

/* ---------- result ---------- */
.result-head { margin-bottom: 8px; }
.brand-name { font-size: 24px; font-weight: 700; }
.price-line { color: #7a7065; font-size: 15px; margin-top: 4px; }
.size-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 14px 0;
}
.size-btn {
  position: relative;
  padding: 20px 6px 14px;
  font-size: 22px;
  font-weight: 700;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  cursor: pointer;
  background: #fff;
}
.size-btn small { display: block; font-size: 11px; font-weight: 600; margin-top: 5px; }
.size-btn.ok { border-color: var(--ok); color: var(--ok); }
.size-btn.add { border-color: var(--add); color: var(--add); }
.size-btn.ng {
  color: var(--ng);
  background: #f6f2ec;
  cursor: not-allowed;
  text-decoration: line-through;
}
.legend { display: flex; gap: 16px; font-size: 12px; color: #7a7065; margin-bottom: 16px; flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.dot.ok { background: var(--ok); }
.dot.add { background: var(--add); }
.dot.ng { background: var(--ng); }

.scan-video { width: 100%; border-radius: 12px; margin-bottom: 14px; }

.caution-box {
  background: #fdf3e4;
  border: 1px solid #e8c98a;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.8;
  color: #7a5a1e;
  margin-bottom: 14px;
}

/* ---------- admin ---------- */
.sub-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.sub-tab {
  border: 1.5px solid var(--line);
  background: #fff;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}
.sub-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.panel { display: none; }
.panel.active { display: block; }
.panel h2 { font-size: 19px; margin: 18px 0 8px; }
.count-badge {
  font-size: 13px;
  background: var(--gold);
  color: #fff;
  border-radius: 12px;
  padding: 2px 10px;
  vertical-align: middle;
}

.keep-list, .inv-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.keep-item, .inv-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.keep-item .info { flex: 1; min-width: 200px; }
.keep-item .title { font-weight: 700; font-size: 16px; }
.keep-item .meta { font-size: 13px; color: #7a7065; margin-top: 4px; line-height: 1.6; }
.keep-item .actions { display: flex; gap: 8px; }
.keep-item .btn { padding: 8px 14px; font-size: 14px; }

.status-chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  border-radius: 12px;
  padding: 3px 10px;
  margin-right: 8px;
}
.status-chip.keep { background: #e8f3ec; color: var(--ok); }
.status-chip.contract { background: #f7ecd8; color: #8a6410; }
.status-chip.expired { background: #f0ece6; color: var(--ng); }
.status-chip.released { background: #f0ece6; color: var(--ng); }

.inv-item .title { font-weight: 700; }
.inv-item .meta { font-size: 12px; color: #7a7065; margin-top: 3px; line-height: 1.6; }
.inv-search {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  margin-top: 8px;
  background: #fff;
}
.year-slots { font-size: 12px; margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.year-slot {
  border-radius: 6px;
  padding: 2px 8px;
  background: #eef5ef;
  color: var(--ok);
  font-weight: 600;
}
.year-slot.taken { background: #f6ecec; color: var(--danger); }

.csv-result { margin-top: 12px; font-weight: 600; color: var(--ok); white-space: pre-line; }
.csv-result.err { color: var(--danger); }

.empty-note {
  text-align: center;
  color: #a99f92;
  padding: 40px 10px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  line-height: 1.8;
}

/* ---------- login ---------- */
.login-gate {
  position: fixed;
  inset: 0;
  background: var(--paper);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
/* display:flex が hidden属性(UAのdisplay:none)を上書きしてしまうのを防ぐ */
.login-gate[hidden] { display: none; }
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 30px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(43,38,34,.08);
}
.login-brand .brand-mark {
  width: 52px; height: 52px;
  font-size: 22px;
  background: var(--crimson);
  color: #fff;
  margin-bottom: 10px;
}
.login-card h1 { font-size: 22px; letter-spacing: 3px; margin-bottom: 4px; }
.login-sub { color: #7a7065; font-size: 13px; margin-bottom: 22px; }
.login-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}
.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fffdf9;
  box-sizing: border-box;
}
.login-card input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.tab.logout { padding: 8px 12px; font-size: 15px; }
.login-ver { margin-top: 16px; font-size: 11px; color: #c5bcae; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  z-index: 100;
  max-width: 90vw;
}

@media (max-width: 480px) {
  .year-grid { grid-template-columns: repeat(2, 1fr); }
  .size-grid { grid-template-columns: repeat(3, 1fr); }
  .btn-row { flex-direction: column; }
}
