@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Noto+Sans+SC:wght@400;500;700&display=swap');

:root {
  --paper: #fffaf2;
  --paper-deep: #f8efdf;
  --ink: #272522;
  --muted: #82786d;
  --line: #e7ddcc;
  --tomato: #e85d45;
  --tomato-dark: #ba4836;
  --tomato-soft: #f9ddd5;
  --sage: #4f8472;
  --sage-soft: #dfece6;
  --mustard: #d59e46;
  --mustard-soft: #f8eace;
  --lavender: #8578a7;
  --lavender-soft: #eae7f2;
  --shadow: 0 20px 55px rgba(65, 47, 28, .08);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); font-family: 'Noto Sans SC', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(79, 132, 114, .32); outline-offset: 2px; }

.app-shell { min-height: 100vh; overflow-x: hidden; }
.topbar { width: min(1180px, calc(100% - 40px)); height: 78px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand strong { display: block; font-size: 16px; letter-spacing: .02em; line-height: 1.2; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; letter-spacing: .12em; }
.brand-mark { width: 35px; height: 35px; border-radius: 11px; display: inline-flex; align-items: end; justify-content: center; gap: 3px; padding: 8px; background: var(--tomato); box-shadow: 4px 5px 0 rgba(186, 72, 54, .12); }
.brand-mark span { width: 3px; border-radius: 4px; background: var(--paper); display: block; }
.brand-mark span:nth-child(1) { height: 9px; }
.brand-mark span:nth-child(2) { height: 14px; }
.brand-mark span:nth-child(3) { height: 7px; }
.topnav { display: flex; align-items: center; gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.44); }
.nav-button { border: 0; border-radius: 10px; padding: 9px 14px; color: var(--muted); background: transparent; font-size: 13px; transition: .2s ease; }
.nav-button.is-active { color: var(--ink); background: var(--paper-deep); box-shadow: 0 2px 0 rgba(65,47,28,.03); }
.nav-icon { margin-right: 5px; font-size: 15px; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 70px; }
.view { display: none; }
.view.is-visible { display: block; }
.hero-row, .library-heading { display: flex; align-items: center; justify-content: space-between; gap: 32px; padding: 44px 0 34px; }
.eyebrow { margin: 0 0 13px; color: var(--tomato-dark); font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: .12em; }
.eyebrow-dot { display: inline-block; width: 5px; height: 5px; margin: 0 5px 2px; border-radius: 50%; background: var(--mustard); }
h1 { max-width: 710px; margin: 0; font-size: clamp(32px, 4.8vw, 58px); letter-spacing: -.04em; line-height: 1.15; font-weight: 700; }
h1 em { color: var(--tomato); font-style: normal; }
.hero-copy { max-width: 540px; margin: 15px 0 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.hero-sticker { position: relative; width: 170px; height: 135px; flex: 0 0 170px; transform: rotate(4deg); }
.sticker-bowl { position: absolute; left: 30px; bottom: 14px; z-index: 2; width: 107px; height: 80px; display: grid; place-items: center; border: 1px solid rgba(232,93,69,.35); border-radius: 50% 50% 44% 44%; background: var(--tomato-soft); font-size: 50px; box-shadow: inset 0 -12px rgba(232,93,69,.08), 8px 11px 0 rgba(65,47,28,.05); }
.sticker-steam { position: absolute; z-index: 1; width: 22px; height: 48px; border-left: 3px solid var(--sage); border-radius: 50%; opacity: .45; transform: rotate(16deg); }
.steam-one { left: 63px; top: 2px; }
.steam-two { left: 97px; top: 15px; height: 38px; transform: rotate(-13deg); }
.sticker-spark { position: absolute; color: var(--mustard); font-family: 'DM Mono', monospace; font-weight: 500; }
.spark-one { top: 9px; right: 9px; font-size: 22px; }
.spark-two { top: 55px; right: -2px; font-size: 30px; }

.control-strip { display: flex; align-items: center; justify-content: flex-end; gap: 18px; padding: 16px 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.control-label { color: var(--muted); font-size: 13px; }
.meal-note { display: flex; align-items: center; gap: 8px; color: var(--sage); font-size: 13px; }
.meal-note small { color: var(--muted); font-size: 11px; }
.note-icon { font-size: 22px; line-height: 1; transform: rotate(-8deg); }

.menu-summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 24px 0 18px; }
.summary-kicker { display: block; color: var(--muted); font-size: 12px; }
.menu-summary strong { display: inline-block; margin: 4px 10px 0 0; font-size: 19px; letter-spacing: -.02em; }
.menu-summary div > span:last-child { color: var(--muted); font-size: 12px; }
.summary-progress { width: 180px; height: 7px; overflow: hidden; border-radius: 99px; background: var(--paper-deep); }
.summary-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--tomato); transition: width .35s ease; }

