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

:root {
  --primary:       #FF6B35;
  --primary-light: #FF8C5A;
  --primary-pale:  #FFF0EA;
  --bg:            #FFFDF8;
  --surface:       #FFFFFF;
  --text:          #2D2D2D;
  --text-muted:    #888;
  --border:        #F0EBE3;
  --danger:        #E53E3E;
  --success:       #38A169;
  --shadow:        0 2px 12px rgba(0,0,0,0.08);
  --radius:        16px;
  --nav-height:    72px;
  --header-height: 56px;
}

html, body {
  height: 100%;
  font-family: -apple-system, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ========== HEADER ========== */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.header-add-btn {
  background: var(--primary);
  color: white;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s, transform 0.1s;
}
.header-add-btn:active { transform: scale(0.92); }

/* ========== MAIN ========== */
#main {
  padding-top: var(--header-height);
  padding-bottom: var(--nav-height);
  min-height: 100vh;
}

.view {
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.hidden { display: none !important; }
.active { display: block; }

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

/* ========== RECIPE GRID ========== */
#recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.recipe-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
}
.recipe-card:active { transform: scale(0.97); }

.recipe-card-img {
  width: 100%;
  aspect-ratio: 1;
  background: var(--primary-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  overflow: hidden;
  position: relative;
}
.recipe-card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.photo-count-badge {
  position: absolute;
  bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 10px; font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  backdrop-filter: blur(4px);
}

.card-hearts {
  position: absolute;
  top: 6px; left: 6px;
  background: rgba(220,20,60,0.85);
  color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  backdrop-filter: blur(4px);
}

.recipe-card-body { padding: 10px 12px 12px; }
.recipe-card-name { font-size: 14px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.recipe-card-meta { font-size: 11px; color: var(--text-muted); }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state p:first-child { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 16px; font-weight: 500; }
.empty-state .sub { font-size: 13px; margin-top: 6px; font-weight: 400; }

/* ========== IMPORT BOX ========== */
.import-box {
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--primary-pale);
  overflow: hidden;
  margin-bottom: 4px;
}
.import-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px; font-weight: 600;
  color: var(--primary);
  user-select: none;
}
.import-arrow { font-size: 11px; transition: transform 0.2s; }
.import-box-header.open .import-arrow { transform: rotate(180deg); }
#import-area {
  padding: 0 14px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.import-hint { font-size: 12px; color: var(--text-muted); }

.divider-or { text-align: center; position: relative; margin: 14px 0 10px; }
.divider-or::before {
  content: '';
  position: absolute; top: 50%; left: 0; right: 0;
  height: 1px; background: var(--border);
}
.divider-or span {
  position: relative;
  background: var(--bg);
  padding: 0 10px;
  font-size: 12px; color: var(--text-muted);
}

/* ========== MULTI PHOTO UPLOAD ========== */
.photos-section { margin-bottom: 14px; }
.section-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.photos-preview {
  display: flex; gap: 8px;
  overflow-x: auto; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.photos-preview::-webkit-scrollbar { display: none; }
.photo-thumb-wrap { position: relative; flex-shrink: 0; }
.photo-thumb {
  width: 80px; height: 80px;
  border-radius: 12px; object-fit: cover; display: block;
  border: 2px solid transparent;
}
.photo-thumb-wrap:first-child .photo-thumb { border-color: var(--primary); }
.photo-main-label {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 700;
  background: var(--primary); color: white;
  padding: 1px 5px; border-radius: 6px; white-space: nowrap;
}
.photo-remove-btn {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--text); color: white; border: none;
  font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.add-photo-btn {
  flex-shrink: 0; width: 80px; height: 80px;
  border-radius: 12px; border: 2px dashed var(--border);
  background: var(--surface); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--text-muted); font-size: 11px; font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.add-photo-btn:hover { border-color: var(--primary); background: var(--primary-pale); }
.add-photo-icon { font-size: 22px; }
.photo-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ========== RECIPE FORM ========== */
.recipe-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
label small { font-weight: 400; }
.required { color: var(--primary); }
input[type="text"], textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px; font-family: inherit;
  background: var(--surface); color: var(--text);
  outline: none; resize: vertical;
  transition: border-color 0.15s;
}
input:focus, textarea:focus { border-color: var(--primary); }
.form-actions { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }

/* ========== BUTTONS ========== */
.btn-primary {
  background: var(--primary); color: white; border: none;
  border-radius: 12px; padding: 14px 20px;
  font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--primary-light); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 12px; padding: 13px 20px;
  font-size: 15px; font-weight: 500;
  cursor: pointer; color: var(--text-muted); font-family: inherit;
}

.btn-full { width: 100%; }

