:root {
    --bg: #f4efe6;
    --surface: rgba(255, 250, 242, 0.88);
    --surface-strong: #fffdf9;
    --line: rgba(57, 61, 42, 0.12);
    --text: #23261c;
    --muted: #6f725f;
    --brand: #7a8f3d;
    --brand-strong: #586f1b;
    --accent: #d76c4a;
    --ok: #2d8a55;
    --warn: #af5a2c;
    --shadow: 0 20px 40px rgba(63, 44, 25, 0.08);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    font: 16px/1.5 "Segoe UI", "Noto Sans KR", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(214, 208, 160, 0.45), transparent 32%),
        radial-gradient(circle at top right, rgba(122, 143, 61, 0.18), transparent 26%),
        linear-gradient(180deg, #f7f1e8 0%, #efe6d8 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.page-shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 24px;
    align-items: center;
    padding: 18px 28px;
    backdrop-filter: blur(18px);
    background: rgba(244, 239, 230, 0.88);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-block;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.brand-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.main-nav a,
.ghost-link,
.action-button,
.ghost-button,
.primary-button {
    border-radius: 999px;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.main-nav a {
    padding: 10px 16px;
    color: var(--muted);
}

.main-nav a:hover,
.ghost-link:hover,
.action-button:hover,
.ghost-button:hover,
.primary-button:hover {
    transform: translateY(-1px);
}

.main-nav a:hover {
    color: var(--brand-strong);
    background: rgba(122, 143, 61, 0.12);
}

.user-block {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-weight: 700;
}

.user-role,
.badge,
.section-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.user-role,
.badge-soft {
    background: rgba(122, 143, 61, 0.12);
    color: var(--brand-strong);
}

.badge {
    background: rgba(35, 38, 28, 0.08);
    color: var(--muted);
}

.badge-alert {
    background: rgba(215, 108, 74, 0.16);
    color: var(--warn);
}

.section-tag {
    margin-bottom: 14px;
    background: rgba(122, 143, 61, 0.15);
    color: var(--brand-strong);
}

.ghost-link,
.ghost-button,
.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.5);
    color: var(--text);
}

.ghost-button {
    cursor: pointer;
}

.action-button {
    min-height: 48px;
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
    color: #fff;
    box-shadow: 0 10px 22px rgba(88, 111, 27, 0.28);
}

.main-content {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 48px;
}

.auth-shell {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 140px);
}

.auth-panel,
.card,
.hero-card,
.info-card,
.demo-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-panel {
    width: min(460px, 100%);
    padding: 28px;
}

.wide-panel {
    width: min(620px, 100%);
}

.muted {
    color: var(--muted);
}

.stack-form {
    display: grid;
    gap: 16px;
}

.stack-form label,
.form-grid label {
    display: grid;
    gap: 8px;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(57, 61, 42, 0.14);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
}

textarea {
    resize: vertical;
}

.hero-card {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
    padding: 28px;
    margin-bottom: 24px;
}

.hero-card h1,
.section-head h1,
.auth-panel h1 {
    margin: 0 0 8px;
    font-size: clamp(1.7rem, 3vw, 2.4rem);
    line-height: 1.15;
}

.hero-meta {
    display: grid;
    gap: 12px;
}

.metric-chip {
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.58);
    border-radius: 20px;
    border: 1px solid var(--line);
}

.metric-chip span {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
}

.metric-chip strong {
    display: block;
    margin-top: 6px;
    font-size: 1.35rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
    padding: 24px;
}

.wide-card {
    grid-column: 1 / -1;
}

.card-header,
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 16px;
}

.card-header {
    margin-bottom: 18px;
}

.card-header h2,
.card h3 {
    margin: 0;
}

.stat-list {
    display: grid;
    gap: 12px;
}

.stat-list > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--line);
}

.stat-list span {
    color: var(--muted);
}

.stat-list strong {
    font-size: 1.05rem;
}

.quick-actions {
    display: grid;
    gap: 12px;
}

.plain-list {
    margin: 0;
    padding-left: 18px;
}

.plain-list li + li {
    margin-top: 10px;
}