.category-list { display: grid; gap: 18px; }
.category-section { position: relative; display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 26px; padding: 23px 0; border-top: 1px solid var(--line); }
.category-heading { display: flex; align-items: flex-start; gap: 11px; }
.category-symbol { width: 37px; height: 37px; display: grid; place-items: center; flex: 0 0 37px; border-radius: 12px; font-size: 20px; }
.tone-tomato { background: var(--tomato-soft); }
.tone-sage { background: var(--sage-soft); }
.tone-mustard { background: var(--mustard-soft); }
.tone-lavender { background: var(--lavender-soft); }
.category-heading h2 { margin: 1px 0 4px; font-size: 17px; letter-spacing: -.02em; }
.category-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.category-meta { display: flex; align-items: center; gap: 2px; margin-top: 14px; color: var(--muted); font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: .04em; }
.category-meta strong { color: var(--ink); font-weight: 500; }
.slot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dish-slot { position: relative; min-width: 0; min-height: 112px; display: flex; align-items: stretch; overflow: visible; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: rgba(255,255,255,.52); text-align: left; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease; }
.dish-slot:hover { transform: translateY(-2px); border-color: rgba(232,93,69,.45); box-shadow: 0 8px 20px rgba(65,47,28,.07); }
.dish-slot:active { transform: translateY(0); }
.dish-slot.is-empty { border-style: dashed; background: transparent; }
.dish-slot.is-empty:hover { background: rgba(255,255,255,.55); }
.dish-slot.is-optional { opacity: .65; }
.dish-slot.is-menu-open { z-index: 8; border-color: rgba(232,93,69,.62); box-shadow: 0 8px 20px rgba(65,47,28,.1); }
.dish-slot-main { min-width: 0; flex: 1; display: flex; align-items: center; gap: 13px; padding: 14px 46px 14px 14px; border: 0; border-radius: inherit; color: inherit; background: transparent; text-align: left; }
.dish-slot-main:hover { background: rgba(255,255,255,.22); }
.dish-slot-main:focus-visible { position: relative; z-index: 1; outline-offset: -3px; }
.slot-select-toggle { position: absolute; z-index: 2; top: 50%; right: 10px; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--paper); transform: translateY(-50%); transition: color .18s ease, border-color .18s ease, background .18s ease; }
.slot-select-toggle:hover, .dish-slot.is-menu-open .slot-select-toggle { border-color: var(--tomato); color: var(--tomato-dark); background: var(--tomato-soft); }
.slot-select-chevron { width: 9px; height: 9px; display: block; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transform-origin: center; transition: transform .18s ease; }
.dish-slot.is-menu-open .slot-select-chevron { transform: rotate(225deg); }
.slot-select-menu { position: absolute; z-index: 10; top: calc(100% + 8px); right: 8px; left: 8px; max-height: min(320px, 55vh); overflow-y: auto; padding: 7px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); box-shadow: 0 14px 30px rgba(65,47,28,.16); }
.slot-select-menu-title { padding: 5px 8px 7px; color: var(--muted); font-size: 10px; }
.slot-select-option { width: 100%; min-height: 35px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px; border: 0; border-radius: 7px; color: var(--ink); background: transparent; text-align: left; font-size: 12px; }
.slot-select-option:hover, .slot-select-option:focus-visible, .slot-select-option.is-current { color: var(--tomato-dark); background: var(--tomato-soft); }
.slot-select-option span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-select-option small { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.slot-select-empty { display: block; padding: 10px 8px; color: var(--muted); font-size: 11px; text-align: center; }
.slot-number { position: absolute; top: 9px; right: 11px; color: var(--muted); font-family: 'DM Mono', monospace; font-size: 10px; }
.slot-visual { width: 59px; height: 59px; display: grid; place-items: center; flex: 0 0 59px; border-radius: 18px; font-size: 31px; background: var(--paper-deep); }
.slot-visual.tone-tomato { background: var(--tomato-soft); }
.slot-visual.tone-sage { background: var(--sage-soft); }
.slot-visual.tone-mustard { background: var(--mustard-soft); }
.slot-visual.tone-lavender { background: var(--lavender-soft); }
.slot-copy { min-width: 0; padding-right: 13px; }
.slot-copy strong { display: block; overflow: hidden; font-size: 15px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.slot-copy small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.is-empty .slot-visual { color: var(--tomato); background: var(--tomato-soft); font-size: 27px; }
.is-empty .slot-copy strong { color: var(--tomato-dark); }
.is-empty .slot-copy small { color: var(--muted); }

.action-dock { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 24px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper-deep); }
.dock-copy { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.dock-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mustard); }
.dock-actions { display: flex; gap: 9px; }
.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 10px; padding: 8px 14px; font-size: 12px; transition: .2s ease; }
.button span { font-size: 17px; line-height: 1; }
.button-primary { color: var(--paper); border-color: var(--tomato); background: var(--tomato); box-shadow: 0 4px 0 rgba(186,72,54,.18); }
.button-primary:hover { background: var(--tomato-dark); border-color: var(--tomato-dark); transform: translateY(-1px); }
.button-quiet { color: var(--ink); border-color: var(--line); background: var(--paper); }
.button-quiet:hover { border-color: var(--tomato); color: var(--tomato-dark); }
.button-block { width: 100%; margin-top: 20px; }

