:root {
  --bg: #fffaf3;
  --card: #ffffff;
  --text: #2a211b;
  --muted: #7d6d62;
  --primary: #f08a4b;
  --primary-dark: #cf6c2f;
  --border: #eadfd4;
  --danger: #c94b4b;
  --secret-bg: #17151d;
  --secret-card: #24202e;
  --secret-text: #f7eefc;
  --secret-muted: #b9a9c6;
  --secret-primary: #b77cff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

button:active {
  transform: scale(0.98);
}

button.ghost {
  background: transparent;
  color: var(--primary-dark);
  border: 1px solid var(--border);
}

button.danger {
  background: var(--danger);
}

button.small {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  padding: 12px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.app {
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: 88px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(16px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(255, 250, 243, 0.94);
  backdrop-filter: blur(14px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
}

h1 {
  margin: 0;
  font-size: 24px;
}

h2 {
  font-size: 18px;
  margin: 0 0 12px;
}

p {
  line-height: 1.65;
}

.view {
  padding: 12px 16px 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 16px;
  margin: 0 0 14px;
  box-shadow: 0 8px 24px rgba(80, 48, 18, 0.05);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row > * {
  flex: 1;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  padding: 12px;
  border-radius: 16px;
  background: #fff7ee;
  border: 1px solid var(--border);
}

.item-title {
  font-weight: 800;
}

.item-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.notice {
  margin: 12px 16px 0;
  padding: 14px;
  border-radius: 18px;
  background: #fff0d9;
  border: 1px solid #f3d0a5;
}

.notice p {
  margin: 6px 0 10px;
  font-size: 13px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(520px, 100%);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  background: rgba(255, 250, 243, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}

.bottom-nav button {
  background: transparent;
  color: var(--muted);
  padding: 9px 4px;
  border-radius: 12px;
  font-size: 12px;
}

.bottom-nav button.active {
  background: #ffe8d5;
  color: var(--primary-dark);
}

.chat-log {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.bubble {
  padding: 12px;
  border-radius: 18px;
  white-space: pre-wrap;
  line-height: 1.65;
}

.bubble.user {
  background: #ffe2ca;
  margin-left: 38px;
}

.bubble.ai {
  background: #fff;
  border: 1px solid var(--border);
  margin-right: 38px;
}

.hidden {
  display: none !important;
}

/* secret mode */
body.secret {
  background: var(--secret-bg);
  color: var(--secret-text);
}

body.secret .app-header,
body.secret .bottom-nav {
  background: rgba(23, 21, 29, 0.94);
  border-color: #383143;
}

body.secret .eyebrow,
body.secret .muted,
body.secret label,
body.secret .item-meta {
  color: var(--secret-muted);
}

body.secret .card {
  background: var(--secret-card);
  border-color: #383143;
  box-shadow: none;
}

body.secret input,
body.secret textarea,
body.secret select {
  background: #17151d;
  color: var(--secret-text);
  border-color: #40384b;
}

body.secret button {
  background: var(--secret-primary);
}

body.secret button.ghost {
  background: transparent;
  color: var(--secret-primary);
  border-color: #40384b;
}

body.secret .bottom-nav button {
  background: transparent;
  color: var(--secret-muted);
}

body.secret .bottom-nav button.active {
  background: #332543;
  color: #e4c8ff;
}

body.secret .item {
  background: #1c1924;
  border-color: #383143;
}

body.secret .bubble.user {
  background: #3a2454;
}

body.secret .bubble.ai {
  background: #201b29;
  border-color: #383143;
}

body.secret .notice {
  background: #2b2435;
  border-color: #4a3b5c;
  color: #f7eefc;
}

body.secret .notice strong,
body.secret .notice p {
  color: #f7eefc;
}

body.secret .notice button {
  background: #b77cff;
  color: #ffffff;
}

body.secret {
  --bg: #17151d;
  --card: #24202e;
  --text: #f7eefc;
  --muted: #b9a9c6;
  --primary: #b77cff;
  --primary-dark: #d9b8ff;
  --border: #383143;
}

body.secret .app {
  background: #17151d;
  color: #f7eefc;
}

body.secret .view {
  background: #17151d;
}

body.secret .card {
  background: #24202e !important;
  color: #f7eefc !important;
  border-color: #383143 !important;
  box-shadow: none !important;
}

body.secret .item {
  background: #1c1924 !important;
  color: #f7eefc !important;
  border-color: #383143 !important;
}

body.secret .item-title {
  color: #f7eefc !important;
}

body.secret .item-meta,
body.secret .muted,
body.secret label {
  color: #b9a9c6 !important;
}

body.secret input,
body.secret textarea,
body.secret select {
  background: #17151d !important;
  color: #f7eefc !important;
  border-color: #40384b !important;
}

body.secret .bottom-nav,
body.secret .app-header {
  background: rgba(23, 21, 29, 0.94) !important;
  border-color: #383143 !important;
}

body.secret .bottom-nav button {
  background: transparent !important;
  color: #b9a9c6 !important;
}

body.secret .bottom-nav button.active {
  background: #332543 !important;
  color: #e4c8ff !important;
}

body.secret button {
  background: #b77cff;
  color: #ffffff;
}

body.secret button.ghost {
  background: transparent !important;
  color: #d9b8ff !important;
  border-color: #40384b !important;
}

/* iOS Safari date input overflow fix */
input[type="date"] {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  -webkit-appearance: none;
  appearance: none;
}

/* 念のため、カード内のフォーム要素全体もはみ出し防止 */
.card input,
.card textarea,
.card select {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* card内のボタンと上の入力欄・リストとの間隔を整える */
.card button {
  margin-top: 14px;
}

/* ボタンが連続する場合の間隔 */
.card button + button {
  margin-top: 10px;
}

/* リストの下にボタンが来る場合の間隔 */
.card .list + button {
  margin-top: 16px;
}

/* textarea / input / select の直後にボタンが来る場合の間隔 */
.card textarea + button,
.card input + button,
.card select + button {
  margin-top: 16px;
}

/* トースト通知 */
.toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #2a211b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
}
.toast.fade-out {
  opacity: 0;
}
body.secret .toast {
  background: #e4c8ff;
  color: #17151d;
}

/* 料理・相手アイテムの操作ボタン */
.item-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.item-actions button {
  margin-top: 0;
  padding: 5px 0;
  font-size: 12px;
  border-radius: 10px;
  font-weight: 600;
  min-width: 64px;
  text-align: center;
  border: 1px solid transparent;
}
.item-actions .btn-delete {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* カスタム確認モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--card);
  border-radius: 22px;
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}
.modal-body {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 20px;
}
.modal-body input {
  margin-top: 10px;
}
.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions button {
  flex: 1;
  margin-top: 0;
}
body.secret .modal {
  background: var(--secret-card);
  color: var(--secret-text);
}
body.secret .modal-title {
  color: var(--secret-text);
}
body.secret .modal-body {
  color: var(--secret-muted);
}

/* 食材タグ入力 */
.ingredient-input-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.ingredient-input-row input {
  flex: 1;
}
.ingredient-input-row button {
  margin-top: 0;
  padding: 10px 16px;
  border-radius: 14px;
  flex-shrink: 0;
}
.ingredient-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  min-height: 0;
}
.ingredient-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff0e0;
  border: 1px solid #f3c896;
  border-radius: 20px;
  padding: 4px 12px 4px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
}
.ingredient-tag button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 16px;
  line-height: 1;
  color: var(--primary-dark);
  cursor: pointer;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}
.ingredient-tag button:active {
  opacity: 1;
  transform: scale(0.9);
}
