/* MissionTodo — 基本スタイル（デフォルトテーマ） */
:root {
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", sans-serif;
  --outside: #2d2622;
  --bg: #e8e0d5;
  --bg-stripe: rgba(110, 90, 70, 0.04);
  --top: #d9cec1;
  --ink: #3e2f27;
  --ink-soft: #7b6b60;
  --ink-faint: #a39487;
  --brown: #5c4a42;
  --brown-deep: #3b2f29;
  --line: #6d5d52;
  --line-soft: #ab9c8e;
  --panel: #e3d9cd;
  --panel-in: #efe8de;
  --field: #f2ebe2;
  --card: #6f635b;
  --card-edge: #463a33;
  --card-line: #a29385;
  --card-title: #f6f0e9;
  --card-text: #ddd3c8;
  --pt: #f3d46c;
  --time: #d7ead0;
  --time-icon: #8fd29a;
  --banner-1: #bb9066;
  --banner-2: #9e7551;
  --banner-edge: #4f392c;
  --banner-ink: #3a2a20;
  --accent: #ec9f37;
  --good: #3f9b58;
  --danger: #b4463a;
  --on-dark: #f4ede6;
  --radius: 6px;
  --ornament: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 48'%3E%3Cpath d='M34 9C24 9 20 3 13 5 6 7 4 14 9 18c4 3 9 0 8-4' fill='none' stroke='%23493226' stroke-width='3.4' stroke-linecap='round'/%3E%3Cpath d='M34 39c-10 0-14 6-21 4-7-2-9-9-4-13 4-3 9 0 8 4' fill='none' stroke='%23493226' stroke-width='3.4' stroke-linecap='round'/%3E%3Cpath d='M35 24H20c-5 0-8-4-14 0 6 4 9 0 14 0' fill='%23493226' stroke='%23493226' stroke-width='2.4' stroke-linejoin='round'/%3E%3Ccircle cx='6.5' cy='24' r='3.2' fill='%23c9a36a' stroke='%23493226' stroke-width='1.8'/%3E%3Cpath d='M34.5 4v40' stroke='%23493226' stroke-width='3.5' stroke-linecap='round'/%3E%3Cpath d='M13 7.5c-3 1-5 4-3 7' fill='none' stroke='%23b48a5a' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(circle at 50% 0, #3e3530, var(--outside) 70%);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.ic { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -0.12em; }

/* ---------- フレーム（スマホ幅） ---------- */
.frame {
  position: relative;
  max-width: 440px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: repeating-linear-gradient(0deg, var(--bg-stripe) 0 1px, transparent 1px 4px), var(--bg);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

/* ---------- ステータスバー ---------- */
.status {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 6px;
  background: linear-gradient(var(--top), color-mix(in srgb, var(--top) 88%, #000));
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.st-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.st-back { font-size: 20px; color: var(--brown); display: grid; place-items: center; width: 26px; height: 26px; }
.nameplate {
  flex: 1;
  min-width: 0;
  max-width: 132px;
  height: 22px;
  padding: 1.5px;
  background: var(--brown-deep);
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 9px 100%, 0 50%);
}
.nameplate span {
  display: block;
  height: 100%;
  padding: 0 12px;
  background: linear-gradient(#6a574d, var(--brown));
  color: var(--on-dark);
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
  box-shadow: inset 0 0 0 1px #9a8a7c;
}
.st-mid { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.lvl {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 35%, #6e5b50, var(--brown-deep));
  border: 2px solid #d9ccbe;
  box-shadow: 0 0 0 2px var(--brown-deep), inset 0 0 0 2px #7d6a5e;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}
.expbar { width: 42px; height: 5px; border-radius: 3px; background: #7d6d62; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.3); overflow: hidden; }
.expbar i { display: block; height: 100%; background: linear-gradient(#f8c865, var(--accent)); transition: width 0.6s ease; }
.st-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.st-row { display: flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 700; color: var(--ink); }
.st-row .box {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  min-width: 66px;
  height: 17px;
  padding: 0 7px;
  background: var(--panel-in);
  border: 1.5px solid var(--line);
  border-radius: 5px;
  font-size: 10px;
}
.st-row .box .ic { color: var(--ink-faint); font-size: 9px; margin-right: auto; }
.st-row .box em { font-style: normal; }

/* ---------- 見出しバナー ---------- */
.banner {
  position: relative;
  height: 30px;
  margin: 10px 26px 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(var(--banner-1), var(--banner-2));
  border-top: 2px solid var(--banner-edge);
  border-bottom: 2px solid var(--banner-edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  color: var(--banner-ink);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.banner span { max-width: 100%; padding: 0 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner::before, .banner::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 30px;
  height: 44px;
  background: var(--ornament) center / contain no-repeat;
  pointer-events: none;
}
.banner::before { left: -24px; }
.banner::after { right: -24px; transform: scaleX(-1); }
.banner.sm { height: 24px; margin: 2px 22px 12px; font-size: 11px; }
.banner.sm::before, .banner.sm::after { top: -8px; width: 24px; height: 36px; }
.banner.sm::before { left: -19px; }
.banner.sm::after { right: -19px; }

/* ---------- メイン ---------- */
.main { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 12px; overscroll-behavior: contain; }
.main.fixed { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }

/* ---------- 下部ナビ ---------- */
.nav { display: flex; justify-content: space-around; padding: 6px 12px calc(8px + env(safe-area-inset-bottom)); }
.nav-btn { position: relative; width: 80px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--brown); }
.hex {
  width: 32px;
  height: 32px;
  padding: 2px;
  background: #cbbdaf;
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  transition: transform 0.15s;
}
.hex span {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 35%, #75625a, var(--brown));
  clip-path: inherit;
  color: var(--on-dark);
  font-size: 15px;
}
.nav-btn b { font-size: 9.5px; font-weight: 800; opacity: 0.8; }
.nav-btn.on .hex { transform: scale(1.15); }
.nav-btn.on b { font-size: 11px; opacity: 1; }
.nav-btn .new {
  position: absolute;
  top: -5px;
  left: calc(50% + 4px);
  padding: 0 4px;
  border-radius: 6px;
  background: #e0443a;
  color: #fff;
  font-size: 8px;
  font-style: normal;
  font-weight: 800;
  line-height: 13px;
}

/* ---------- タブ・パネル・並び替え ---------- */
.tabs { display: flex; justify-content: center; gap: 12px; position: relative; z-index: 1; margin-bottom: -2px; }
.tab {
  min-width: 80px;
  height: 30px;
  padding: 0 12px;
  border: 2px solid var(--brown);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: var(--panel-in);
  box-shadow: inset 0 0 0 2px var(--panel-in), inset 0 0 0 3px var(--line-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}
.tab.on { background: var(--brown); color: var(--on-dark); box-shadow: inset 0 0 0 2px var(--brown), inset 0 0 0 3px #a08f80; }
.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px var(--panel), inset 0 0 0 3px var(--line-soft);
  padding: 6px 7px 7px;
}
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1px; }
.sortbar { display: flex; align-items: center; gap: 8px; padding: 2px 3px 7px; font-size: 10.5px; white-space: nowrap; }
.sortbar > b { color: var(--ink); font-weight: 800; }
.sort-opts { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; }
.sort-opts::-webkit-scrollbar { display: none; }
.sort-opt { color: var(--ink-faint); font-weight: 700; }
.sort-opt.on { color: var(--ink); font-weight: 800; }
.sortbar .icon-btn { margin-left: auto; }
.icon-btn { display: inline-grid; place-items: center; width: 26px; height: 22px; color: var(--ink); font-size: 16px; border-radius: 4px; }
.icon-btn.on { background: var(--brown); color: var(--on-dark); }
.link-btn { display: block; margin: 8px auto 4px; padding: 4px 16px; color: var(--ink); font-size: 12px; font-weight: 800; }

/* ---------- ボタン ---------- */
.btn {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0 0 9px;
  padding: 9px 12px;
  background: var(--panel-in);
  border: 2px solid var(--line);
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px var(--panel-in), inset 0 0 0 3px var(--line-soft);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 800;
  text-align: center;
  transition: transform 0.08s, filter 0.08s;
}
.btn:active { transform: scale(0.98); filter: brightness(0.96); }
.btn.primary { background: var(--brown); color: var(--on-dark); box-shadow: inset 0 0 0 2px var(--brown), inset 0 0 0 3px #a08f80; }
.btn.danger { color: var(--danger); }
.btn.sm { display: inline-block; width: auto; min-height: 32px; padding: 5px 14px; font-size: 12px; border-radius: 8px; margin: 0; }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn .ic { margin-right: 6px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ---------- 入力 ---------- */
.field { position: relative; margin: 14px 0 10px; }
.field .fl {
  position: absolute;
  top: -7px;
  left: 8px;
  z-index: 1;
  padding: 0 4px;
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
}
.field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .field textarea, .field select {
  width: 100%;
  min-height: 44px;
  padding: 11px 10px 9px;
  background: var(--field);
  border: 1.5px solid var(--line-soft);
  border-radius: 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  outline: none;
}
.field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brown); }
.field .suffix { position: absolute; right: 12px; top: 13px; color: var(--ink-soft); font-size: 13px; font-weight: 800; pointer-events: none; }
.field .hint { display: block; margin: 4px 2px 0; color: var(--ink-soft); font-size: 10.5px; line-height: 1.5; }
.field.err input, .field.err textarea { border-color: var(--danger); }
.form-err { color: var(--danger); font-size: 12px; font-weight: 700; margin: 4px 2px; }

.check-row, .switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 6px 8px; font-size: 13px; font-weight: 800; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--brown); }
.switch-row { border-bottom: 1px dashed var(--line-soft); }
.switch-row .sr-text small { display: block; margin-top: 2px; color: var(--ink-soft); font-size: 10.5px; font-weight: 700; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row .sw { position: relative; flex: none; width: 44px; height: 24px; border-radius: 12px; background: #b9ab9d; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25); transition: background 0.2s; }
.switch-row .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.2s; }
.switch-row input:checked + .sw { background: var(--brown); }
.switch-row input:checked + .sw::after { transform: translateX(20px); }
.switch-row input:focus-visible + .sw { outline: 2px solid var(--accent); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; min-width: 42px; padding: 7px 10px; border: 1.5px solid var(--line-soft); border-radius: 8px; background: var(--field); color: var(--ink); font-size: 12px; font-weight: 800; text-align: center; cursor: pointer; }
.seg input:checked + span { background: var(--brown); border-color: var(--brown); color: var(--on-dark); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

/* ---------- ダイアログ ---------- */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(24, 16, 12, 0.55);
  animation: fade-in 0.15s ease;
}
.modal-back.out { animation: fade-out 0.17s ease forwards; }
.modal {
  width: min(360px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 14px 16px 8px;
  background: var(--panel-in);
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: inset 0 0 0 3px var(--panel-in), inset 0 0 0 4px var(--line-soft), 0 12px 36px rgba(0, 0, 0, 0.45);
  animation: pop-in 0.18s ease;
}
.modal .banner { background: linear-gradient(var(--banner-1), var(--banner-2)); }
.modal-msg { margin: 4px 2px 14px; font-size: 13.5px; font-weight: 700; line-height: 1.7; text-align: center; white-space: pre-line; }
.modal-actions { margin-top: 8px; }
.menu-sub { margin: 10px 0 4px; color: var(--ink-soft); font-size: 11px; font-weight: 700; text-align: center; }
.menu-modal .close-btn { margin-top: 18px; }

.toast {
  position: fixed;
  top: 84px;
  left: 50%;
  z-index: 300;
  max-width: min(400px, 90vw);
  padding: 9px 18px;
  border-radius: 18px;
  background: rgba(46, 35, 29, 0.94);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  animation: toast-in 0.2s ease;
  pointer-events: none;
}
.toast.error { background: rgba(150, 45, 38, 0.95); }
.toast.out { animation: fade-out 0.35s ease forwards; }
.snackbar {
  position: fixed;
  left: 50%;
  bottom: 84px;
  z-index: 250;
  width: min(416px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #3b2f29;
  color: #f3ece4;
  font-size: 13px;
  font-weight: 700;
  transform: translateX(-50%);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  animation: snack-in 0.22s ease;
}
.snackbar span { flex: 1; min-width: 0; }
.snackbar button { color: #ffc566; font-weight: 800; padding: 4px 6px; white-space: nowrap; }
.snackbar.out { animation: snack-out 0.22s ease forwards; }

.empty { padding: 36px 16px; text-align: center; color: var(--ink-soft); font-size: 12.5px; font-weight: 700; line-height: 1.8; }
.empty .btn { margin: 14px auto 0; max-width: 240px; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.92); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -10px); } }
@keyframes snack-in { from { opacity: 0; transform: translate(-50%, 16px); } }
@keyframes snack-out { to { opacity: 0; transform: translate(-50%, 16px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (min-width: 480px) {
  .frame { border-left: 1px solid rgba(0, 0, 0, 0.3); border-right: 1px solid rgba(0, 0, 0, 0.3); }
}

/* ---------- スマホ（ホーム画面アプリ） ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior: none; }
body { overscroll-behavior: none; }
button, label, .scard, .ecard, .cal-cell { touch-action: manipulation; }
img { -webkit-touch-callout: none; }
.toast { top: calc(84px + env(safe-area-inset-top)); }
.snackbar { bottom: calc(84px + env(safe-area-inset-bottom)); }
@media (hover: none) and (pointer: coarse) {
  /* iPhone で入力欄をタップしたときに画面が拡大されないよう 16px 以上にする */
  .field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .field textarea, .field select { font-size: 16px; }
  .mcard:hover, .scard:hover { filter: none; }
}

/* ---------- 環境表示（本番以外） ---------- */
.env-bar {
  flex: none;
  padding: calc(3px + env(safe-area-inset-top)) 8px 3px;
  background: repeating-linear-gradient(45deg, #d9822b 0 10px, #c9741f 10px 20px);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.env-bar.dev { background: repeating-linear-gradient(45deg, #5a7fa8 0 10px, #4d7099 10px 20px); }
.env-bar + .status { padding-top: 8px; }
