/* ============================================================
   딸깍 식단 · 홈페이지 리디자인 v3.0
   Design tokens & components (Pretendard / warm off-white)
   ============================================================ */
:root {
    --bg: #FAF8F5;
    --surface: #FFFFFF;
    --surface-sunken: #F5F1EB;
    --surface-input: #FAF8F5;
    --surface-faint: #FCFBF9;

    --text: #221F1A;
    --text-2: #57534E;
    --text-muted: #8A8378;
    --text-faint: #B5AEA3;
    --text-faintest: #C9C2B6;

    --border: #E8E3DB;
    --border-light: #F0EBE3;

    --primary: #2F6B4E;
    --primary-hover: #275B42;
    --primary-soft: #EAF2ED;
    --primary-soft-hover: #DDEAE2;

    --accent: #D97D3E;
    --accent-text: #B05F22;
    --accent-soft: #FBEFE4;

    --danger: #C2410C;
    --toggle-off: #D8D2C8;

    --dot-rice: #8FAE9B;
    --dot-soup: #7D9BB8;
    --dot-main1: #C97B5A;
    --dot-side: #C9A85A;
    --dot-kimchi: #B87D8F;
    --dot-dessert: #9B8FB8;

    --radius-card: 14px;
    --radius-input: 9px;
    --radius-modal: 16px;

    --shadow-modal: 0 16px 40px rgba(34, 31, 26, 0.18);
    --shadow-loading: 0 12px 32px rgba(34, 31, 26, 0.1);
    --shadow-primary: 0 1px 2px rgba(47, 107, 78, 0.3);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

input, textarea, select, button {
    font-family: inherit;
    color: inherit;
}

h1, h2, h3, h4, p { margin: 0; }

@keyframes ringspin { 100% { transform: rotate(360deg); } }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: var(--radius-input);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid transparent;
    padding: 9px 14px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-sunken); }

.btn-soft { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.btn-soft:hover { background: var(--primary-soft-hover); }

.btn-generate {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 9px 18px;
    box-shadow: var(--shadow-primary);
}
.btn-generate:hover { background: var(--primary-hover); }

.btn-icon-text svg { flex: 0 0 auto; }
.btn-block { width: 100%; }
.btn-block--tall { padding: 12px; font-size: 0.9rem; margin-top: 6px; }
.btn-sm { padding: 8px 13px; font-size: 0.8rem; }
.btn-xs { padding: 4px 10px; font-size: 0.75rem; border-radius: 7px; }

.btn-nav {
    width: 34px; height: 34px; padding: 0;
    background: var(--surface); border-color: var(--border); color: var(--text-2);
}
.btn-nav:hover { background: var(--surface-sunken); }

.btn-danger-text { background: transparent; border: none; color: var(--danger); font-weight: 600; }
.btn-danger-text:hover { background: var(--accent-soft); }

/* ---------- App bar ---------- */
.appbar {
    min-height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 28px;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
}
.appbar__brand { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px; background: var(--primary);
    display: flex; align-items: center; justify-content: center;
}
.brand-mark__bowl {
    width: 14px; height: 7px; border-radius: 0 0 14px 14px; background: #fff; margin-top: 4px;
}
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-name { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; white-space: nowrap; }

.appbar__actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; flex-wrap: wrap; }

.visit-counter {
    font-size: 0.8rem; color: var(--text-muted); margin-right: 6px; white-space: nowrap;
}
.visit-counter strong { color: var(--text); font-weight: 700; }
.visit-total { color: var(--primary); }
.visit-total-wrap { display: none; }
body.admin-mode .visit-total-wrap { display: inline; }
body.hide-visit-counter .visit-counter { display: none; }

.admin-badge {
    display: none;
    padding: 3px 9px; border-radius: 6px;
    background: var(--primary-soft); color: var(--primary);
    font-size: 0.7rem; font-weight: 700;
}

/* ---------- Layout ---------- */
.layout {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    padding: 24px 28px;
    max-width: 1680px;
    margin: 0 auto;
}
.sidebar {
    width: 288px; flex: 0 0 288px;
    display: flex; flex-direction: column; gap: 16px;
    position: sticky; top: 88px;
}
.main { flex: 1; min-width: 0; }