.compact-list li + li {
    margin-top: 6px;
}

.two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--muted);
    font-weight: 600;
}

.flash-stack,
.inline-errors {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid transparent;
}

.flash-success {
    background: rgba(45, 138, 85, 0.14);
    border-color: rgba(45, 138, 85, 0.24);
    color: var(--ok);
}

.flash-error {
    background: rgba(175, 90, 44, 0.14);
    border-color: rgba(175, 90, 44, 0.24);
    color: var(--warn);
}

.flash-info {
    background: rgba(122, 143, 61, 0.12);
    border-color: rgba(122, 143, 61, 0.18);
    color: var(--brand-strong);
}

.info-card,
.demo-card {
    padding: 18px;
    margin-top: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.helper-text {
    margin: -4px 0 0;
}

.meal-search-shell {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.52);
}

.meal-search-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.meal-search-head h3 {
    margin: 0;
}

.meal-search-results {
    display: grid;
    gap: 12px;
}

.meal-search-group {
    display: grid;
    gap: 10px;
}

.meal-search-group h4 {
    margin: 0;
    font-size: 0.95rem;
}

.meal-search-result {
    display: grid;
    gap: 8px;
    width: 100%;
    padding: 14px 16px;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.8);
    cursor: pointer;
}

.meal-search-result-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.meal-search-result-subtitle,
.meal-search-result-hint {
    color: var(--muted);
    font-size: 0.88rem;
}

.meal-search-result-meta {
    font-size: 0.9rem;
}

.meal-items-grid {
    display: grid;
    gap: 14px;
}

.meal-item-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.52);
}

.meal-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.meal-item-card h3 {
    margin: 0;
}

.meal-item-remove {
    padding: 8px 12px;
}

.table-subnote {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.82rem;
}

.goal-preview {
    display: grid;
    gap: 14px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.preview-grid span {
    display: block;
    color: var(--muted);
    font-size: 0.84rem;
}

.preview-grid strong {
    display: block;
    margin-top: 4px;
    font-size: 1.05rem;
}

.is-readonly {
    color: var(--brand-strong);
    background: rgba(122, 143, 61, 0.08);
    border-color: rgba(122, 143, 61, 0.22);
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.danger-button {
    color: var(--warn);
    border-color: rgba(175, 90, 44, 0.22);
}

.search-example-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.search-example-chip {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    min-width: 140px;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.76);
    cursor: pointer;
}

.search-example-chip strong {
    font-size: 0.95rem;
}

.search-example-chip span {
    color: var(--muted);
    font-size: 0.8rem;
}

.chart-shell {
    padding: 18px;
    border-radius: 20px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.86) 0%, rgba(250, 244, 236, 0.76) 100%);
    border: 1px solid var(--line);
}

.chart-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.chart-guide {
    stroke: rgba(57, 61, 42, 0.14);
    stroke-width: 1;
    stroke-dasharray: 4 6;
}

.chart-axis-label,
.chart-target-label {
    fill: var(--muted);
    font-size: 12px;
}

.chart-path {
    fill: none;
    stroke: var(--brand-strong);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-point {
    fill: var(--surface-strong);
    stroke: var(--brand-strong);
    stroke-width: 2;
}

.chart-target {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 8 6;
}

.chart-target-label {
    text-anchor: end;
}

.chart-empty {
    display: grid;
    gap: 8px;
    place-items: start;
    min-height: 220px;
    padding: 18px;
    border-radius: 20px;
    border: 1px dashed rgba(57, 61, 42, 0.18);
    background: rgba(255, 255, 255, 0.42);
}

@media (max-width: 960px) {
    .topbar,
    .hero-card,
    .card-grid,
    .two-column,
    .settings-grid,
    .form-grid,
    .preview-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        position: static;
    }

    .main-nav {
        justify-content: start;
    }

    .user-block {
        flex-wrap: wrap;
    }

    .inline-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .meal-item-head {
        flex-direction: column;
        align-items: stretch;
    }

    .meal-search-head,
    .meal-search-result-top {
        flex-direction: column;
        align-items: stretch;
    }
}
