:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1f2a24;
  --muted: #5d6b63;
  --line: #d9ddd6;
  --accent: #2f7d5b;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ea;
  --locked: #fff3c4;
  --changed: #d7f5e3;
  --sat: #1f5fbf;
  --sun: #c0392b;
  --radius: 12px;
  font-size: 17px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", sans-serif;
  line-height: 1.5;
}
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.secondary { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
button.ghost { background: transparent; }
button.big { padding: 12px 22px; font-size: 1.1rem; }
input, textarea, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; gap: 12px; align-items: center; }
.logo { font-size: 2rem; }
.brand h1 { margin: 0; font-size: 1.4rem; }
.sub { margin: 0; color: var(--muted); font-size: .9rem; }
.top-actions { display: flex; gap: 6px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; padding: 16px; align-items: start; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }

.steps { display: grid; gap: 10px; margin-bottom: 16px; }
.step { display: flex; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.step-num { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; }
.step-body { flex: 1; min-width: 0; }
.step h2 { margin: 2px 0 8px; font-size: 1.05rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.drop { display: block; border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.status { margin: 8px 0 0; color: var(--accent); font-weight: 600; }
.hint { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }
.chip { padding: 1px 8px; border-radius: 6px; }
.chip.locked { background: var(--locked); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }

.plan-area { display: grid; gap: 18px; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); }
.week { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; margin: 2px 4px 10px; }
.week-head h3 { margin: 0; font-size: 1.05rem; }
.week-head .hosp { color: var(--muted); font-size: .9rem; }
.table-wrap { overflow-x: auto; }
table.menu { border-collapse: collapse; width: 100%; min-width: 820px; table-layout: fixed; font-size: .92rem; }
table.menu th, table.menu td { border: 1px solid #b9c0b8; text-align: center; padding: 4px 3px; }
table.menu thead th { background: #eef2ec; font-weight: 700; }
table.menu thead th.sat { color: var(--sat); }
table.menu thead th.sun { color: var(--sun); }
table.menu th.label { width: 64px; background: #f3f5f1; font-weight: 700; }
table.menu td { cursor: pointer; height: 30px; word-break: keep-all; overflow-wrap: anywhere; line-height: 1.3; }
table.menu td:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
table.menu td.locked { background: var(--locked); }
table.menu td.changed { background: var(--changed); transition: background 1.5s; }
table.menu td.off { background: #eceee9; cursor: default; }
table.menu td.porridge { color: var(--muted); font-size: .85rem; }
table.menu tr.meal-start td, table.menu tr.meal-start th { border-top: 2px solid #6d7a70; }
table.menu tr.kcal td { color: var(--muted); cursor: default; }

.chat { position: sticky; top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; height: calc(100vh - 110px); min-height: 480px; }
@media (max-width: 1100px) { .chat { position: static; height: 560px; } }
.chat-head { padding: 12px 14px 6px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; font-size: 1.05rem; }
.chat-head p { margin: 2px 0 6px; color: var(--muted); font-size: .88rem; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 8px 12px; border-radius: 12px; max-width: 92%; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.bot { align-self: flex-start; background: #eef2ec; }
.msg.err { background: #fde8e6; }
.msg .undo-link { display: inline-block; margin-top: 4px; font-size: .85rem; color: var(--accent); text-decoration: underline; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.chips button { font-size: .82rem; padding: 4px 10px; border-radius: 99px; }
.chat-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); align-items: stretch; }
.chat-input textarea { flex: 1; resize: none; min-width: 0; }
.mic { font-size: 1.3rem; padding: 6px 10px; }
.mic.on { background: #fde8e6; border-color: var(--sun); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.pop { position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 12px; width: 300px; }
.pop-title { font-weight: 700; margin-bottom: 6px; }
.pop input { width: 100%; }
.pop-actions { display: flex; gap: 6px; margin-top: 8px; justify-content: flex-end; flex-wrap: wrap; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(900px, 94vw); max-height: 86vh; }
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.dlg-head h2 { margin: 0; font-size: 1.1rem; }
#dlgBody { padding: 14px 16px; }
.lib-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.lib-tabs button.on { background: var(--accent); color: #fff; }
.lib-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.lib-item { display: flex; justify-content: space-between; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: .9rem; }
.lib-item.hidden { opacity: .4; text-decoration: line-through; }
.lib-item small { color: var(--muted); }
.lib-item select { padding: 2px; font-size: .8rem; }
.form-grid { display: grid; grid-template-columns: 160px 1fr; gap: 10px 14px; align-items: center; }
.form-grid textarea { width: 100%; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2a24; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 50; }

@media print {
  .top, .steps, .chat, .pop { display: none !important; }
  .layout { display: block; padding: 0; }
  .week { border: 0; page-break-after: always; }
  table.menu td.locked, table.menu td.changed { background: none; }
}

table.menu tr.nut th, table.menu tr.nut td { cursor: default; font-size: .82rem; color: var(--muted); background: #fafbf8; }
table.menu tr.nut td:hover { outline: none; }
table.menu tr.warn td.good { color: var(--accent); font-weight: 600; }
table.menu tr.warn td.bad { color: var(--sun); background: #fdf0ee; font-weight: 600; }

.site-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: #1f2a24; position: sticky; top: 0; z-index: 30; }
.site-tabs button { border: 0; border-radius: 0; background: transparent; color: #cfd8d2; font-size: 1.25rem; font-weight: 800; padding: 14px 10px; letter-spacing: .02em; }
.site-tabs button.on { background: var(--accent); color: #fff; box-shadow: inset 0 -5px 0 #f5c542; }
.site-tabs button:not(.on):hover { background: #2c3a32; color: #fff; }
body[data-site="esco"] { --accent: #2a5d9f; --accent-soft: #e4edf8; }