.library-heading { padding-bottom: 26px; }
.library-heading h1 { font-size: clamp(32px, 4.5vw, 48px); }
.library-count { display: flex; align-items: baseline; gap: 7px; color: var(--muted); }
.library-count strong { color: var(--tomato); font-family: 'DM Mono', monospace; font-size: 45px; font-weight: 500; line-height: 1; }
.library-count span { font-size: 13px; }
.library-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.search-field { min-width: 210px; display: flex; align-items: center; gap: 7px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.search-field span { color: var(--muted); font-size: 21px; }
.search-field input { width: 100%; height: 37px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.search-field input::placeholder { color: #aaa095; }
.category-tabs { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.tab-button { border: 1px solid var(--line); border-radius: 99px; padding: 7px 12px; color: var(--muted); background: transparent; font-size: 11px; transition: .2s ease; }
.tab-button.is-active { border-color: var(--sage); color: var(--sage); background: var(--sage-soft); }
.sync-bar { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 10px 0; color: var(--muted); font-size: 11px; }
.sync-indicator { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--mustard); }
.sync-indicator.is-online { background: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft); }
.sync-indicator.is-busy { background: var(--tomato); animation: sync-pulse 1.1s ease-in-out infinite; }
.sync-indicator.is-offline { background: #aaa095; }
.sync-version { color: #aaa095; font-family: 'DM Mono', monospace; font-size: 10px; }
.sync-actions { display: inline-flex; gap: 5px; margin-left: auto; }
.sync-button { display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 8px; padding: 6px 9px; color: var(--muted); background: transparent; font-size: 11px; }
.sync-button:hover { color: var(--sage); background: var(--sage-soft); }
@keyframes sync-pulse { 50% { opacity: .35; } }
.library-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 30px; padding-top: 25px; }
.dish-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 10px; }
.dish-row { display: flex; align-items: center; gap: 10px; min-height: 74px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.dish-row-visual { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 42px; border-radius: 13px; font-size: 22px; }
.dish-row-copy { min-width: 0; flex: 1; }
.dish-row-copy strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.dish-row-copy small { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.dish-row-actions { display: flex; align-items: center; gap: 4px; }
.mini-button { width: 29px; height: 29px; display: grid; place-items: center; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 16px; }
.mini-button:hover { color: var(--tomato); background: var(--tomato-soft); }
.empty-library { grid-column: 1 / -1; padding: 40px 20px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; font-size: 13px; }
.add-panel { align-self: start; padding: 21px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper-deep); }
.add-panel-heading { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 20px; }
.add-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; color: var(--tomato); background: var(--tomato-soft); font-size: 21px; }
.add-panel h2 { margin: 1px 0 4px; font-size: 16px; }
.add-panel-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.field-label { display: block; margin: 13px 0 7px; color: var(--ink); font-size: 11px; }
.field-label span { color: var(--muted); font-size: 10px; }
.text-input { width: 100%; min-height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; outline: 0; color: var(--ink); background: var(--paper); font-size: 12px; }
.text-input:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(79,132,114,.13); }
.text-area { resize: vertical; line-height: 1.55; }
.form-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 9px; }
.form-hint { margin: 14px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 25px; max-width: calc(100% - 40px); padding: 11px 16px; border-radius: 99px; color: var(--paper); background: var(--ink); box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 14px); transition: .25s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.site-footer { width: min(1180px, calc(100% - 40px)); display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 9px 18px; margin: 0 auto; padding: 24px 0 30px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.site-footer a { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--tomato-dark); }
.site-footer img { width: 14px; height: 14px; object-fit: contain; }

