:root {
  --primary: #C85A20;
  --primary-light: #F5E0D0;
  --bg: #FAFAF8;
  --card: #FFFFFF;
  --text: #1C1917;
  --text-secondary: #78716C;
  --border: #E7E5E0;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

/* ── NAV ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250,250,248,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 7px 28px; gap: 12px;
}
.nav-brand { font-size: 18px; font-weight: 800; text-decoration: none; color: var(--text); flex: 1; }
.nav-right { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  background: none; border: none; cursor: pointer;
  padding: 7px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-weight: 600;
}
.nav-btn:hover { background: var(--border); }
.nav-btn-back { font-size: 22px; padding: 4px 10px; }

/* ── HERO ── */
.hero {
  background: linear-gradient(135deg, #7c2d0e 0%, #c2410c 45%, #ea580c 100%);
  color: white; padding: 0; height: 33vh; min-height: 240px; max-height: 340px;
  display: flex; align-items: center;
  position: relative; overflow: hidden;
}
.hero-pattern {
  position: absolute; inset: 0; pointer-events: none; user-select: none; overflow: hidden;
}
.hero-pattern span { position: absolute; line-height: 1; }
.hero-inner {
  position: relative; z-index: 1; width: 100%; padding: 0 28px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; align-items: center;
}
.hero-left { display: flex; flex-direction: column; gap: 6px; }
.hero-right { display: flex; flex-direction: column; gap: 12px; }
.hero-title { font-size: clamp(28px, 4vw, 52px); font-weight: 900; letter-spacing: -1px; }
.hero-sub { font-size: 14px; opacity: .82; }
.hero-search { position: relative; width: 100%; }
.hero-search input {
  width: 100%; padding: 10px 18px 10px 40px;
  border-radius: 100px; border: none; font-size: 14px;
  background: rgba(255,255,255,.18); color: white;
  backdrop-filter: blur(10px); outline: none; transition: background .2s;
}
.hero-search input::placeholder { color: rgba(255,255,255,.72); }
.hero-search input:focus { background: rgba(255,255,255,.28); }
.hero-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; pointer-events: none; }
.hero-stats { display: flex; gap: 32px; }
.hero-stat-num { font-size: 28px; font-weight: 800; line-height: 1; }
.hero-stat-label { font-size: 11px; opacity: .75; margin-top: 3px; }

/* ── MAIN LAYOUT ── */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px 28px 60px;
}
@media (max-width: 860px) {
  .main-layout { grid-template-columns: 1fr; padding: 16px 16px 80px; gap: 16px; }
  .nav { padding: 12px 16px; }
  .hero { padding: 48px 16px; }
}