/* ---------- Side cards ---------- */
.side-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 20px;
}
.side-card__head { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.side-card__head--between { justify-content: space-between; margin-bottom: 12px; }
.side-card__head-left { display: flex; align-items: center; gap: 8px; }
.side-card__head h3 { font-size: 0.95rem; font-weight: 700; }

.dot { width: 8px; height: 8px; border-radius: 4px; flex: 0 0 8px; }
.dot--accent { background: var(--accent); }

.pill {
    padding: 2px 8px; border-radius: 6px;
    background: var(--primary-soft); color: var(--primary);
    font-size: 0.68rem; font-weight: 700;
}

.side-note { margin-top: 10px; font-size: 0.72rem; color: var(--text-faint); line-height: 1.5; }
.side-note--tight { margin: 8px 0 14px; color: var(--text-muted); font-size: 0.75rem; }

.field { margin-bottom: 18px; }
.field > label {
    display: block; font-size: 0.78rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 8px;
}

.range-inputs { display: flex; align-items: center; gap: 8px; }
.range-inputs input {
    flex: 1; min-width: 0; padding: 9px 10px;
    border: 1px solid var(--border); border-radius: var(--radius-input);
    font-size: 0.85rem; background: var(--surface-input); color: var(--text);
}
.range-inputs input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.range-sep { color: var(--text-faint); font-size: 0.85rem; }
.range-unit { color: var(--text-muted); font-size: 0.8rem; }

/* Stepper */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper__btn {
    width: 34px; height: 34px; border: 1px solid var(--border);
    background: var(--surface-input); cursor: pointer; font-size: 1rem; color: var(--text-2);
    display: flex; align-items: center; justify-content: center;
}
.stepper__btn:first-of-type { border-radius: var(--radius-input) 0 0 var(--radius-input); border-right: none; }
.stepper__btn:nth-of-type(2) { border-radius: 0 var(--radius-input) var(--radius-input) 0; border-left: none; }
.stepper__btn:hover { background: var(--border-light); }
.stepper__input {
    width: 46px; height: 34px; text-align: center;
    border: 1px solid var(--border); border-left: none; border-right: none;
    background: var(--surface); font-size: 0.9rem; font-weight: 700; color: var(--text);
    -moz-appearance: textfield; appearance: textfield;
}
.stepper__input:focus { outline: none; }
.stepper__input::-webkit-outer-spin-button,
.stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper__unit { font-size: 0.8rem; color: var(--text-muted); }

/* Toggle switch */
.toggle-list { display: flex; flex-direction: column; gap: 10px; }
.toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; cursor: pointer; min-height: 24px; font-size: 0.83rem; color: var(--text);
}
.toggle-row--boxed {
    border: 1px solid var(--border); border-radius: 10px;
    padding: 12px 14px; background: var(--surface-input); margin-bottom: 14px;
}
.switch { position: relative; display: inline-flex; flex: 0 0 34px; }
.switch-input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    width: 34px; height: 20px; border-radius: 10px; background: var(--toggle-off);
    position: relative; transition: background 0.15s; display: inline-block;
}
.switch-knob {
    width: 16px; height: 16px; border-radius: 8px; background: #fff;
    position: absolute; top: 2px; left: 2px; transition: left 0.15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.switch-input:checked + .switch-track { background: var(--primary); }
.switch-input:checked + .switch-track .switch-knob { left: 16px; }
.switch-input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* 이달의 메뉴 */
body.hide-trend-banner .trend-card { display: none; }
.trend-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.trend-chip {
    padding: 4px 10px; border-radius: 8px;
    background: var(--accent-soft); color: var(--accent-text);
    font-size: 0.78rem; font-weight: 600;
}
.trend-empty { font-size: 0.78rem; color: var(--text-faint); }

/* 운영 관리 */
.admin-btn-stack { display: flex; flex-direction: column; gap: 8px; }
.admin-btn-stack .btn { font-weight: 600; font-size: 0.83rem; }

.sidebar-version { margin: 4px 0 0; text-align: center; font-size: 0.7rem; color: var(--text-faintest); }

/* ---------- Ad slots ---------- */
.sidebar-ad-stack { display: flex; flex-direction: column; gap: 16px; }
.ad-slot {
    position: relative;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-card);
    background: var(--surface-sunken);
    padding: 10px;
    overflow: hidden;
}
.ad-slot::after {
    content: "AD";
    position: absolute; top: 8px; right: 10px;
    font-size: 0.62rem; font-weight: 700; color: var(--text-faint); letter-spacing: 0.05em;
    z-index: 2; pointer-events: none;
}
.ad-slot--filled { background: var(--surface); }
.ad-slot--filled::after { display: none; }

.ad-slot__variant { width: 100%; }
.ad-slot--medium .ad-slot__placeholder { aspect-ratio: 300 / 250; }
.ad-slot--halfpage .ad-slot__placeholder { aspect-ratio: 300 / 600; }
.ad-slot--leaderboard { display: flex; justify-content: center; }
.ad-slot--leaderboard .ad-slot__placeholder { width: 970px; max-width: 100%; aspect-ratio: 970 / 90; }
.ad-slot--mobile-leaderboard .ad-slot__placeholder { aspect-ratio: 320 / 100; }

