:root {
    --bg: #f5f5f3;
    --surface: #ffffff;
    --text: #1b1b1a;
    --muted: #6d6d68;
    --border: #e3e3de;
    --accent: #1b1b1a;
    --danger: #b42318;
    --green: #157f3d;
    --amber: #9a5b00;
    --radius: 8px;
    color-scheme: light;
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

h1,
h2,
h3 {
    margin: 0;
    font-weight: 650;
}

h2 {
    font-size: 18px;
}

h3 {
    font-size: 15px;
    margin: 28px 0 10px;
}

a {
    color: inherit;
}

.hidden {
    display: none !important;
}

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

.small {
    font-size: 12px;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

.error {
    color: var(--danger);
}

.right {
    text-align: right;
}

.spacer {
    flex: 1;
}

/* 버튼과 입력 */

button,
.button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

button:disabled {
    opacity: 0.5;
    cursor: default;
}

button.secondary,
.button.secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

button.ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}

button.danger {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--border);
}

button.small {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
}

input,
select {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font: inherit;
    color: inherit;
}

input[type="file"] {
    height: auto;
    padding: 6px;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

input:focus,
select:focus,
button:focus-visible {
    outline: 2px solid #8fb3ff;
    outline-offset: 1px;
}

.toolbar select {
    width: auto;
}

/* 로그인 */

.login {
    display: grid;
    gap: 12px;
    width: min(320px, calc(100% - 32px));
    margin: 18vh auto 0;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.login h1 {
    font-size: 18px;
    margin-bottom: 4px;
}

.login button {
    justify-content: center;
}

.notice {
    margin: 0;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: #fff6e5;
    color: var(--amber);
    font-size: 13px;
}

/* 레이아웃 */

.shell {
    display: grid;
    grid-template-columns: 200px 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100vh;
    padding: 20px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.brand {
    padding: 0 10px;
}

.sidebar nav {
    display: grid;
    gap: 16px;
    flex: 1;
    align-content: start;
}

.nav-group {
    display: grid;
    gap: 2px;
}

.sidebar nav a {
    padding: 7px 10px;
    border-radius: var(--radius);
    color: var(--muted);
    text-decoration: none;
}

.sidebar nav a:hover {
    color: var(--text);
}

.sidebar nav a.active {
    background: var(--bg);
    color: var(--text);
    font-weight: 600;
}

.sidebar > button {
    justify-content: flex-start;
    padding: 0 10px;
}

.content {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* 좁은 화면에서는 메뉴를 위로 올린다. */
@media (max-width: 720px) {
    .shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        height: auto;
        padding: 10px 12px;
        gap: 10px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .sidebar .brand {
        padding: 0 10px;
        white-space: nowrap;
    }

    .sidebar > button {
        margin-left: auto;
    }

    .sidebar nav,
    .nav-group {
        display: flex;
        gap: 2px;
    }

    .sidebar nav {
        order: 1;
        flex-basis: 100%;
        overflow-x: auto;
    }

    .sidebar nav a,
    .nav-group {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .content {
        padding: 20px 16px;
    }
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.empty {
    padding: 40px;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* 목록 */

table.list {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

table.list th {
    white-space: nowrap;
    padding: 8px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 550;
    color: var(--muted);
    background: #fafaf8;
    border-bottom: 1px solid var(--border);
}

table.list td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.list tr:last-child td {
    border-bottom: 0;
}

tr.clickable {
    cursor: pointer;
}

tr.clickable:hover td {
    background: #fafaf8;
}

.thumb-cell {
    width: 72px;
}

.thumb {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 6px;
    background: repeating-conic-gradient(#eeeeea 0% 25%, #fff 0% 50%) 50% / 12px 12px;
}

.thumb-font {
    width: 140px;
    height: 32px;
    background: none;
    object-position: left center;
}

.thumb-filter {
    object-fit: cover;
}

.badge {
    display: inline-block;
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 550;
    background: #efefeb;
    color: var(--muted);
}

.badge-published {
    background: #e7f6ec;
    color: var(--green);
}

.badge-hidden {
    background: #f3f3f0;
    color: #9a9a94;
    text-decoration: line-through;
}

.badge-draft {
    background: #fff4dc;
    color: var(--amber);
}

.badge-paid {
    background: #efe9ff;
    color: #5b3cc4;
}

/* 게시: 앱 게시를 중심에 두고 기록과 테스트 도구는 접어 둔다. */

.publish-page {
    max-width: 780px;
    margin: 12px auto 40px;
    animation: publish-enter 180ms ease-out;
}

.publish-heading {
    margin-bottom: 32px;
}

.publish-heading h1 {
    font-size: 28px;
    letter-spacing: -0.8px;
}

.publish-heading p {
    margin: 8px 0 0;
}

.publish-workspace {
    border-top: 2px solid var(--text);
}

.publish-state {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
}

.publish-state p {
    flex-basis: 100%;
    margin: 0;
}

.publish-preview {
    padding: 24px 0;
}

.publish-section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.publish-section-head h2 {
    font-size: 16px;
}

.publish-type-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 6px;
}

.publish-items {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
    margin: 16px 0 12px;
    padding: 0;
    list-style: none;
}

.publish-item {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.publish-item[hidden] {
    display: none;
}

.publish-item .thumb {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    object-position: center;
}

.publish-item .thumb-font {
    width: 80px;
}

.publish-item-name {
    display: grid;
    gap: 2px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.publish-item-name strong {
    font-weight: 550;
}

.publish-empty {
    padding: 28px 0 8px;
}

.publish-empty p {
    margin: 6px 0 16px;
}

.publish-drafts {
    margin-top: 24px;
    padding-left: 14px;
    border-left: 2px solid var(--border);
}

.publish-drafts strong {
    font-size: 13px;
    font-weight: 550;
}

.publish-drafts p {
    margin: 4px 0 10px;
}

.publish-draft-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 12px;
}

.publish-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px 0 28px;
}

.publish-footer p {
    max-width: 360px;
    margin: 0;
}

.publish-button {
    justify-content: center;
    min-width: 144px;
    height: 44px;
    transition: background 150ms, transform 150ms;
}

.publish-button:hover:not(:disabled) {
    background: #383835;
}

.publish-button:active:not(:disabled) {
    transform: translateY(1px);
}

.publish-details {
    padding: 18px 0;
    border-top: 1px solid var(--border);
}

.publish-details > summary {
    width: fit-content;
    cursor: pointer;
    font-weight: 550;
}

.publish-details > summary:focus-visible {
    outline: 2px solid #8fb3ff;
    outline-offset: 4px;
}

.publish-details > summary > span {
    margin-left: 10px;
    font-weight: 400;
}

.publish-history {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.publish-history li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.publish-history li:last-child {
    border-bottom: 0;
}

.publish-history strong {
    font-weight: 500;
}

.publish-history p {
    margin: 4px 0 0;
}

.publish-test-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 16px 0 24px;
}

.publish-technical {
    margin: 20px 0;
}

.publish-technical h3 {
    margin: 0 0 6px;
    font-size: 13px;
}

.publish-technical > a {
    overflow-wrap: anywhere;
}

.publish-technical .actions {
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 8px;
    font-size: 12px;
}

@keyframes publish-enter {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .publish-page { animation: none; }
    .publish-button { transition: none; }
}

@media (max-width: 720px) {
    .publish-page {
        margin-top: 4px;
    }

    .publish-heading {
        margin-bottom: 24px;
    }

    .publish-heading h1 {
        font-size: 24px;
    }

    .publish-items {
        grid-template-columns: 1fr;
    }

    .publish-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .publish-history li {
        flex-wrap: wrap;
    }
}

.actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 16px;
    margin: 12px 0 0;
}

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

dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* 편집 시트 */

dialog.sheet {
    width: min(640px, calc(100% - 32px));
    max-height: calc(100% - 48px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: inherit;
}

dialog.sheet::backdrop {
    background: rgb(20 20 18 / 35%);
}

.sheet-head,
.sheet-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
}

.sheet-head {
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sheet-foot {
    border-top: 1px solid var(--border);
}

.sheet-body {
    display: grid;
    gap: 14px;
    padding: 18px 20px;
}

.row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    align-items: end;
}

.field {
    display: grid;
    gap: 4px;
}

.label {
    font-size: 12px;
    font-weight: 550;
    color: var(--muted);
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
}

fieldset {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 12px 14px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

fieldset p {
    margin: 0;
}

legend {
    padding: 0 4px;
    font-size: 12px;
    font-weight: 600;
}

.segmented {
    display: inline-flex;
    width: fit-content;
    padding: 2px;
    background: var(--bg);
    border-radius: var(--radius);
}

.segmented button {
    height: 30px;
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}

.segmented button.active {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.field p {
    margin: 2px 0 0;
}

.upload {
    display: grid;
    gap: 10px;
    padding: 14px;
    background: #fafaf8;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.upload-preview {
    display: grid;
    gap: 6px;
}

.preview-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.preview {
    max-width: 160px;
    max-height: 160px;
    border-radius: 6px;
    background: repeating-conic-gradient(#eeeeea 0% 25%, #fff 0% 50%) 50% / 12px 12px;
}

.preview-font {
    max-width: 100%;
    max-height: 64px;
    background: #fff;
    border: 1px solid var(--border);
}

.summary {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.summary dl {
    margin: 0;
    flex: 1;
}

.versions summary {
    cursor: pointer;
    font-weight: 550;
}

.versions[open] {
    display: grid;
    gap: 10px;
}

.versions ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.versions > button {
    width: fit-content;
}

/* 알림. 팝오버로 띄워 열린 시트 위에도 보이게 한다. */

#toast {
    inset: auto auto 24px 50%;
    max-width: min(560px, calc(100% - 32px));
    margin: 0;
    padding: 10px 16px;
    border: 0;
    border-radius: var(--radius);
    background: var(--text);
    color: #fff;
    transform: translateX(-50%);
}

#toast.error {
    background: var(--danger);
}
