:root {
    --ink: #18231e;
    --muted: #627068;
    --line: #dce2de;
    --surface: #ffffff;
    --background: #f3f6f4;
    --primary: #176b4f;
    --primary-dark: #0f513b;
    --accent: #f2c94c;
    --danger: #b42318;
    --warning: #9a5b00;
    --info: #245b78;
    --radius: 8px;
    --shadow: 0 8px 24px rgba(21, 42, 31, .07);
    font-family: Pretendard, "Noto Sans KR", "Malgun Gothic", Arial, sans-serif;
    color: var(--ink);
    background: var(--background);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--background); color: var(--ink); font-size: 15px; line-height: 1.58; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .58; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: 32px; line-height: 1.25; }
h2 { margin-bottom: 6px; font-size: 22px; line-height: 1.35; }
h3 { margin-bottom: 5px; font-size: 17px; }
p { margin-bottom: 0; }
code { font-family: Consolas, monospace; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted, small { color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.lead-copy { max-width: 760px; color: var(--muted); font-size: 16px; }

.app-header { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); }
.app-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; background: var(--primary); color: #fff; font-size: 17px; font-weight: 900; }
.admin-header .brand-mark { background: #283148; }
.app-nav { display: flex; align-items: center; gap: 20px; }
.app-nav a { color: var(--muted); font-weight: 700; }
.app-nav form { margin: 0; }
.app-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { position: sticky; top: 64px; align-self: start; height: calc(100vh - 64px); padding: 26px 18px; border-right: 1px solid var(--line); background: #fff; }
.sidebar-user { display: grid; gap: 2px; padding: 0 10px 20px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.sidebar-user span { color: var(--muted); font-size: 12px; }
.sidebar nav { display: grid; gap: 5px; margin-top: 18px; }
.sidebar nav a { padding: 10px 12px; border-radius: 6px; color: var(--muted); font-weight: 700; }
.sidebar nav a:hover, .sidebar nav a.is-active { background: #e8f2ed; color: var(--primary-dark); }
.sidebar-license { position: absolute; right: 18px; bottom: 26px; left: 18px; display: grid; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8faf8; }
.sidebar-license span { color: var(--muted); font-size: 12px; }
.app-main { width: 100%; max-width: 1500px; min-width: 0; padding: 36px clamp(20px, 4vw, 58px) 80px; }
.admin-main { width: min(1500px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 80px; }

.page-heading, .project-heading, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.page-heading, .project-heading { margin-bottom: 32px; }
.page-heading p:not(.eyebrow), .project-heading p:not(.eyebrow), .section-heading p { color: var(--muted); }
.project-heading h1 { overflow-wrap: anywhere; }
.heading-actions, .button-row, .result-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.back-link { display: inline-block; margin-bottom: 10px; color: var(--muted); font-size: 13px; font-weight: 700; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 8px 16px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); font-weight: 800; line-height: 1.25; text-align: center; }
.button:hover { filter: brightness(.97); }
.button-primary { background: var(--primary); color: #fff; }
.button-secondary { border-color: #bdc8c1; background: #fff; }
.button-ai { border-color: #29354d; background: #29354d; color: #fff; }
.button-danger { border-color: #e6b5b0; background: #fff4f2; color: var(--danger); }
.button-download { background: #202c27; color: #fff; }
.button-quiet { min-height: 34px; padding: 6px 10px; color: var(--muted); }
.button-large { min-height: 48px; padding: 11px 22px; }
.button-small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.button-block { width: 100%; }
.button.is-disabled { pointer-events: none; opacity: .5; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--danger); font-size: 22px; line-height: 1; }

.alert, .license-block { margin-bottom: 22px; padding: 15px 18px; border: 1px solid; border-radius: var(--radius); }
.alert-success { border-color: #a7d8c0; background: #edf8f2; color: #14543e; }
.alert-error { border-color: #efb4ae; background: #fff1ef; color: #8f1e15; }
.alert-info { border-color: #b8d4e2; background: #eef7fb; color: var(--info); }
.license-block { border-color: #e1b460; background: #fff9e9; color: #704400; }
.license-block p { margin-top: 3px; }
.status { display: inline-flex; width: max-content; min-height: 28px; align-items: center; padding: 4px 10px; border-radius: 999px; background: #edf0ee; color: #536058; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-active, .status-ready, .status-content_ready { background: #e3f4eb; color: #126044; }
.status-danger, .status-failed, .status-expired, .status-revoked { background: #fde9e7; color: #9d2118; }
.status-warning, .status-building, .status-suspended { background: #fff2d4; color: #805000; }
.status-draft { background: #edf0ee; color: #59655e; }

.plain-section { padding: 34px 0; border-top: 1px solid var(--line); }
.plain-section:first-of-type { border-top: 0; }
.section-heading { margin-bottom: 20px; }
.section-heading p { max-width: 760px; }
.template-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.template-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.template-card > img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #e8ece9; }
.template-card-body { padding: 17px; }
.template-card-body p { min-height: 46px; margin-bottom: 15px; color: var(--muted); font-size: 13px; }
.template-card form { display: grid; gap: 8px; }
.template-code { display: inline-block; color: var(--primary); font: 700 11px/1.3 Consolas, monospace; text-transform: uppercase; }
.project-list { display: grid; border-top: 1px solid var(--line); }
.project-row { display: grid; grid-template-columns: 100px minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 17px 10px; border-bottom: 1px solid var(--line); }
.project-row:hover { background: rgba(255,255,255,.65); }
.project-template { color: var(--primary); font: 700 12px Consolas, monospace; }
.project-summary { display: grid; min-width: 0; }
.project-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-summary small { font-size: 12px; }
.empty-state { padding: 34px; border: 1px dashed #bcc7c0; border-radius: var(--radius); text-align: center; }
.empty-state p { margin-top: 4px; color: var(--muted); }
.empty-state.compact { padding: 20px; text-align: left; }

label { display: grid; gap: 7px; color: #354139; font-size: 13px; font-weight: 800; }
label em { display: inline; color: var(--danger); font-size: 11px; font-style: normal; }
label small, .form-note { font-size: 12px; font-weight: 500; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid #cbd3ce; border-radius: 6px; background: #fff; color: var(--ink); outline: 0; }
input, select { min-height: 43px; padding: 8px 11px; }
textarea { padding: 10px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,107,79,.12); }
input[readonly] { background: #f0f3f1; color: var(--muted); }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack-form, .setup-form, .form-panel { display: grid; gap: 18px; }
.form-panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.info-panel { align-self: start; padding: 24px; border-left: 4px solid var(--accent); background: #fff; }
.check-list { display: grid; gap: 10px; margin: 16px 0 24px; padding: 0; list-style: none; }
.check-list li { position: relative; padding-left: 22px; }
.check-list li::before { position: absolute; left: 0; content: "✓"; color: var(--primary); font-weight: 900; }
.settings-layout, .admin-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr); gap: 22px; }

.step-nav { position: sticky; top: 78px; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 26px; padding: 7px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.step-nav a { display: flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 7px; border-radius: 5px; color: var(--muted); font-size: 13px; font-weight: 800; white-space: nowrap; }
.step-nav a:hover { background: #edf4f0; color: var(--primary); }
.step-nav span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #e6ebe8; font-size: 11px; }
.project-form { display: grid; gap: 1px; }
.editor-section { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 18px; padding: 34px 0; border-top: 1px solid var(--line); scroll-margin-top: 150px; }
.editor-section:first-child { border-top: 0; }
.standalone-section { border-top: 1px solid var(--line); }
.section-number { display: grid; place-items: center; width: 42px; height: 32px; border-radius: 6px; background: #dfeae4; color: var(--primary); font: 800 12px Consolas, monospace; }
.section-content { min-width: 0; }
.section-content > label, .section-content > .form-grid { margin-bottom: 16px; }
.advanced-fields { padding-top: 3px; }
.sticky-save { position: sticky; bottom: 14px; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 20px 0 46px 72px; padding: 13px 16px; border: 1px solid #b9c8bf; border-radius: var(--radius); background: rgba(255,255,255,.97); box-shadow: 0 12px 36px rgba(18, 43, 29, .14); }
.sticky-save span { color: var(--muted); font-size: 13px; }
.menu-editor { display: grid; gap: 10px; }
.menu-row { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(120px, .4fr) minmax(220px, 1.5fr) 34px; align-items: end; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.copy-preview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.copy-preview > div { padding: 18px; border-left: 3px solid var(--primary); background: #fff; }
.copy-preview span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 800; }
.copy-preview strong { display: block; font-size: 19px; line-height: 1.4; }
.copy-preview p { margin-top: 7px; color: var(--muted); font-size: 13px; }
.upload-bar { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(220px, 1.3fr) auto; align-items: end; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.batch-image-form { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 16px; padding: 16px; border: 1px solid #d8dfec; border-left: 4px solid #29354d; border-radius: var(--radius); background: #f7f9fc; }
.batch-image-form div { min-width: 0; }
.batch-image-form strong { display: block; margin-bottom: 4px; font-size: 14px; }
.batch-image-form p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.batch-image-form .button { flex: 0 0 auto; }
.file-picker input { padding: 6px; }
.uploaded-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 22px 0 34px; }
.uploaded-item { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.uploaded-item > img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #edf0ee; }
.uploaded-item > div { display: grid; padding: 10px; }
.uploaded-item strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.uploaded-item small { font-size: 10px; }
.uploaded-item select { min-height: 36px; border-width: 1px 0 0; border-radius: 0; font-size: 12px; }
.uploaded-item > form:last-child { position: absolute; top: 7px; right: 7px; }
.uploaded-item .icon-button { border-color: rgba(255,255,255,.8); background: rgba(255,255,255,.9); }
.slot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 24px; }
.slot-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.slot-preview { background: #e8ece9; }
.slot-preview img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.slot-body { display: grid; gap: 15px; padding: 16px; }
.slot-body small { display: block; }
.slot-body form { display: grid; gap: 10px; }
.result-section { padding-bottom: 0; }
.result-actions { margin-bottom: 20px; }
.delivery-note { padding: 16px 18px; border-left: 4px solid var(--accent); background: #fff; }
.delivery-note p { margin-top: 3px; color: var(--muted); }

.auth-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: #edf2ef; }
.auth-shell { width: min(100%, 520px); }
.auth-panel { padding: 34px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.auth-panel-wide { width: min(680px, calc(100vw - 32px)); margin-left: 50%; transform: translateX(-50%); }
.auth-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 12px; }
.auth-heading h1 { margin: 0; font-size: 25px; }
.auth-panel > .muted { margin-bottom: 24px; }
.auth-links { display: flex; justify-content: space-between; gap: 15px; margin-top: 22px; color: var(--muted); font-size: 12px; font-weight: 700; }
.setup-panel { width: min(1000px, calc(100vw - 34px)); margin-left: 50%; padding: 34px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.requirement-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.requirement { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; }
.requirement span { min-width: 38px; color: var(--muted); font-size: 11px; font-weight: 900; }
.requirement.is-ok span { color: var(--primary); }
.requirement.is-error { border-color: #e8aaa4; background: #fff3f1; }
.setup-form fieldset { display: grid; gap: 16px; margin: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); }
.setup-form legend { padding: 0 7px; font-weight: 900; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat-item { display: grid; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.stat-item span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-item strong { font-size: 27px; }
.issued-code { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; padding: 20px; border: 2px solid var(--primary); border-radius: var(--radius); background: #eff9f4; }
.issued-code > div { display: grid; }
.issued-code strong { font: 800 24px/1.4 Consolas, monospace; overflow-wrap: anywhere; }
.issued-code small { font-size: 11px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; min-width: 850px; border-collapse: collapse; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f0f4f1; color: var(--muted); font-size: 12px; }
td > strong, td > span, td > small { display: block; }
td small { font-size: 11px; }
.inline-editor { margin-top: 8px; }
.inline-editor summary { color: var(--primary); font-size: 12px; font-weight: 800; cursor: pointer; }
.inline-editor form { display: grid; gap: 7px; min-width: 300px; margin-top: 9px; }
.inline-editor input, .inline-editor select { min-height: 34px; font-size: 12px; }
.audit-list { display: grid; border-top: 1px solid var(--line); }
.audit-list > div { display: grid; grid-template-columns: minmax(180px, 1fr) 180px 220px; gap: 14px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.audit-list code { color: var(--primary); font-size: 12px; font-weight: 700; }
.audit-list span, .audit-list small { color: var(--muted); font-size: 11px; }

.loading-screen { position: fixed; inset: 0; z-index: 999; display: grid; place-items: center; padding: 20px; background: rgba(20,30,25,.72); }
.loading-box { width: min(420px, 100%); padding: 26px; border-radius: var(--radius); background: #fff; text-align: center; box-shadow: var(--shadow); }
.loading-spinner { width: 34px; height: 34px; margin: 0 auto 14px; border: 4px solid #d9e2dd; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
    .template-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .uploaded-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .form-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    h1 { font-size: 27px; }
    .app-header { padding: 0 17px; }
    .app-nav > a { display: none; }
    .app-shell { display: block; }
    .sidebar { position: static; display: flex; height: auto; align-items: center; justify-content: space-between; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
    .sidebar-user { display: none; }
    .sidebar nav { display: flex; margin: 0; }
    .sidebar-license { position: static; padding: 7px 10px; }
    .sidebar-license span { display: none; }
    .app-main { padding: 25px 18px 70px; }
    .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .settings-layout, .admin-grid { grid-template-columns: 1fr; }
    .step-nav { top: 68px; overflow-x: auto; grid-template-columns: repeat(5, minmax(110px, 1fr)); justify-content: start; scrollbar-width: none; }
    .step-nav::-webkit-scrollbar { display: none; }
    .menu-row { grid-template-columns: repeat(2, minmax(0, 1fr)) 34px; }
    .menu-row label:nth-child(3) { grid-column: 1 / 3; }
    .menu-row .icon-button { grid-column: 3; grid-row: 1; }
    .uploaded-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .audit-list > div { grid-template-columns: 1fr 150px; }
    .audit-list small { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
    body { font-size: 14px; }
    h1 { font-size: 24px; }
    h2 { font-size: 19px; }
    .app-brand > span:last-child { max-width: 150px; font-size: 13px; }
    .app-nav { gap: 8px; }
    .app-nav > span { display: none; }
    .page-heading, .project-heading, .section-heading { align-items: stretch; flex-direction: column; gap: 12px; }
    .heading-actions { justify-content: flex-start; }
    .template-grid, .slot-grid, .copy-preview { grid-template-columns: 1fr; }
    .template-card-body p { min-height: 0; }
    .project-row { grid-template-columns: 70px minmax(0, 1fr); }
    .project-row .status { grid-column: 2; }
    .form-grid.two, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
    .editor-section { grid-template-columns: 1fr; gap: 10px; padding: 28px 0; }
    .section-number { width: 38px; height: 28px; }
    .sticky-save { position: static; align-items: stretch; flex-direction: column; margin: 14px 0 35px; }
    .menu-row { grid-template-columns: minmax(0, 1fr) 34px; }
    .menu-row label, .menu-row label:nth-child(3) { grid-column: 1; }
    .menu-row .icon-button { grid-column: 2; grid-row: 1; }
    .upload-bar { grid-template-columns: 1fr; }
    .batch-image-form { align-items: stretch; flex-direction: column; }
    .batch-image-form .button { width: 100%; }
    .uploaded-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .result-actions { align-items: stretch; flex-direction: column; }
    .result-actions > *, .result-actions form .button { width: 100%; }
    .auth-body { padding: 16px; }
    .auth-panel, .setup-panel { padding: 23px 18px; }
    .auth-panel-wide { width: calc(100vw - 24px); }
    .auth-links { align-items: flex-start; flex-direction: column; }
    .requirement-grid, .stat-grid { grid-template-columns: 1fr 1fr; }
    .admin-main { width: calc(100% - 28px); padding-top: 24px; }
    .issued-code { align-items: stretch; flex-direction: column; }
    .issued-code strong { font-size: 19px; }
    .audit-list > div { grid-template-columns: 1fr; gap: 2px; }
    .audit-list small { grid-column: auto; }
}

@media (max-width: 390px) {
    .sidebar-license { display: none; }
    .uploaded-grid, .requirement-grid, .stat-grid { grid-template-columns: 1fr; }
    .app-brand > span:last-child { max-width: 125px; }
}
