:root {
    color-scheme: light;
    --green: #168554;
    --green-dark: #0d6640;
    --green-soft: #e7f5ed;
    --red: #d71920;
    --ink: #17211c;
    --muted: #68736d;
    --line: #dfe6e2;
    --surface: #ffffff;
    --canvas: #f2f6f3;
    --danger: #b3261e;
    --shadow: 0 10px 30px rgb(20 43 31 / 9%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
    font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); }

body {
    min-height: 100vh;
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--green-dark); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    padding-top: env(safe-area-inset-top);
    background: rgb(255 255 255 / 94%);
    border-bottom: 1px solid rgb(23 33 28 / 8%);
    backdrop-filter: blur(18px) saturate(1.2);
}

.header-inner {
    width: min(100%, 820px);
    margin: 0 auto;
    padding: 13px 16px 12px;
}

.title-row, .search-row, .dialog-header, .user-row {
    display: flex;
    align-items: center;
}

.title-row { justify-content: space-between; gap: 14px; }

.korean-title {
    margin: 0;
    font-size: clamp(1.35rem, 5vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.1;
}

.korean-title span { color: var(--red); }
.korean-title strong { color: #101713; font-weight: 800; }

.user-line {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: .84rem;
    font-weight: 600;
}

.icon-button, .close-button {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #edf1ef;
    cursor: pointer;
}

.icon-button { font-size: 1.6rem; line-height: 1; letter-spacing: 2px; padding-bottom: 9px; }
.close-button { font-size: 1.7rem; color: var(--muted); }

.search-row { gap: 10px; margin-top: 12px; }

.search-field {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 13px;
    gap: 8px;
    border-radius: 13px;
    background: #edf1ef;
    color: var(--muted);
}

.search-field span[aria-hidden] { font-size: 1.45rem; transform: rotate(-20deg); }

.search-field input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font-size: 1rem;
}

.search-field:focus-within { box-shadow: 0 0 0 2px var(--green); }

.progress-pill {
    display: flex;
    align-items: baseline;
    justify-content: center;
    min-width: 76px;
    height: 44px;
    padding: 9px 11px;
    border: 1px solid #cfe5d8;
    border-radius: 13px;
    background: var(--green-soft);
    color: var(--green-dark);
    font-variant-numeric: tabular-nums;
}

.progress-pill strong { font-size: 1.05rem; }
.progress-pill span { color: #527161; font-size: .82rem; margin-left: 3px; }

.catalog-shell {
    width: min(100%, 820px);
    margin: 0 auto;
    padding: 14px 12px calc(26px + env(safe-area-inset-bottom));
}

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

.dish-card {
    display: grid;
    grid-template-columns: 126px minmax(0, 1fr) 24px;
    align-items: center;
    min-height: 112px;
    width: 100%;
    padding: 7px 10px 7px 7px;
    border: 1px solid rgb(23 33 28 / 8%);
    border-radius: 19px;
    background: var(--surface);
    box-shadow: 0 3px 14px rgb(20 43 31 / 5%);
    text-align: left;
    cursor: pointer;
    transition: transform .16s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.dish-card:active { transform: scale(.986); }
.dish-card:focus-visible { outline: 3px solid rgb(22 133 84 / 35%); outline-offset: 2px; }

.dish-card.is-rated {
    background: var(--green);
    border-color: var(--green);
    box-shadow: 0 7px 18px rgb(13 102 64 / 20%);
}

.dish-image-wrap {
    position: relative;
    display: grid;
    place-items: center;
    align-self: stretch;
    min-height: 96px;
    overflow: hidden;
    border-radius: 14px;
    background: #fff;
}

.dish-image-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 116px;
    object-fit: contain;
}

.score-badge {
    position: absolute;
    left: 7px;
    bottom: 7px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 2px solid white;
    border-radius: 50%;
    background: var(--green);
    color: white;
    box-shadow: 0 2px 7px rgb(0 0 0 / 24%);
    font-size: 1.22rem;
    font-weight: 850;
    font-variant-numeric: tabular-nums;
}

[hidden] { display: none !important; }

.dish-names {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: 8px 8px;
    text-align: center;
}

.dish-names strong {
    max-width: 100%;
    overflow: hidden;
    color: var(--ink);
    font-size: clamp(1.15rem, 4.3vw, 1.45rem);
    font-weight: 800;
    letter-spacing: -.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dish-names span {
    max-width: 100%;
    margin-top: 2px;
    overflow: hidden;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.is-rated .dish-names strong, .is-rated .edit-mark { color: white; }
.is-rated .dish-names span { color: rgb(255 255 255 / 82%); }
.edit-mark { color: #9aa39e; font-size: 1.75rem; font-weight: 300; text-align: right; }

.empty-search { padding: 48px 20px; color: var(--muted); text-align: center; }
.page-notice { margin-bottom: 12px; }

.app-dialog {
    width: min(calc(100% - 24px), 560px);
    max-height: min(86vh, 760px);
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 24px;
    background: transparent;
    color: var(--ink);
}

.app-dialog::backdrop { background: rgb(6 19 12 / 48%); backdrop-filter: blur(3px); }

.dialog-card {
    max-height: min(86vh, 760px);
    padding: 20px;
    overflow: auto;
    border-radius: 24px;
    background: white;
    box-shadow: 0 24px 70px rgb(0 0 0 / 30%);
}

.dialog-header { justify-content: space-between; gap: 14px; }
.dialog-header h2 { margin: 0; font-size: 1.35rem; }
.dialog-korean { margin: 0 0 1px; color: var(--green-dark); font-size: 1.35rem; font-weight: 800; }
.subtle, .field-hint { color: var(--muted); }
.subtle { margin: 8px 0 18px; }
.field-hint { margin: -6px 0 0; font-size: .82rem; }

.score-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.score-picker button {
    min-width: 0;
    height: 48px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #f1f4f2;
    font-size: 1.1rem;
    font-weight: 750;
    cursor: pointer;
}
.score-picker button.is-selected { border-color: var(--green); background: var(--green); color: white; }

.danger-button, .tiny-danger-button {
    border: 0;
    color: var(--danger);
    background: #fceceb;
    font-weight: 700;
    cursor: pointer;
}
.danger-button { width: 100%; min-height: 44px; margin-top: 16px; border-radius: 13px; }
.tiny-danger-button { min-height: 36px; padding: 7px 10px; border-radius: 10px; font-size: .84rem; }

.menu-card > * + * { margin-top: 10px; }
details { border: 1px solid var(--line); border-radius: 14px; background: #fbfcfb; }
summary { padding: 14px 15px; cursor: pointer; font-weight: 750; }
.details-content { padding: 0 14px 14px; border-top: 1px solid var(--line); }

.stack { display: grid; gap: 14px; }
.compact-stack { gap: 11px; }
.stack label { display: grid; gap: 6px; font-size: .9rem; font-weight: 700; }
.stack input[type="text"], .stack input[type="password"], .stack input:not([type]) {
    width: 100%;
    height: 46px;
    padding: 0 12px;
    border: 1px solid #cbd5cf;
    border-radius: 12px;
    background: white;
    color: var(--ink);
    font-size: 1rem;
}
.stack input:focus { border-color: var(--green); outline: 3px solid rgb(22 133 84 / 17%); }
.stack input[type="file"] { max-width: 100%; font-weight: 500; }

.primary-button, .secondary-button, .menu-action {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 10px 15px;
    border: 0;
    border-radius: 13px;
    font-weight: 750;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}
.primary-button { background: var(--green); color: white; }
.secondary-button { border: 1px solid #b9d9c7; background: var(--green-soft); color: var(--green-dark); }
.menu-action { width: 100%; background: #edf1ef; color: var(--ink); }

.user-list { display: grid; gap: 8px; }
.user-row { justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row > span { display: grid; }
.user-row small { color: var(--muted); }
.version-line { margin: 14px 0 0; color: var(--muted); font-size: .78rem; text-align: center; }

.toast {
    position: fixed;
    z-index: 60;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 11px 15px;
    border-radius: 999px;
    background: #16231c;
    color: white;
    box-shadow: var(--shadow);
    text-align: center;
}

.setup-screen {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
    background: radial-gradient(circle at 50% 0%, #e4f6ec 0, transparent 42%), var(--canvas);
}

.setup-card {
    width: min(100%, 440px);
    padding: clamp(22px, 6vw, 34px);
    border: 1px solid rgb(23 33 28 / 8%);
    border-radius: 26px;
    background: white;
    box-shadow: var(--shadow);
}
.setup-card h1 { margin: 3px 0 8px; font-size: 1.8rem; }
.setup-card > p { color: var(--muted); }
.brand-mark {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--green);
    color: white;
    box-shadow: 0 8px 20px rgb(22 133 84 / 23%);
}
.brand-mark span { font-size: 1.7rem; font-weight: 850; }
.eyebrow { margin: 18px 0 0 !important; color: var(--red) !important; font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.check-row { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 9px !important; font-weight: 600 !important; }
.check-row input { width: 20px; height: 20px; accent-color: var(--green); }

.notice { padding: 12px 14px; border-radius: 13px; background: #eef1ef; }
.notice.error { background: #fceceb; color: #7f1d18; }
.notice.success { background: var(--green-soft); color: var(--green-dark); }
.setup-card .notice { margin: 16px 0; }

@media (max-width: 430px) {
    .dish-card { grid-template-columns: 112px minmax(0, 1fr) 18px; min-height: 104px; padding-right: 8px; }
    .dish-image-wrap { min-height: 90px; }
    .dish-names { padding-inline: 5px; }
    .dish-names strong { font-size: 1.12rem; }
    .dish-names span { font-size: .82rem; }
    .score-picker { gap: 5px; }
    .score-picker button { height: 44px; border-radius: 11px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
