/* Cooking Pt.1 — Japanese-minimalist theme
 * washi paper · sumi ink · ai indigo · shu vermilion · matcha
 */
:root {
  --washi: #f3f0e9;
  --surface: #fcfbf7;
  --surface-2: #f7f4ec;
  --sumi: #232019;
  --muted: #a59c8c;
  --line: #e7e1d5;
  --ai: #2f3e55;          /* indigo — primary */
  --ai-deep: #243245;
  --ai-soft: #e9edf2;
  --shu: #c8493a;         /* vermilion — sparing accent */
  --matcha: #5e7d54;      /* success / checked */
  --matcha-soft: #eaf0e6;
  --shadow-sm: 0 1px 2px rgba(40,34,22,.05), 0 2px 8px rgba(40,34,22,.04);
  --shadow-md: 0 4px 14px rgba(40,34,22,.08), 0 12px 30px rgba(40,34,22,.06);
  --radius: 16px;
  --ease: cubic-bezier(.22,.68,.16,1);   /* smooth, gentle settle */
  --ease-out: cubic-bezier(.16,.84,.32,1);
  --t: .26s;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--washi);
  color: var(--sumi);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; padding-top: max(16px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--washi) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.hanko {
  width: 26px; height: 26px; border-radius: 7px; background: var(--shu);
  display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(200,73,58,.35); transform: rotate(-3deg);
}
.brand h1 { font-size: 1.05rem; margin: 0; font-weight: 650; letter-spacing: .3px; }
.brand .sub-en { font-size: .66rem; color: var(--muted); letter-spacing: 3px; text-transform: uppercase; display: block; margin-top: 1px; }
.install-btn {
  background: var(--ai); color: #fff; border: 0; font-weight: 600; font-size: .82rem;
  padding: 8px 15px; border-radius: 999px; cursor: pointer;
  transition: transform var(--t) var(--ease), background var(--t), box-shadow var(--t);
  box-shadow: var(--shadow-sm);
}
.install-btn:hover { background: var(--ai-deep); }
.install-btn:active { transform: scale(.94); }
.header-actions { display: flex; gap: 8px; align-items: center; }
.install-btn.ghost { background: var(--surface); color: var(--ai); border: 1.5px solid var(--line); box-shadow: none; }
.install-btn.ghost:hover { border-color: var(--ai); background: var(--surface); }
.install-btn.signed { background: var(--matcha-soft); color: var(--matcha); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-card { text-align: center; }
.auth-card #gsiButton { display: flex; justify-content: center; margin: 18px 0 10px; min-height: 44px; }
.auth-note { font-size: .78rem; line-height: 1.5; margin-top: 14px; }

/* ---------- Tabs ---------- */
.tabs {
  position: sticky; top: 0; z-index: 15; position: relative;
  display: flex; background: var(--surface); border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1; padding: 15px 8px; border: 0; background: none; cursor: pointer;
  font-size: .92rem; font-weight: 600; color: var(--muted);
  transition: color var(--t) var(--ease); position: relative;
}
.tab.active { color: var(--ai); }
.tab:active { transform: scale(.97); }
.tab-underline {
  position: absolute; bottom: -1px; left: 0; height: 2.5px; width: 0;
  background: var(--ai); border-radius: 3px;
  transition: transform .34s var(--ease), width .34s var(--ease);
}
.badge {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px;
  margin-left: 5px; font-size: .7rem; background: var(--shu); color: #fff; border-radius: 999px;
  transition: transform var(--t) var(--ease-out);
}
.badge.pop { animation: pop .4s var(--ease-out); }

/* ---------- Layout / views ---------- */
main { max-width: 780px; margin: 0 auto; padding: 20px 18px; }
.view { display: none; }
.view.active { display: block; animation: viewIn .42s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.muted { color: var(--muted); }
.section-head { font-size: .72rem; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }

/* ---------- Segmented controls + filters ---------- */
.filters { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.seg {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px; gap: 2px; align-self: flex-start; flex-wrap: wrap;
}
.seg-btn {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: .84rem; font-weight: 600; padding: 7px 15px; border-radius: 999px;
  transition: color var(--t) var(--ease), background var(--t) var(--ease), transform var(--t) var(--ease);
}
.seg-btn:hover { color: var(--sumi); }
.seg-btn:active { transform: scale(.93); }
.seg-btn.active { background: var(--ai); color: #fff; box-shadow: var(--shadow-sm); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.track {
  width: 42px; height: 24px; border-radius: 999px; background: var(--line);
  position: relative; transition: background var(--t) var(--ease);
}
.thumb {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform var(--t) var(--ease-out);
}
.switch input:checked + .track { background: var(--matcha); }
.switch input:checked + .track .thumb { transform: translateX(18px); }
.switch-label { font-size: .86rem; color: var(--muted); }

/* ---------- Recipe cards ---------- */
.card-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 580px) { .card-grid { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 17px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 9px;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: #ddd4c4; }
.card.enter { animation: fadeUp .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.card h3 { margin: 0; font-size: 1.08rem; font-weight: 650; }
.card .sub { color: var(--muted); font-size: .82rem; margin-top: -5px; }
.card .desc { font-size: .87rem; color: #5f574a; flex: 1; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  font-size: .7rem; padding: 3px 9px; border-radius: 999px; font-weight: 600;
  background: var(--ai-soft); color: var(--ai);
}
.pill.grey { background: var(--surface-2); color: var(--muted); }
.pill.ahead { background: var(--matcha-soft); color: var(--matcha); }
.card-actions { display: flex; gap: 9px; margin-top: 4px; }
.card-actions button { flex: 1; }

/* ---------- Buttons ---------- */
button.primary, button.secondary, .ghost-btn {
  font-size: .87rem; font-weight: 600; cursor: pointer; border-radius: 11px; padding: 10px 14px;
  transition: transform var(--t) var(--ease), background var(--t) var(--ease),
              color var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t);
}
button.primary { background: var(--ai); color: #fff; border: 0; box-shadow: var(--shadow-sm); }
button.primary:hover { background: var(--ai-deep); box-shadow: var(--shadow-md); }
button.primary:active { transform: scale(.95); }
button.primary.added { background: var(--matcha); }
button.secondary { background: var(--surface); color: var(--ai); border: 1.5px solid var(--line); }
button.secondary:hover { border-color: var(--ai); }
button.secondary:active { transform: scale(.95); }
.ghost-btn { background: none; border: 1px solid var(--line); color: var(--muted); }
.ghost-btn:hover { color: var(--sumi); border-color: var(--muted); }
.ghost-btn:active { transform: scale(.95); }

/* ---------- Plan ---------- */
.plan-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.plan-toolbar .left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.plan-day { margin-bottom: 22px; animation: fadeUp .45s var(--ease) both; }
.plan-day > h2 {
  font-size: .76rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ai);
  margin: 0 0 10px; display: flex; align-items: center; gap: 8px;
}
.plan-day > h2::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--shu); }
.meal-label { font-size: .68rem; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 10px 0 6px; }
.slot {
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  padding: 12px 14px; display: flex; align-items: center; gap: 11px; margin-bottom: 9px;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), opacity var(--t);
  animation: fadeUp .4s var(--ease) both;
}
.slot:hover { box-shadow: var(--shadow-sm); }
.slot .s-name { flex: 1; font-weight: 600; cursor: pointer; }
.slot .s-name:hover { color: var(--ai); }
.slot select {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  color: var(--sumi); font-size: .8rem; cursor: pointer; transition: border-color var(--t);
}
.slot select:hover { border-color: var(--muted); }
.icon-btn {
  background: none; border: 0; color: var(--muted); font-size: 1.05rem; cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; transition: color var(--t), background var(--t), transform var(--t) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--sumi); }