@media (max-width: 760px) {
  .topbar, main, .site-footer { width: min(100% - 28px, 620px); }
  .topbar { height: 69px; }
  .hero-row, .library-heading { align-items: flex-start; padding: 30px 0 24px; }
  .hero-sticker { width: 112px; height: 96px; flex-basis: 112px; transform: scale(.8) rotate(4deg); transform-origin: top right; margin-right: -10px; }
  h1 { font-size: clamp(31px, 8.8vw, 44px); }
  .control-strip { padding: 15px 0; }
  .meal-note { width: 100%; justify-content: flex-end; }
  .category-section { grid-template-columns: 1fr; gap: 14px; padding: 18px 0; }
  .category-heading { align-items: center; }
  .category-meta { margin: 0 0 0 auto; }
  .category-heading-wrap { display: flex; align-items: center; justify-content: space-between; }
  .slot-grid { gap: 8px; }
  .dish-slot { min-height: 104px; }
  .dish-slot-main { gap: 9px; padding: 12px 43px 12px 10px; }
  .slot-select-toggle { right: 7px; width: 28px; height: 28px; }
  .slot-select-menu { right: 6px; left: 6px; }
  .slot-visual { width: 50px; height: 50px; flex-basis: 50px; border-radius: 15px; font-size: 26px; }
  .slot-copy strong { font-size: 13px; }
  .slot-copy small { font-size: 10px; }
  .action-dock { align-items: stretch; flex-direction: column; padding: 14px; }
  .dock-actions { display: grid; grid-template-columns: 1fr 1.2fr; }
  .button { padding: 8px 9px; font-size: 11px; }
  .library-heading { align-items: end; }
  .library-count strong { font-size: 34px; }
  .library-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .category-tabs { justify-content: flex-start; }
  .sync-bar { align-items: flex-start; flex-wrap: wrap; }
  .sync-actions { width: 100%; margin-left: 15px; }
  .library-layout { grid-template-columns: 1fr; gap: 25px; }
  .dish-list { grid-template-columns: 1fr; }
  .add-panel { order: -1; }
}

@media (max-width: 400px) {
  .topnav { padding: 3px; }
  .nav-button { padding: 8px 10px; font-size: 12px; }
  .brand small { display: none; }
  .hero-sticker { display: none; }
  .menu-summary { align-items: flex-end; }
  .summary-progress { width: 98px; }
  .slot-grid { grid-template-columns: 1fr; }
  .dish-slot { min-height: 79px; }
  .dish-slot-main { padding-top: 10px; padding-bottom: 10px; }
  .slot-visual { width: 44px; height: 44px; flex-basis: 44px; font-size: 23px; }
  .slot-copy small { margin-top: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