/* ── CARD ── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }

/* ── CALENDAR ── */
.cal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 2px; }
.cal-month { font-size: 15px; font-weight: 700; }
.cal-nav { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text); padding: 3px 8px; border-radius: 8px; }
.cal-nav:hover { background: var(--border); }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); grid-auto-rows: 34px; gap: 2px; padding: 4px 10px 10px; }
.cal-weekday { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.cal-day { display: flex; align-items: center; justify-content: center; font-size: 13px; border-radius: 50%; width: 34px; height: 34px; margin: 0 auto; }
.cal-day.has-record { background: var(--primary); color: #fff; font-weight: 700; cursor: pointer; }
.cal-day.has-record:hover { opacity: .85; }
.cal-day.today:not(.has-record) { border: 2px solid var(--primary); color: var(--primary); font-weight: 700; }

/* ── SIDEBAR ── */
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.sidebar-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); padding: 16px 16px 8px; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: var(--bg); }
.recent-icon { width: 40px; height: 40px; background: var(--primary-light); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.recent-info { flex: 1; min-width: 0; }
.recent-dish { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-date { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ── TAGS ── */
.tag { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 600; }
.tag-炒    { background: #FEF3C7; color: #D97706; }
.tag-煮    { background: #DBEAFE; color: #2563EB; }
.tag-蛋料理 { background: #FEF9C3; color: #CA8A04; }
.tag-拌    { background: #DCFCE7; color: #16A34A; }
.tag-燙    { background: #FEE2E2; color: #DC2626; }
.tag-其他  { background: #EDE9FE; color: #7C3AED; }
.tag-source { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 20px; border-radius: var(--radius); border: none; cursor: pointer; font-size: 15px; font-weight: 600; transition: opacity .15s; }
.btn:active { opacity: .8; }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-sm { padding: 7px 13px; font-size: 13px; }

/* ── LOGIN ── */
.login-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 32px 24px 20vh; gap: 20px; }
.login-logo { font-size: 60px; }
.login-title { font-size: 28px; font-weight: 800; }
.login-sub { color: var(--text-secondary); font-size: 14px; text-align: center; }
.login-form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-form input { width: 100%; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 16px; background: var(--card); outline: none; }
.login-form input:focus { border-color: var(--primary); }
.login-err { color: #DC2626; font-size: 13px; display: none; text-align: center; }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.modal { background: var(--card); border-radius: 16px; padding: 24px; width: 100%; max-width: 340px; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-input { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 15px; outline: none; margin-bottom: 8px; }
.modal-input:focus { border-color: var(--primary); }

/* ── SUB-PAGE NAV ── */
.sub-nav { display: flex; align-items: center; padding: 12px 24px; gap: 10px; border-bottom: 1px solid var(--border); background: var(--card); position: sticky; top: 0; z-index: 50; }
.sub-nav-title { font-size: 17px; font-weight: 700; flex: 1; }
@media (max-width: 860px) { .sub-nav { padding: 12px 16px; } }

/* ── DAY / SEARCH PAGE ── */
.page-body { max-width: 680px; margin: 0 auto; padding: 24px 32px 80px; }
@media (max-width: 860px) { .page-body { padding: 16px 16px 80px; } }
.day-count { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; }
.no-records { text-align: center; color: var(--text-secondary); padding: 48px 16px; font-size: 14px; }

/* ── RECORD CARD ── */
.record-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; cursor: pointer; display: flex; align-items: center; gap: 14px; transition: box-shadow .15s; }
.record-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.record-thumb-placeholder { width: 56px; height: 56px; border-radius: var(--radius-sm); background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.record-info { flex: 1; min-width: 0; }
.record-dish { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-meta { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.record-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

/* ── DETAIL ── */
.detail-photo { width: 100%; max-height: 420px; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; }
.detail-body { padding: 20px 24px; }
.detail-dish { font-size: 26px; font-weight: 800; margin-bottom: 8px; }
.detail-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.detail-time { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }
.section { margin-bottom: 20px; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); margin-bottom: 8px; }
.section-body { font-size: 15px; line-height: 1.75; white-space: pre-wrap; }
.ingredient-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.ingredient-row:last-child { border-bottom: none; }
.ingredient-total { display: flex; justify-content: flex-end; font-size: 14px; font-weight: 700; padding-top: 8px; color: var(--primary); }
.detail-actions { display: flex; gap: 10px; margin-top: 8px; padding: 0 24px 24px; }

/* ── FORM ── */
.form-body { max-width: 680px; margin: 0 auto; padding: 24px 32px 80px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 860px) { .form-body { padding: 16px 16px 80px; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.field input, .field textarea { padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 15px; font-family: inherit; background: var(--card); color: var(--text); outline: none; width: 100%; }
.field input:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 16px; border-radius: 100px; border: 1.5px solid var(--border); background: var(--card); font-size: 14px; cursor: pointer; transition: all .15s; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.time-row { display: flex; gap: 10px; }
.time-row .field { flex: 1; }
.photo-upload { border: 2px dashed var(--border); border-radius: var(--radius); padding: 24px; text-align: center; cursor: pointer; }
.photo-upload:hover { border-color: var(--primary); }
.ingredient-input-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.ingredient-input-row input { flex: 1; }
.ingredient-input-row input.cost { width: 90px; flex: none; }
.ingredient-remove { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 20px; padding: 4px; line-height: 1; }

/* ── SEARCH ── */
.search-bar { padding: 12px 0 8px; }
.search-bar input { width: 100%; padding: 11px 16px; border: 1.5px solid var(--border); border-radius: 100px; font-size: 14px; background: var(--card); outline: none; }
.search-bar input:focus { border-color: var(--primary); }
.search-empty { text-align: center; color: var(--text-secondary); padding: 32px 0; font-size: 14px; }

/* ── FAB ── */
.fab { position: fixed; bottom: 28px; right: 28px; width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #fff; border: none; font-size: 28px; cursor: pointer; box-shadow: 0 4px 16px rgba(200,90,32,.4); display: flex; align-items: center; justify-content: center; z-index: 20; }
.fab:active { opacity: .85; }