.icon-btn:active { transform: scale(.85) rotate(-8deg); }
.empty { text-align: center; color: var(--muted); padding: 48px 18px; animation: fadeIn .5s var(--ease) both; }
.empty .big { font-size: 2.2rem; display: block; margin-bottom: 12px; opacity: .5; }

/* ---------- Grocery ---------- */
.g-section { margin-bottom: 18px; animation: fadeUp .42s var(--ease) both; }
.g-section h2 {
  font-size: .74rem; text-transform: uppercase; letter-spacing: 1.4px; color: var(--ai);
  margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.g-section.staples h2 { color: var(--muted); }
.g-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 11px 4px;
  border-bottom: 1px solid #f1ebe1; transition: opacity var(--t);
}
.checkbox {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; flex: none; margin-top: 1px;
  border: 2px solid var(--line); border-radius: 7px; cursor: pointer; position: relative;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), transform var(--t) var(--ease-out);
}
.checkbox:hover { border-color: var(--matcha); }
.checkbox:active { transform: scale(.85); }
.checkbox:checked { background: var(--matcha); border-color: var(--matcha); }
.checkbox:checked::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(42deg);
  animation: check .25s var(--ease-out) both;
}
@keyframes check { from { height: 0; opacity: 0; } to { height: 10px; opacity: 1; } }
.g-item label { flex: 1; cursor: pointer; transition: color var(--t), opacity var(--t); }
.g-item .qty { font-weight: 650; }
.g-item .for { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; }
.g-item.checked label { color: var(--muted); text-decoration: line-through; opacity: .65; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 580px) { .modal { align-items: center; } }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(35,28,18,.42); animation: fadeIn .3s var(--ease) both; backdrop-filter: blur(2px); }
.modal-card {
  position: relative; background: var(--surface); width: 100%; max-width: 600px; max-height: 88vh;
  overflow-y: auto; border-radius: 22px 22px 0 0; padding: 26px 24px 30px;
  animation: slideUp .4s var(--ease-out) both;
}
@media (min-width: 580px) { .modal-card { border-radius: 22px; animation: zoomIn .34s var(--ease-out) both; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes zoomIn { from { opacity: 0; transform: scale(.94) translateY(10px); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute; top: 14px; right: 16px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); border: 0; font-size: 1.4rem; line-height: 1; color: var(--muted);
  cursor: pointer; transition: transform var(--t) var(--ease), background var(--t), color var(--t);
}
.modal-close:hover { background: var(--line); color: var(--sumi); }
.modal-close:active { transform: scale(.85) rotate(90deg); }
.modal-card h2 { margin: 0 0 2px; font-size: 1.4rem; }
.modal-card .m-sub { color: var(--muted); margin: 0 0 12px; }
.modal-card ol { padding-left: 20px; }
.modal-card ol li { margin-bottom: 8px; padding-left: 4px; }
.modal-card a { color: var(--ai); }
.ing-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #f1ebe1; gap: 12px; }
.ing-row .q { color: var(--muted); white-space: nowrap; }
.section-label { margin: 20px 0 8px; font-weight: 700; font-size: .78rem; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ai); }

/* ---------- Reduced motion ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}
