:root {
    color-scheme: light;
    --bg: #fff7ea;
    --surface: #ffffff;
    --surface-soft: #fff0db;
    --surface-cool: #e8fbf4;
    --text: #243049;
    --muted: #68728a;
    --line: #eadfce;
    --primary: #f05a3b;
    --primary-dark: #b83d2b;
    --herb: #15946f;
    --herb-dark: #0e6d52;
    --lemon: #ffd45a;
    --cream: #fffaf2;
    --berry: #7c5cff;
    --bad: #c5322f;
    --good: #16885f;
    --shadow: 0 22px 60px rgba(91, 64, 38, 0.16);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        linear-gradient(120deg, rgba(255, 218, 112, 0.45) 0%, rgba(255, 248, 236, 0.6) 30%, transparent 55%),
        linear-gradient(300deg, rgba(38, 197, 165, 0.24) 0%, rgba(124, 92, 255, 0.18) 42%, transparent 68%),
        var(--bg);
    font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

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

button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    padding: 0 18px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #ff8a3d);
    cursor: pointer;
    font-weight: 800;
    transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

button:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark), #e66f20);
    box-shadow: 0 8px 20px rgba(240, 90, 59, 0.28);
    transform: translateY(-1px);
}

button[data-icon] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.secondary {
    color: var(--herb-dark);
    background: #eafff5;
}

.secondary:hover:not(:disabled) {
    color: #fff;
    background: linear-gradient(135deg, var(--herb), #24bca0);
}

.top-nav {
    padding: 20px clamp(18px, 4vw, 48px) 0;
}

.top-nav nav {
    max-width: 1280px;
    margin: 0 auto;
}

.top-nav a {
    color: var(--herb-dark);
    font-weight: 800;
    text-decoration: none;
}

.top-nav a::before {
    content: "↩";
    display: inline-grid;
    width: 28px;
    height: 28px;
    margin-right: 8px;
    place-items: center;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(135deg, var(--herb), var(--berry));
}

.app-shell {
    width: min(1360px, calc(100% - 40px));
    min-height: calc(100vh - 70px);
    margin: 0 auto;
    display: grid;
    gap: 18px;
    align-items: start;
    padding: 32px 0 56px;
}

.app-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 216, 151, 0.9);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(255, 245, 225, 0.94)),
        var(--surface);
    box-shadow: var(--shadow);
    padding: clamp(24px, 3vw, 36px);
}

.app-header::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: linear-gradient(90deg, #ff8a3d, var(--lemon), var(--herb), #38a1ff, var(--berry));
}

.app-header h1 {
    margin-bottom: 0;
}

.app-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.view-button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--herb-dark);
    background: linear-gradient(135deg, #fff8e8, #eafff5);
}

.view-button.is-active {
    color: #fff;
    background: linear-gradient(135deg, var(--herb), var(--primary));
}

button[data-icon]::before,
.view-button[data-icon]::before {
    content: attr(data-icon);
    display: inline-grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 999px;
    color: currentColor;
    background: rgba(255, 255, 255, 0.34);
    font-size: 0.85rem;
    line-height: 1;
}

.app-view {
    display: none;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(234, 223, 206, 0.95);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
    padding: clamp(26px, 3vw, 40px);
}

.app-view::before,
.generator-panel::before,
.recipe-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--lemon), var(--herb), var(--berry));
}

.app-view.is-active {
    display: block;
}

.generator-layout {
    display: grid;
    grid-template-columns: minmax(520px, 0.95fr) minmax(0, 1.05fr);
    gap: 22px;
}

.generator-panel,
.recipe-panel {
    min-width: 0;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(234, 223, 206, 0.95);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
    padding: clamp(26px, 3vw, 40px);
}

.recipe-panel {
    min-height: 620px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    color: var(--herb);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.eyebrow[data-icon]::before {
    content: attr(data-icon);
    display: inline-grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--berry));
    font-size: 0.8rem;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 28px;
    font-size: clamp(2.1rem, 2.4vw, 2.45rem);
    line-height: 1.12;
    word-break: keep-all;
    white-space: nowrap;
}

h2 {
    margin-bottom: 12px;
    font-size: clamp(1.45rem, 2.2vw, 2rem);
    line-height: 1.22;
    word-break: keep-all;
}

h3 {
    margin-bottom: 10px;
    color: var(--herb-dark);
    font-size: 1.05rem;
}

.account-panel {
    margin-bottom: 28px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf8;
}

.view-heading {
    margin-bottom: 22px;
}

.view-heading h2 {
    margin-bottom: 0;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.25rem;
}

.small-copy {
    margin: 10px 0 14px;
    color: var(--muted);
    line-height: 1.45;
}

.recipe-form,
.compact-form {
    display: grid;
    gap: 12px;
}

.recipe-form label {
    color: var(--muted);
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(234, 223, 206, 0.95);
    border-radius: 8px;
    padding: 14px 16px;
    color: var(--text);
    background: #fffdf8;
    line-height: 1.5;
}

textarea {
    min-height: 240px;
    resize: vertical;
}

input,
select {
    min-height: 46px;
}