.btn-danger {
  background: none; border: 1.5px solid var(--danger); color: var(--danger);
  border-radius: 12px; padding: 12px 20px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; width: 100%; margin-top: 8px; font-family: inherit;
  transition: background 0.15s;
}
.btn-danger:hover { background: #FFF5F5; }

/* ========== MODAL ACTIONS ========== */
.modal-actions { display: flex; gap: 10px; }

.btn-plan {
  flex: 1;
  background: var(--primary); color: white; border: none;
  border-radius: 12px; padding: 12px 16px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.btn-plan.btn-plan-added { background: var(--success); }

.btn-heart {
  background: var(--bg); color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 12px; padding: 12px 16px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn-heart:active { background: #FFE4E4; border-color: #FF6B6B; }

.btn-goto-plan {
  display: block; width: 100%; margin-top: 10px;
  background: var(--primary-pale); color: var(--primary);
  border: 1.5px solid var(--primary-light);
  border-radius: 12px; padding: 12px 16px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  text-align: center;
  transition: background 0.15s;
}
.btn-goto-plan:active { background: #FFD9C8; }

/* ========== PLAN VIEW ========== */
.plan-section-title {
  font-size: 14px; font-weight: 700; color: var(--text);
  margin: 18px 0 10px;
}
.plan-section-title:first-child { margin-top: 0; }
.plan-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }

.plan-recipe-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.plan-recipe-thumb {
  width: 52px; height: 52px;
  border-radius: 10px;
  background: var(--primary-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; overflow: hidden; flex-shrink: 0;
}
.plan-recipe-thumb img { width: 100%; height: 100%; object-fit: cover; }
.plan-recipe-info { flex: 1; }
.plan-recipe-name { font-size: 15px; font-weight: 600; }
.plan-recipe-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.plan-remove-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer;
  padding: 6px 10px; border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.plan-remove-btn:hover { background: var(--bg); color: var(--danger); }

.plan-footer {
  margin-top: 24px;
  display: flex; flex-direction: column; gap: 10px;
  padding-bottom: 20px;
}

.plan-steps-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.plan-steps-name {
  font-size: 15px; font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
}
.plan-steps-img {
  width: 100%; border-radius: 10px;
  object-fit: cover; margin-bottom: 14px;
  display: block;
}
.plan-steps-list-ol {
  padding-left: 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.plan-steps-list-ol li {
  font-size: 13px; line-height: 1.6; color: var(--text);
}

/* ========== HISTORY ========== */
.history-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex; align-items: flex-start; gap: 14px;
  transition: transform 0.15s;
}
.history-card:active { transform: scale(0.98); }

.history-date {
  display: flex; flex-direction: column; align-items: center;
  background: var(--primary); color: white;
  border-radius: 12px; padding: 8px 10px;
  min-width: 52px; flex-shrink: 0;
}
.history-date-num { font-size: 24px; font-weight: 700; line-height: 1; }
.history-date-label { font-size: 10px; margin-top: 2px; opacity: 0.9; }
.history-info { flex: 1; padding-top: 4px; }
.history-card-recipes { display: flex; flex-wrap: wrap; gap: 4px; }

.recipe-tag {
  font-size: 11px;
  background: var(--primary-pale); color: var(--primary);
  padding: 3px 8px; border-radius: 20px; font-weight: 500;
}

.history-recipe-row {
  font-size: 15px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.history-recipe-row:last-child { border-bottom: none; }

.history-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 4px;
}
.history-date-input {
  width: 100%;
  font-size: 16px;
  padding: 10px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}
.history-date-input:focus {
  outline: none;
  border-color: var(--primary);
}
.history-title-input {
  width: 100%;
  font-size: 18px;
  font-weight: 700;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}
.history-title-input:focus {
  outline: none;
  border-color: var(--primary);
}
.history-card-memo {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  white-space: pre-line;
}

/* ========== FREEZER（冷凍庫） ========== */
.freezer-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #e8f4fd, #dbeeff);
  border: 1.5px solid #a8d4f5;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 16px;
  font-weight: 700;
  color: #1a6fa8;
}
.freezer-summary-icon { font-size: 22px; }

.freezer-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.freezer-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 12px;
  margin-bottom: 8px;
}
.freezer-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
.freezer-thumb-empty {
  background: var(--border);
}
.freezer-info {
  flex: 1;
  min-width: 0;
}
.freezer-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.freezer-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}
.freezer-counter {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.freezer-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: var(--bg);
  color: var(--primary);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.freezer-btn:disabled {
  border-color: var(--border);
  color: var(--text-muted);
  cursor: default;
}
.freezer-btn-plus {
  background: var(--primary);
  color: #fff;
}
.freezer-count {
  font-size: 22px;
  font-weight: 800;
  min-width: 36px;
  text-align: center;
  color: var(--text);
}

#freezer-stock { margin-bottom: 24px; }

/* ========== RANKING ========== */
.ranking-header-text {
  font-size: 12px; color: var(--text-muted); margin-bottom: 12px;
}

.ranking-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  transition: transform 0.15s;
}
.ranking-card:active { transform: scale(0.98); }

.ranking-medal { font-size: 26px; min-width: 36px; text-align: center; flex-shrink: 0; }
.ranking-thumb {
  width: 52px; height: 52px;
  border-radius: 10px;
  background: var(--primary-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; overflow: hidden; flex-shrink: 0;
}
.ranking-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ranking-info { flex: 1; }
.ranking-name { font-size: 15px; font-weight: 600; }
.ranking-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ranking-hearts { font-size: 15px; font-weight: 700; color: #E53E3E; white-space: nowrap; }

/* ========== PLAN BADGE ========== */
.nav-btn { position: relative; }
.plan-badge {
  position: absolute;
  top: 6px; right: 12px;
  background: var(--primary); color: white;
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ========== BOTTOM NAV ========== */
#bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 100;
}
.nav-btn {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 8px 4px;
  color: var(--text-muted); transition: color 0.15s;
}
.nav-icon { font-size: 22px; transition: transform 0.15s; }
.nav-label { font-size: 10px; font-weight: 500; font-family: inherit; }
.nav-btn.active { color: var(--primary); }
.nav-btn.active .nav-icon { transform: scale(1.15); }

/* ========== MODALS ========== */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end;
}
.modal.hidden { display: none !important; }
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
.modal-sheet {
  position: relative;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  width: 100%; max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: rgba(0,0,0,0.4); border: none;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 13px; cursor: pointer; z-index: 10;
  display: flex; align-items: center; justify-content: center; color: white;
}

/* ========== PHOTO GALLERY ========== */
.modal-gallery-wrap {
  position: relative;
  border-radius: 24px 24px 0 0;
  overflow: hidden; background: #111;
}
.modal-gallery {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.modal-gallery::-webkit-scrollbar { display: none; }
.modal-gallery img {
  flex-shrink: 0; width: 100%; height: 280px;
  object-fit: contain;
  scroll-snap-align: start; background: #111; display: block;
}
.gallery-counter {
  position: absolute; bottom: 10px; right: 12px;
  background: rgba(0,0,0,0.55); color: white;
  font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 12px; backdrop-filter: blur(4px);
}

/* ========== MODAL BODY ========== */
.modal-body {
  padding: 20px 20px 40px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-body h2 { font-size: 22px; font-weight: 700; }
.modal-body h3 { font-size: 15px; font-weight: 700; margin-top: 4px; color: var(--primary); }
.modal-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-meta span {
  font-size: 13px; color: var(--text-muted);
  background: var(--bg); padding: 4px 10px; border-radius: 20px;
}
.modal-meta-text { font-size: 13px; color: var(--text-muted); }

.modal-body ul {
  list-style: none;
  display: flex; flex-direction: column; gap: 6px;
}
.modal-body ul li {
  padding: 10px 14px; background: var(--bg);
  border-radius: 10px; font-size: 14px;
  display: flex; align-items: flex-start; gap: 8px;
}
.modal-body ul li::before { content: '・'; color: var(--primary); flex-shrink: 0; }

.modal-body ol {
  list-style: none; counter-reset: step;
  display: flex; flex-direction: column; gap: 8px;
}
.modal-body ol li {
  counter-increment: step;
  padding: 10px 14px; background: var(--bg);
  border-radius: 10px; font-size: 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.modal-body ol li::before {
  content: counter(step);
  background: var(--primary); color: white;
  min-width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}

/* ========== LIST ITEMS ========== */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--bg);
  border-radius: 10px; margin-bottom: 6px;
  cursor: pointer; user-select: none;
  transition: opacity 0.15s;
}
.list-item.checked { opacity: 0.5; }
.list-item-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; flex-shrink: 0; transition: all 0.15s;
}
.list-item.checked .list-item-check {
  background: var(--success); border-color: var(--success); color: white;
}
.list-item-text { font-size: 14px; flex: 1; }
.list-item.checked .list-item-text { text-decoration: line-through; }

.list-section-title {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  margin: 14px 0 6px;
  text-transform: uppercase; letter-spacing: 0.05em;
}


/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%; transform: translateX(-50%);
  background: var(--text); color: white;
  padding: 12px 20px; border-radius: 24px;
  font-size: 14px; font-weight: 500;
  z-index: 300; white-space: nowrap;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (min-width: 480px) {
  #recipe-grid { grid-template-columns: repeat(3, 1fr); }
}