.ad-slot__placeholder {
    width: 100%;
    border-radius: var(--radius-input);
    background: repeating-linear-gradient(45deg, #EFEAE2 0 8px, var(--surface-sunken) 8px 16px);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 60px; text-align: center; padding: 8px;
}
.ad-slot__placeholder strong { font-size: 0.72rem; color: var(--text-2); font-weight: 600; }
.ad-slot__placeholder span { font-family: ui-monospace, monospace; font-size: 0.68rem; color: var(--text-muted); }

.ad-slot__media { display: block; width: 100%; height: auto; border-radius: var(--radius-input); }
.ad-slot__link { display: block; }

/* 미등록(빈) 광고 슬롯 숨기기 */
body.hide-empty-ad-slots .ad-slot:not(.ad-slot--filled) { display: none; }

.ad-strip { margin-top: 20px; }
.ad-strip--mobile { display: none; }

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.toolbar__nav { display: flex; align-items: center; gap: 10px; }
.toolbar__nav h2 {
    font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em;
    min-width: 130px; text-align: center;
}
.toolbar__weekend { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-left: 8px; }
.toolbar__weekend-label { font-size: 0.8rem; color: var(--text-2); font-weight: 500; }

.metrics {
    display: flex; align-items: center; gap: 28px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 10px 20px;
}
.metric { display: flex; flex-direction: column; gap: 2px; }
.metric__label { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); }
.metric strong { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; }
.metric--green { color: var(--primary); }
.metric__div { width: 1px; height: 28px; background: var(--border); }

/* ---------- Calendar ---------- */
.calendar-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    overflow: hidden;
}
.monthly-calendar { display: grid; grid-template-columns: repeat(5, 1fr); }

.cal-dow {
    background: var(--bg); color: var(--text-muted);
    font-weight: 700; text-align: center; padding: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem; letter-spacing: 0.02em;
}
.cal-dow.sun { color: var(--danger); }
.cal-dow.sat { color: var(--dot-soup); }

.cal-cell {
    min-height: 236px;
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    padding: 10px; min-width: 0;
    display: flex; flex-direction: column;
    background: var(--surface);
}
.cal-cell--blank { background: var(--surface-faint); }
.cal-cell--weekend { background: var(--bg); }

.cal-cell__head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px; min-height: 24px;
}
.cal-date { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.cal-date.sun { color: var(--danger); }
.cal-date.sat { color: var(--dot-soup); }
.cal-date--today {
    width: 24px; height: 24px; border-radius: 12px;
    background: var(--primary); color: #fff;
    font-size: 0.8rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.cal-daycost { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); }

.cal-slot {
    display: flex; align-items: center; gap: 7px;
    padding: 4px 6px; border-radius: 7px; cursor: pointer; min-width: 0;
    transition: background 0.12s;
}
.cal-slot:hover { background: var(--surface-sunken); }
.cal-dot { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 3px; }
.cal-name {
    font-size: 0.79rem; color: var(--text); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1;
}
.cal-slot--empty .cal-name { color: var(--text-faint); font-weight: 400; }
.cal-slot--empty .cal-dot { opacity: 0.4; }
.cal-hot {
    padding: 1px 6px; border-radius: 6px;
    background: var(--accent-soft); color: var(--accent-text);
    font-size: 0.62rem; font-weight: 700; flex: 0 0 auto;
}

.cal-foot {
    margin-top: auto; padding-top: 7px; border-top: 1px solid var(--border-light);
    display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--text-muted);
}
.cal-budget { font-weight: 700; }
.cal-budget--ok { color: var(--primary); }
.cal-budget--over { color: var(--danger); }

/* ---------- Loading overlay ---------- */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(250, 248, 245, 0.85);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.loading-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px; padding: 36px 44px;
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    box-shadow: var(--shadow-loading);
}
.loading-spinner {
    width: 36px; height: 36px; border-radius: 18px;
    border: 3px solid var(--primary-soft); border-top-color: var(--primary);
    animation: ringspin 0.8s linear infinite;
}
.loading-card__text { text-align: center; }
.loading-card__text h2 { font-size: 1.05rem; font-weight: 800; margin-bottom: 4px; }
.loading-card__text p { color: var(--text-muted); font-size: 0.83rem; }

