/* ============================================================
   お買い物リスト — スタイルシート
   開発ポリシー第4章(シリーズ統一デザイン)準拠・モバイルファースト
   ============================================================ */

:root {
  --hdr-bg: linear-gradient(135deg, #1a2332, #243447);
  --body-bg: #f5f7fa;
  --card: #ffffff;
  --card-border: #e8ecf1;
  --input-bg: #f5f7fa;
  --input-border: #dde2ea;
  --text: #1e2a3a;
  --dim: #7b8a9e;
  --accent: #3b6ef6;
  --accent-hover: #2d5ad4;
  --green: #10b97e;
  --red: #e04848;
  --yellow: #d4960e;
  --orange: #f59e0b;
  /* チェック済みアイテム(中程度のグレー塗りつぶし) */
  --checked-bg: #d7dde5;
  --checked-text: #6b7686;
}

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

html, body { height: 100%; }

body {
  font-family: "Meiryo UI", "Yu Gothic UI", "Segoe UI", "Hiragino Sans", sans-serif;
  background: #dfe4ea; /* PCで見たとき、アプリ外周を少し暗くする */
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* アプリ全体: スマホでは全画面、PCでは中央に480px幅 */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--body-bg);
  box-shadow: 0 0 24px rgba(0, 0, 0, .12);
}

/* ---------- ヘッダー ---------- */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  padding-top: calc(8px + env(safe-area-inset-top)); /* iPhoneのノッチ対応 */
  min-height: 52px;
  background: var(--hdr-bg);
  color: #fff;
  flex-shrink: 0;
}

.header-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b6ef6, #2d5ad4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}

.header-titles { flex: 1; } /* これ以降の要素(バッジ・共有)は右寄せになる */
.header-title { font-size: 16px; font-weight: 700; line-height: 1.2; }
.header-sub { font-size: 10px; color: #8ba4c4; }

.dev-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.btn-share {
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .25);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-share:active { background: rgba(255, 255, 255, .2); }

/* ---------- タブ ---------- */
.tabs-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 4px;
  flex-shrink: 0;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--dim);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tab.active::after {
  content: " ✏️";
  font-size: 11px;
}

.tab-add {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px dashed var(--input-border);
  background: transparent;
  color: var(--dim);
  font-size: 18px;
  cursor: pointer;
}

/* ---------- 残り件数 ---------- */
.count-line {
  padding: 2px 16px 6px;
  font-size: 11px;
  color: var(--dim);
  flex-shrink: 0;
  min-height: 18px;
}

/* ---------- リスト本体 ---------- */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 2px 10px 16px;
  -webkit-overflow-scrolling: touch;
}

.item-list { list-style: none; }

.item {
  display: flex;
  align-items: center;
  min-height: 52px;
  margin-bottom: 8px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
  animation: fadeUp .3s;
  overflow: hidden;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* チェック部分(タップ領域を広く取る) */
.item-check {
  display: flex;
  align-items: center;
  align-self: stretch;
  padding: 0 12px 0 14px;
  background: none;
  border: none;
  cursor: pointer;
}

.item-check .circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--input-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #fff;
  background: transparent;
  transition: background .15s, border-color .15s;
}

.item-name {
  flex: 1;
  padding: 14px 4px 14px 0;
  font-size: 15px;
  line-height: 1.4;
  word-break: break-all;
  cursor: pointer;
}

.item-delete {
  align-self: stretch;
  padding: 0 16px;
  background: none;
  border: none;
  color: var(--dim);
  font-size: 16px;
  cursor: pointer;
}

/* チェック済みの見た目(中程度のグレーで塗りつぶし) */
.item.checked {
  background: var(--checked-bg);
  border-color: var(--checked-bg);
  box-shadow: none;
}

.item.checked .item-name {
  color: var(--checked-text);
  text-decoration: line-through;
}

.item.checked .circle {
  background: var(--green);
  border-color: var(--green);
}

/* 空のとき */
.empty-state {
  text-align: center;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.9;
  padding: 48px 16px;
}

/* ---------- 一括削除ボタン ---------- */
.bulk-actions {
  display: flex;
  gap: 8px;
  padding: 12px 4px 4px;
}

.bulk-actions .btn { flex: 1; }

/* ---------- 入力バー(下部固定) ---------- */
.input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom)); /* iPhoneのホームバー対応 */
  background: var(--card);
  border-top: 1px solid var(--card-border);
  flex-shrink: 0;
}

.item-input {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  font-size: 16px; /* 16px未満だとiPhoneで自動ズームされるため */
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  outline: none;
}

.item-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 110, 246, .15);
}

/* ---------- ボタン共通 ---------- */
.btn {
  height: 44px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-outline {
  background: var(--card);
  border: 1px solid var(--input-border);
  color: var(--dim);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-outline-danger {
  background: var(--card);
  border: 1px solid var(--input-border);
  color: var(--red);
}
.btn-outline-danger:hover { border-color: var(--red); }

.btn-danger {
  background: var(--red);
  border: 1px solid var(--red);
  color: #fff;
}

/* ---------- トースト(元に戻す) ---------- */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(78px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 92vw;
  background: #1e2a3a;
  color: #fff;
  font-size: 13px;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
  animation: fadeUp .25s;
  z-index: 20;
}

.toast-msg {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-undo {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #6f9bff;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  padding: 6px;
}

/* ---------- モーダル ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 40, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}

.modal {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 14px;
  padding: 20px 18px 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .2);
  animation: fadeUp .2s;
}

.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.modal-body { font-size: 13px; color: var(--dim); line-height: 1.7; margin-bottom: 12px; }

.modal-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  outline: none;
  margin-bottom: 14px;
}

.modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 110, 246, .15);
}

.modal-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-spacer { flex: 1; }

[hidden] { display: none !important; }