textarea:focus {
    outline: 3px solid rgba(255, 138, 61, 0.22);
    border-color: var(--primary);
}

input:focus,
select:focus {
    outline: 3px solid rgba(255, 138, 61, 0.22);
    border-color: var(--primary);
}

.form-message {
    min-height: 24px;
    margin: 0;
    color: var(--muted);
    font-weight: 800;
}

.form-message.is-error {
    color: var(--bad);
}

.form-message.is-success {
    color: var(--good);
}

.form-message.is-info {
    color: var(--primary-dark);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-actions button {
    min-width: 108px;
}

.split-actions {
    justify-content: stretch;
}

.split-actions button {
    flex: 1;
}

.empty-state {
    display: grid;
    min-height: 540px;
    align-content: center;
    justify-items: start;
    padding: clamp(20px, 4vw, 42px);
    border: 1px dashed rgba(240, 90, 59, 0.3);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255, 212, 90, 0.22), transparent 42%),
        linear-gradient(315deg, rgba(21, 148, 111, 0.12), transparent 34%),
        #fffdf8;
}

.empty-state h2 {
    max-width: 12em;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: clamp(1.65rem, 2.6vw, 2.25rem);
}

.empty-state::after {
    content: "입력한 재료를 기반으로 요리명, 조리 시간, 난이도, 단계별 조리법을 정리합니다.";
    display: block;
    max-width: 34em;
    color: var(--muted);
    line-height: 1.55;
}

.recipe-description {
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.55;
}

.recipe-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 22px 0;
}

.recipe-meta span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    color: var(--herb-dark);
    background: linear-gradient(135deg, #fff8df, #eafff5);
    font-weight: 800;
}

.recipe-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(234, 223, 206, 0.85);
}

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

.stat-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: linear-gradient(135deg, #fffdf8, #eefdf6);
}

.stat-card:nth-child(2) {
    background: linear-gradient(135deg, #fff7de, #fff0f0);
}

.stat-card:nth-child(3) {
    background: linear-gradient(135deg, #eefdf6, #f1efff);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-weight: 800;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    color: var(--primary-dark);
    font-size: 1.8rem;
}

.mini-section {
    margin-top: 24px;
}

.filter-row,
.inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin: 14px 0;
}

.filter-row {
    grid-template-columns: 180px minmax(0, 1fr) auto;
}

.item-list {
    display: grid;
    gap: 10px;
}

.data-item,
.recipe-item,
.saved-detail {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #fffdf8, #ffffff);
    box-shadow: 0 8px 22px rgba(91, 64, 38, 0.06);
}

.recipe-item:nth-child(3n + 1),
.data-item:nth-child(3n + 1) {
    border-color: rgba(240, 90, 59, 0.26);
}

.recipe-item:nth-child(3n + 2),
.data-item:nth-child(3n + 2) {
    border-color: rgba(21, 148, 111, 0.26);
}

.recipe-item:nth-child(3n),
.data-item:nth-child(3n) {
    border-color: rgba(124, 92, 255, 0.24);
}

.data-item,
.recipe-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.data-item strong,
.data-item span,
.recipe-row strong,
.recipe-row span {
    display: block;
}

.data-item span,
.recipe-row span {
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.45;
}

.item-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.small-button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.9rem;
}

.saved-detail {
    margin-top: 14px;
}

.inline-panel {
    margin-top: 14px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
    background:
        linear-gradient(135deg, rgba(255, 212, 90, 0.12), transparent 40%),
        rgba(255, 250, 242, 0.8);
}

.inline-panel h3 {
    margin-bottom: 8px;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.detail-header h3 {
    margin: 0;
}

.share-panel {
    display: grid;
    gap: 12px;
}

.share-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.auth-card {
    max-width: 520px;
    margin: 0 auto;
}

.account-panel {
    display: grid;
    gap: 12px;
    border: 1px solid rgba(21, 148, 111, 0.24);
    border-radius: 8px;
    background: linear-gradient(135deg, #eafff5, #fff8df);
    padding: 18px;
}

.account-panel strong {
    font-size: 1.15rem;
}

.account-panel span {
    color: var(--muted);
    line-height: 1.45;
}

.ingredient-grid,
.settings-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
}

ul,
ol {
    margin: 0;
    padding-left: 22px;
}

li {
    margin: 8px 0;
    line-height: 1.55;
}

#recipe-tips {
    margin-bottom: 0;
    line-height: 1.6;
}

@media (max-width: 820px) {
    .app-shell {
        padding-top: 22px;
    }

    .app-header {
        align-items: stretch;
        flex-direction: column;
    }

    .app-menu {
        justify-content: flex-start;
    }

    .generator-layout {
        grid-template-columns: 1fr;
    }

    .recipe-panel {
        min-height: auto;
    }

    h1 {
        white-space: normal;
    }

    .empty-state {
        min-height: 300px;
    }

    .form-actions {
        flex-direction: column;
    }

    .stats-grid,
    .ingredient-grid,
    .settings-form,
    .filter-row,
    .inline-form {
        grid-template-columns: 1fr;
    }

    .data-item {
        flex-direction: column;
    }

    .item-actions {
        justify-content: flex-start;
    }
}