/* ---------- Modals ---------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(34, 31, 26, 0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 16px;
}
.modal-content {
    background: var(--surface); border-radius: var(--radius-modal);
    width: 440px; max-width: calc(100vw - 32px);
    padding: 26px; box-shadow: var(--shadow-modal);
    display: flex; flex-direction: column;
}
.modal-content--narrow { width: 380px; }
.modal-content--wide { width: min(600px, calc(100vw - 32px)); }
.modal-content--tall { max-height: min(720px, calc(100vh - 32px)); overflow: hidden; }

.modal-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 12px; margin-bottom: 18px; flex-shrink: 0;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 3px; }
.modal-sub { font-size: 0.78rem; color: var(--text-muted); }
.btn-close {
    background: none; border: none; font-size: 1.2rem; cursor: pointer;
    color: var(--text-faint); line-height: 1; padding: 0;
}
.btn-close:hover { color: var(--text-2); }

.modal-body { flex: 1 1 auto; }
.modal-body--scroll { min-height: 0; overflow-y: auto; padding-right: 4px; }
.modal-help { font-size: 0.75rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }

.modal-footer {
    display: flex; gap: 8px; flex-shrink: 0;
    margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border-light);
}
.modal-footer--end { justify-content: flex-end; }
.modal-footer--between { justify-content: space-between; }
.modal-footer__group { display: flex; gap: 8px; }

/* Form fields */
.form-group { margin-bottom: 14px; }
.form-group > label {
    display: block; font-size: 0.78rem; font-weight: 600;
    margin-bottom: 6px; color: var(--text-muted);
}
.form-control {
    width: 100%; padding: 11px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    font-size: 0.88rem; background: var(--surface-input); color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); background: var(--surface); }
textarea.form-control { resize: vertical; }
.form-control--file { padding: 10px 12px; border-style: dashed; border-color: var(--text-faintest); font-size: 0.8rem; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

.admin-section-title {
    font-size: 0.82rem; font-weight: 700; margin: 2px 0 12px;
    color: var(--primary); letter-spacing: 0.02em;
}
.admin-section-divider { height: 1px; background: var(--border-light); margin: 18px 0 16px; }
.toggle-list--admin { margin-bottom: 6px; }

/* Export modal */
.export-list { display: flex; flex-direction: column; gap: 8px; }
.export-option {
    display: flex; align-items: center; gap: 12px;
    padding: 14px; border-radius: 11px;
    border: 1px solid var(--border); background: var(--surface);
    cursor: pointer; text-align: left; transition: background 0.15s;
}
.export-option:hover { background: var(--surface-sunken); }
.export-badge {
    width: 36px; height: 36px; flex: 0 0 36px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 800;
}
.export-badge--xls { background: var(--primary-soft); color: var(--primary); }
.export-badge--csv { background: var(--accent-soft); color: var(--accent-text); }
.export-option__text { display: flex; flex-direction: column; gap: 1px; }
.export-option__text strong { font-size: 0.88rem; }
.export-option__text span { font-size: 0.73rem; color: var(--text-muted); }

/* Dropdown (inline edit search) */
.dropdown-field { position: relative; }
.dropdown-list {
    position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 20;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow-modal); max-height: 220px; overflow-y: auto;
}
.dropdown-item { padding: 9px 12px; cursor: pointer; font-size: 0.85rem; }
.dropdown-item:hover { background: var(--surface-sunken); }
.dropdown-item .text-muted { color: var(--text-muted); }

/* Banner admin list */
.banner-admin-list {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px; margin-bottom: 18px;
}
.banner-admin-item {
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-input); padding: 11px 12px;
    font-size: 0.75rem; line-height: 1.5;
}
.banner-admin-item.is-active { border-color: var(--dot-rice); background: #F2F6F3; }
.banner-admin-item strong { display: block; color: var(--text); margin-bottom: 1px; font-size: 0.8rem; }
.banner-admin-item .text-muted { color: var(--text-muted); }
.banner-admin-preview {
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-input);
    min-height: 110px; display: flex; align-items: center; justify-content: center;
    color: var(--text-faint); font-size: 0.8rem; padding: 12px; overflow: hidden;
}
.banner-admin-preview .ad-slot { width: 100%; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; flex: 1 1 auto; position: static; }
    .sidebar-ad-stack { flex-direction: row; flex-wrap: wrap; }
    .sidebar-ad-stack .ad-slot { flex: 1 1 240px; }
}

@media (max-width: 640px) {
    .appbar { padding: 8px 16px; }
    .appbar__actions { width: 100%; justify-content: flex-start; }
    .brand-sub { display: none; }
    .layout { padding: 16px; gap: 16px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .metrics { justify-content: space-between; gap: 8px; padding: 10px 14px; }
    .metric__label { font-size: 0.62rem; }
    .monthly-calendar { grid-template-columns: 1fr !important; }
    .cal-dow { display: none; }
    .cal-cell {
        min-height: auto;
        border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px;
    }
    .cal-cell--blank { display: none; }
    .ad-strip--mobile { display: block; }
    .ad-strip:not(.ad-strip--mobile) .ad-slot--leaderboard .ad-slot__placeholder { aspect-ratio: 320 / 100; }
}
