:root {
  color-scheme: light;
  --ink: #26352c;
  --muted: #89928a;
  --green: #587d61;
  --green-dark: #416749;
  --green-light: #edf3eb;
  --border: #e9ece5;
  --paper: #fff;
  --bg: #f6f7f2;
  --orange: #e8a66e;
  font-family: 'DM Sans', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding: 22px 0 32px; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0 2px 20px; border-bottom: 1px solid #e8ebe4; }
.brand { display: inline-flex; gap: 9px; align-items: center; color: var(--ink); text-decoration: none; font-family: Manrope, sans-serif; font-size: 19px; font-weight: 800; letter-spacing: -.8px; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 10px; background: #e9f0e5; color: var(--green); font-size: 19px; }
.brand-light { color: var(--green); }
.local-note { display: inline-flex; align-items: center; gap: 8px; color: #788379; font-size: 12px; }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: #76a47a; }
.intro { display: flex; justify-content: space-between; align-items: center; padding: 30px 2px 22px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: Manrope, sans-serif; }
h1 { margin-bottom: 7px; font-size: clamp(26px, 3.2vw, 35px); letter-spacing: -1.5px; line-height: 1.2; }
.intro-copy { margin-bottom: 0; color: #788178; font-size: 13px; }
.date-card { display: flex; align-items: center; gap: 12px; padding: 11px 15px; border: 1px solid var(--border); border-radius: 13px; background: rgba(255,255,255,.7); }
.date-card-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: #f9f0e4; color: #d6995c; font-size: 20px; }
.date-card-label, .summary-label { display: block; color: #939b91; font-size: 9px; font-weight: 700; letter-spacing: 1px; }
.date-card strong { display: block; margin-top: 3px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.summary-card { display: flex; min-height: 90px; align-items: center; gap: 13px; padding: 15px 17px; border: 1px solid var(--border); border-radius: 14px; background: var(--paper); }
.summary-icon { display: grid; flex: 0 0 40px; height: 40px; place-items: center; border-radius: 12px; font-size: 19px; }
.food-icon { color: #77916d; background: #eff4eb; }
.calories-icon { color: #d49a62; background: #fbf1e7; }
.water-icon { color: #76a8a4; background: #eaf4f2; font-size: 26px; }
.summary-card strong { display: block; margin-top: 5px; font-family: Manrope, sans-serif; font-size: 20px; line-height: 1.1; }
.summary-card div > small { display: block; margin-top: 3px; color: #9ba198; font-size: 10px; }
.summary-card strong .unit { display: inline; margin: 0; color: #858e84; font-family: 'DM Sans', sans-serif; font-size: 10px; font-weight: 500; }
.water-summary { gap: 11px; }
.water-content { flex: 1; min-width: 0; }
.water-track { height: 4px; margin-top: 8px; overflow: hidden; border-radius: 3px; background: #edf1ed; }
.water-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: #80aaa3; transition: width .2s ease; }
.water-cups { display: flex; gap: 2px; margin-top: 5px; }
.water-cup { display: grid; width: 16px; height: 19px; padding: 1px; place-items: center; border: 0; border-radius: 3px; background: transparent; cursor: pointer; }
.water-cup svg { width: 13px; height: 15px; fill: transparent; stroke: #91b9b2; stroke-width: 1.8; transition: fill .15s; }
.water-cup.active svg { fill: #a7d2ca; }
.water-cup:focus-visible { outline: 2px solid #80aaa3; outline-offset: 1px; }
.water-add { width: 28px; height: 28px; border: 1px solid #dfe9e5; border-radius: 9px; background: #f7fbfa; color: #609087; font-size: 18px; line-height: 1; }
.content-grid { display: grid; grid-template-columns: minmax(300px, .82fr) minmax(0, 1.45fr); gap: 14px; margin-top: 16px; }
.panel { min-width: 0; padding: 21px; border: 1px solid var(--border); border-radius: 15px; background: var(--paper); }
.panel-heading, .diary-heading { display: flex; justify-content: space-between; align-items: center; }
.panel h2, .diary-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.5px; }
.heading-sparkle { color: #a7ba9c; font-size: 23px; }
form { display: grid; gap: 12px; margin-top: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
label { display: grid; gap: 6px; color: #5e695f; font-size: 11px; font-weight: 600; }
input, select, textarea { width: 100%; min-width: 0; padding: 10px 11px; border: 1px solid #e6eae3; border-radius: 8px; outline: none; background: #fff; color: var(--ink); font-size: 11px; font-weight: 400; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #9db89b; box-shadow: 0 0 0 3px #eff5ed; }
input::placeholder, textarea::placeholder { color: #abb2aa; }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 57px; }
.optional { color: #a1a89f; font-weight: 400; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 39px; }
.input-suffix span { position: absolute; top: 50%; right: 10px; color: #99a196; font-size: 9px; transform: translateY(-50%); }
.form-actions { display: flex; gap: 8px; }
.primary-button { flex: 1; padding: 11px 12px; border: 0; border-radius: 8px; background: var(--green); color: white; font-size: 11px; font-weight: 600; transition: background .15s; }
.primary-button:hover { background: var(--green-dark); }
.primary-button span { margin-right: 4px; font-size: 15px; vertical-align: -1px; }
.cancel-button { padding: 0 13px; border: 1px solid var(--border); border-radius: 8px; background: white; color: #6a756b; font-size: 11px; }
.hidden { display: none !important; }
.view-switch { display: flex; gap: 5px; margin-top: 18px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: #edf0e9; width: fit-content; }
.view-tab { padding: 8px 14px; border: 0; border-radius: 7px; background: transparent; color: #778177; font-size: 11px; font-weight: 600; }
.view-tab.active { background: #fff; box-shadow: 0 1px 3px #26352c14; color: var(--green-dark); }
.view-tab:focus-visible { outline: 2px solid #80a680; outline-offset: 2px; }
.sheet-panel { margin-top: 14px; }
.sheet-scroll { margin-top: 16px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.sheet-table { width: 100%; min-width: 900px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.sheet-table th, .sheet-table td { border-right: 1px solid #edf0ea; border-bottom: 1px solid #edf0ea; }
.sheet-table thead th { height: 36px; padding: 0 8px; background: #f7f8f5; color: #687468; font-size: 10px; font-weight: 600; text-align: left; white-space: nowrap; }
.sheet-table tbody th { background: #f7f8f5; color: #929b91; font-size: 10px; font-weight: 500; text-align: center; }
.sheet-table th:last-child, .sheet-table td:last-child { border-right: 0; }
.sheet-table tbody tr:last-child th, .sheet-table tbody tr:last-child td { border-bottom: 0; }
.sheet-table .row-number { width: 34px; }
.sheet-table .row-action-heading, .sheet-table .row-action { width: 34px; text-align: center; }
.sheet-table td { height: 37px; padding: 0; background: #fff; }
.sheet-table td input { height: 36px; padding: 7px 8px; border: 0; border-radius: 0; background: transparent; font-size: 11px; }
.sheet-table td input:focus { position: relative; z-index: 1; border: 1px solid #80a680; box-shadow: inset 0 0 0 1px #80a680; }
.sheet-table td.row-action { padding: 0; }
.delete-row-button { width: 28px; height: 28px; border: 0; border-radius: 5px; background: transparent; color: #a2aaa0; font-size: 18px; line-height: 1; }
.delete-row-button:hover { background: #fbefed; color: #bf6d61; }
.add-row-button { margin-top: 10px; padding: 8px 11px; border: 1px solid #e3e9e0; border-radius: 7px; background: #f8faf7; color: var(--green-dark); font-size: 10px; font-weight: 600; }
.add-row-button:hover { background: #eff5ed; }
.sheet-note { margin: 10px 0 0; color: #929b91; font-size: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.diary-panel { display: flex; min-height: 432px; flex-direction: column; }
.diary-heading { flex-wrap: wrap; gap: 10px; }
.filter-label { display: none; }
.day-filter { width: 132px; padding: 8px 9px; color: #687468; font-size: 10px; }
.meal-list { flex: 1; margin-top: 15px; }
.meal-row { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #eff1ed; }
.meal-time { align-self: stretch; padding-top: 3px; color: #8c958c; font-size: 10px; }
.meal-info { min-width: 0; }
.meal-type { display: block; margin-bottom: 3px; color: #7d987a; font-size: 9px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; }
.meal-name { display: block; overflow: hidden; color: #354139; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.meal-details { display: block; overflow: hidden; margin-top: 3px; color: #9aa198; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.meal-calories { color: #758072; font-size: 10px; white-space: nowrap; }
.meal-calories strong { color: #4b5c4d; font-size: 11px; }
.meal-actions { display: flex; gap: 3px; margin-top: 6px; }
.meal-actions button { padding: 2px 5px; border: 0; background: transparent; color: #89968b; font-size: 9px; }
.meal-actions button:hover { color: var(--green-dark); }
.meal-actions .delete-meal:hover { color: #bf6d61; }
.empty-state { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-height: 190px; color: #9ca59a; text-align: center; }
.empty-illustration { display: grid; width: 45px; height: 45px; margin-bottom: 3px; place-items: center; border-radius: 15px; background: #f5f3eb; font-size: 21px; }
.empty-state strong { color: #647064; font-size: 11px; }
.empty-state > span:last-child { font-size: 10px; }
.day-footer { display: flex; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid #eff1ed; color: #969f95; font-size: 9px; }
.footer-sparkle { margin-right: 3px; color: #a5b99d; }
.day-footer > span:last-child { color: #687768; font-weight: 600; }
.export-panel { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 15px; padding: 15px 18px; border: 1px solid var(--border); border-radius: 13px; background: #fff; }
.export-copy { display: flex; align-items: center; gap: 10px; }
.export-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: #eff4eb; color: var(--green); font-size: 17px; }
.export-copy strong, .export-copy span { display: block; }
.export-copy strong { margin-bottom: 3px; color: #465348; font-size: 10px; }
.export-copy div > span { color: #98a096; font-size: 9px; }
.export-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.export-button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid #e8ebe5; border-radius: 7px; background: #fff; color: #606b61; font-size: 9px; font-weight: 600; }
.export-button:hover { border-color: #c8d6c6; background: #f8faf7; }
.file-icon { display: grid; width: 15px; height: 15px; place-items: center; border-radius: 4px; font-size: 9px; font-weight: 700; }
.excel { background: #e9f3eb; color: #438152; }
.csv { background: #f0f1f5; color: #68718b; }
.json { background: #f8f0e8; color: #be8b54; font-size: 7px; }
.image { background: #edf3f4; color: #658d98; font-size: 12px; }
.print { background: #f3eff5; color: #88729a; }
.page-footer { padding: 17px 0 0; color: #a1a79e; font-size: 9px; text-align: center; }
.page-footer span { color: #d3937b; }
.toast { position: fixed; right: 22px; bottom: 20px; z-index: 5; max-width: min(360px, calc(100% - 40px)); padding: 11px 15px; border-radius: 9px; background: #344c39; box-shadow: 0 8px 25px #26352c26; color: #fff; font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 30px, 560px); padding-top: 15px; }
  .intro { padding-top: 24px; }
  .summary-grid { gap: 8px; }
  .summary-card { min-height: 82px; gap: 8px; padding: 11px; }
  .summary-icon { flex-basis: 32px; height: 32px; border-radius: 10px; }
  .summary-card strong { font-size: 17px; }
  .summary-card div > small { font-size: 9px; }
  .content-grid { grid-template-columns: 1fr; }
  .diary-panel { min-height: 350px; }
  .export-panel { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 460px) {
  .app-shell { width: calc(100% - 24px); }
  .local-note { font-size: 10px; }
  .intro { align-items: flex-start; gap: 10px; }
  .intro-copy { max-width: 240px; font-size: 11px; line-height: 1.5; }
  .date-card { gap: 8px; padding: 8px; }
  .date-card-icon { width: 28px; height: 28px; }
  .date-card strong { max-width: 85px; font-size: 10px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .water-summary { grid-column: 1 / -1; }
  .panel { padding: 16px; }
  .export-actions { width: 100%; }
  .export-button { flex: 1; justify-content: center; min-width: 75px; }
}
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .app-shell { width: 100%; padding: 0; }
  .topbar, .entry-panel, .export-panel, .page-footer, .water-add, .meal-actions, .filter-label, .day-filter { display: none !important; }
  .intro { padding: 0 0 14px; }
  .summary-grid { margin-bottom: 12px; }
  .summary-card, .panel { border-color: #d8ddd5; break-inside: avoid; }
  .content-grid { display: block; margin: 0; }
  .diary-panel { min-height: auto; }
  .meal-row { break-inside: avoid; }
  .empty-state { min-height: 80px; }
  .day-footer { margin-top: 8px; }
}
