:root {
    --bg: #0b0b11;
    --card: #14141d;
    --card-2: #1c1c28;
    --line: #2a2a3a;
    --text: #e2e2ea;
    --muted: #9095a8;
    --accent: #b8324a;
    --accent-2: #e0455f;
    --ok: #3fa980;
    --warn: #d2a23c;
    --err: #e0554b;
    --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Noto Sans KR', system-ui, sans-serif;
    background:
        radial-gradient(ellipse at 15% 0%, rgba(140, 30, 60, 0.18), transparent 55%),
        radial-gradient(ellipse at 85% 10%, rgba(40, 30, 120, 0.15), transparent 55%),
        var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
}

a { color: var(--accent-2); }

code {
    background: #000;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0.1em 0.4em;
    font-size: 0.9em;
    word-break: break-all;
}

/* ===== Header ===== */
.site-header {
    text-align: center;
    padding: 3.5rem 1.5rem 2rem;
}

.site-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.6rem, 5vw, 2.6rem);
    letter-spacing: 0.04em;
    background: linear-gradient(90deg, var(--accent-2), #d9a441);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.site-tagline { color: var(--muted); margin-top: 0.6rem; }

.wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.25rem 5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ===== Card ===== */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.75rem;
}

.step {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 1.15rem;
    margin-bottom: 1.1rem;
}

.step .num {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 50%;
    background: var(--accent);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.95rem;
}

.sub {
    font-size: 1rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--text);
}

.help {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ===== Skin picker ===== */
.skin-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.9rem;
}

.skin-btn {
    background: var(--card-2);
    border: 2px solid var(--line);
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    color: var(--text);
    font: inherit;
    transition: border-color 0.2s, transform 0.2s;
}

.skin-btn:hover { transform: translateY(-2px); border-color: #4a4a60; }
.skin-btn.active { border-color: var(--accent-2); }

.skin-thumb {
    display: block;
    height: 88px;
    background: var(--thumb, repeating-linear-gradient(45deg, #1e1e2b, #1e1e2b 10px, #232330 10px, #232330 20px)) center/cover;
}

.skin-name { display: block; padding: 0.6rem; font-size: 0.9rem; }

/* ===== Custom panel ===== */
.custom-panel {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--line);
}

.custom-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.custom-preview {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.custom-preview figure { width: 180px; }
.custom-preview img { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; }
.custom-preview figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }

.filename { font-size: 0.8rem; color: var(--muted); }

/* ===== Count picker ===== */
.count-picker { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.count-btn {
    flex: 1 1 140px;
    background: var(--card-2);
    border: 2px solid var(--line);
    border-radius: 12px;
    padding: 0.9rem;
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s;
}

.count-btn small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.count-btn:hover { border-color: #4a4a60; }
.count-btn.active { border-color: var(--accent-2); background: rgba(224, 69, 95, 0.1); }

/* ===== Fields ===== */
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field.wide { grid-column: 1 / -1; }
.field.inline { margin-top: 1rem; max-width: 420px; }

.label { font-size: 0.85rem; color: var(--muted); }
.label small { color: #6a6f80; }

input[type="text"],
input[type="number"],
textarea,
select {
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
    width: 100%;
    resize: vertical;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent-2);
}

input[type="color"] {
    width: 100%;
    height: 42px;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px;
    cursor: pointer;
}

input[type="file"] { font-size: 0.85rem; color: var(--muted); }

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
}

.room-names {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* ===== Problem editor ===== */
.toolbar { display: flex; gap: 0.6rem; margin-bottom: 1rem; flex-wrap: wrap; }

.room-head {
    font-size: 0.9rem;
    color: var(--muted);
    margin: 1.5rem 0 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--line);
}

.room-head:first-child { margin-top: 0; }

.problem-card {
    background: var(--card-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 0.6rem;
    overflow: hidden;
}

.problem-card summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    list-style: none;
}

.problem-card summary::-webkit-details-marker { display: none; }

.p-badge {
    background: var(--accent);
    border-radius: 20px;
    padding: 0.1rem 0.7rem;
    font-size: 0.78rem;
    white-space: nowrap;
    flex: 0 0 auto;
}

.p-peek {
    color: var(--muted);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.p-body {
    padding: 0 1rem 1.1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
}

/* ===== Buttons ===== */
.btn-primary, .btn-secondary, .btn-ghost {
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1.4rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, filter 0.15s;
}

.btn-primary:hover, .btn-secondary:hover, .btn-ghost:hover { transform: translateY(-1px); filter: brightness(1.12); }

.btn-primary { background: linear-gradient(135deg, var(--accent), #8d2a5e); color: #fff; }
.btn-secondary { background: var(--card-2); border: 1px solid var(--line); color: var(--text); }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 0.5rem 1rem;
    font-weight: 500;
    font-size: 0.88rem;
}

.file-label { display: inline-block; }

.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }
.sub-actions { margin-top: 1.25rem; }

.opts { display: flex; flex-direction: column; gap: 0.6rem; }

.check {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.check input { margin-top: 0.35rem; flex: 0 0 auto; }
.check small { color: var(--muted); }

.build-status { margin-top: 1rem; font-size: 0.9rem; white-space: pre-line; }
.build-status.working { color: var(--warn); }
.build-status.ok { color: var(--ok); }
.build-status.err { color: var(--err); }

/* ===== Guide ===== */
.guide .steps {
    margin: 0 0 1.25rem 1.25rem;
    font-size: 0.92rem;
}

.guide .steps li { margin-bottom: 0.45rem; }
.guide .steps small { color: var(--muted); }

.tag {
    font-size: 0.7rem;
    background: var(--ok);
    color: #05130d;
    border-radius: 20px;
    padding: 0.1rem 0.6rem;
    vertical-align: middle;
    font-weight: 700;
}

.note {
    background: #0a0a10;
    border: 1px solid var(--line);
    border-left: 3px solid var(--warn);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    font-size: 0.9rem;
}

.note ul { margin: 0.6rem 0 0 1.1rem; }
.note li { margin-bottom: 0.4rem; }

.site-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding-top: 1rem;
}

@media (max-width: 560px) {
    .card { padding: 1.25rem; }
    .wrap { padding: 0 0.9rem 3rem; }
}

[hidden] { display: none !important; }

/* ========================= 탭 ========================= */
.tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.75rem;
}

.tab {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.55rem 1.4rem;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover { color: var(--text); border-color: #4a4a60; }

.tab.active {
    background: linear-gradient(135deg, var(--accent), #8d2a5e);
    border-color: transparent;
    color: #fff;
}

.tab-panel { display: none; }
.tab-panel.active { display: flex; }

/* ========================= 리치 편집기 ========================= */
.rich-editor {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0a0a10;
    overflow: hidden;
}

.rich-editor:focus-within { border-color: var(--accent-2); }

.rich-toolbar {
    display: flex;
    gap: 0.25rem;
    padding: 0.35rem;
    background: #0f0f16;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.rich-tool {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    font: inherit;
    font-size: 0.85rem;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    min-width: 32px;
}

.rich-tool:hover { background: var(--card-2); color: var(--text); border-color: var(--line); }
.tool-hl { background: rgba(224, 69, 95, 0.35); border-radius: 3px; padding: 0 0.2em; }

.rich-area {
    padding: 0.6rem 0.7rem;
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.8;
    outline: none;
    overflow-wrap: anywhere;
}

.rich-area:empty::before {
    content: attr(data-placeholder);
    color: #55596a;
}

.rich-area .highlight { color: var(--accent-2); font-weight: 700; }

.mathchip {
    display: inline-block;
    background: rgba(224, 69, 95, 0.12);
    border: 1px solid rgba(224, 69, 95, 0.35);
    border-radius: 5px;
    padding: 0 0.3em;
    margin: 0 0.1em;
    cursor: pointer;
    vertical-align: middle;
}

.mathchip:hover { background: rgba(224, 69, 95, 0.24); }

/* ---- 수식 팝업 ---- */
.math-dialog {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 500;
}

.math-dialog.open { display: flex; }

.math-dialog-inner {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.4rem;
    width: min(560px, 100%);
    max-height: 90vh;
    overflow: auto;
}

.math-dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.9rem;
}

.math-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

math-field, .math-fallback {
    display: block;
    width: 100%;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.6rem;
    color: var(--text);
    font-size: 1.15rem;
}

.math-fallback { font-family: ui-monospace, monospace; font-size: 0.95rem; }

.math-help { color: var(--muted); font-size: 0.82rem; margin: 0.6rem 0; }
.math-help code { font-size: 0.9em; }

.math-snippets { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.9rem; }

.math-snip {
    background: var(--card-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
}

.math-snip:hover { border-color: var(--accent-2); }

.math-preview-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.7rem;
    min-height: 3rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.math-preview-label { color: var(--muted); font-size: 0.8rem; flex: 0 0 auto; }
.math-preview-err { color: var(--err); font-size: 0.85rem; }

.math-dialog-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }

/* ========================= 문제 유형 ========================= */
.p-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.p-row .field { flex: 1 1 180px; }

.p-type {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 0.05rem 0.6rem;
    font-size: 0.72rem;
    color: var(--muted);
    flex: 0 0 auto;
}

.p-empty { color: #55596a; }
.p-peek .katex { font-size: 0.95em; }

.type-picker { display: flex; gap: 0.3rem; }

.type-btn {
    flex: 1;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    font: inherit;
    font-size: 0.85rem;
    padding: 0.5rem 0.4rem;
    cursor: pointer;
}

.type-btn:hover { color: var(--text); }
.type-btn.active { border-color: var(--accent-2); color: var(--text); background: rgba(224, 69, 95, 0.12); }

.answer-block { display: flex; flex-direction: column; gap: 0.45rem; }

.ox-picker { display: flex; gap: 0.5rem; }

.ox-btn {
    flex: 1;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font: inherit;
    padding: 0.6rem;
    cursor: pointer;
}

.ox-btn.active { border-color: var(--ok); color: var(--text); background: rgba(63, 169, 128, 0.14); }

.choice-editor { display: flex; flex-direction: column; gap: 0.4rem; }
.choice-row { display: flex; gap: 0.4rem; align-items: center; }

.choice-mark {
    flex: 0 0 34px;
    height: 34px;
    border-radius: 50%;
    background: #0a0a10;
    border: 1px solid var(--line);
    color: var(--muted);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.choice-mark.active { border-color: var(--ok); background: rgba(63, 169, 128, 0.2); color: var(--text); font-weight: 700; }

.choice-del {
    flex: 0 0 30px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    height: 34px;
}

.choice-del:disabled { opacity: 0.3; cursor: default; }

/* 선택지 줄에 들어가는 √ 버튼은 옆 버튼들과 높이를 맞춘다 */
.choice-row .btn-root-mini { flex: 0 0 34px; height: 34px; }
.choice-add { align-self: flex-start; margin-top: 0.15rem; }

/* ========================= 공유 ========================= */
.share-box {
    margin-top: 1.25rem;
    background: #0a0a10;
    border: 1px solid var(--ok);
    border-radius: 10px;
    padding: 1rem;
}

.share-label { font-size: 0.8rem; color: var(--ok); display: block; margin-bottom: 0.5rem; }
.share-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.share-row input { flex: 1 1 240px; }
.share-row .btn-ghost { display: grid; place-items: center; text-decoration: none; }

.extra { margin-top: 1.5rem; border-top: 1px dashed var(--line); padding-top: 1rem; }
.extra summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; margin-bottom: 0.9rem; }

/* ========================= 게시판 ========================= */
.board-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.board-tools { display: flex; gap: 0.5rem; }
.board-tools input { width: 200px; }

.board-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.board-card {
    background: var(--card-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.board-thumb {
    /* 썸네일은 방 수만큼 나눠 붙인 720x220 그림이다.
       비율을 그림에 맞춰두면 카드 폭이 달라져도 잘리지 않고 방이 다 보인다. */
    aspect-ratio: 720 / 220;
    min-height: 86px;
    background: linear-gradient(135deg, #211a2e, #14141d) center/cover;
    position: relative;
}

/* ===== 방 배경 보관함 ===== */
.bg-slot { position: relative; margin: 0; }
.bg-slot .bg-slot-empty {
    display: grid; place-items: center;
    aspect-ratio: 16 / 9; border: 1px dashed var(--line); border-radius: 8px;
    color: var(--muted); font-size: 0.8rem;
}
.bg-slot-pick { width: 100%; margin-top: 0.3rem; padding: 0.35rem; font-size: 0.78rem; }

.bg-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.6rem;
}

.bg-card {
    position: relative; margin: 0;
    background: #0a0a10; border: 1px solid var(--line); border-radius: 8px;
    padding: 0.35rem; overflow: hidden;
}
.bg-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 5px; display: block; }
.bg-card figcaption {
    font-size: 0.76rem; margin-top: 0.25rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bg-card small { font-size: 0.7rem; color: var(--muted); }
.bg-card-del {
    position: absolute; top: 0.3rem; right: 0.3rem;
    width: 22px; height: 22px; border-radius: 5px;
    background: rgba(0,0,0,0.7); border: 1px solid var(--line);
    color: var(--muted); line-height: 1; cursor: pointer;
}
.bg-card-del:hover { border-color: var(--accent-2); color: var(--text); }

.bg-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.55rem;
    max-height: 55vh; overflow-y: auto; margin-top: 0.5rem;
}
.bg-pick-item {
    background: #0a0a10; border: 1px solid var(--line); border-radius: 8px;
    padding: 0.3rem; cursor: pointer; color: var(--text); font: inherit; text-align: left;
}
.bg-pick-item:hover { border-color: var(--accent-2); }
.bg-pick-item img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 5px; display: block; }
.bg-pick-item span {
    display: block; font-size: 0.74rem; margin-top: 0.2rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 방 배경 고르기 팝업 */
.pick-rooms { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.6rem 0; }

.pick-room {
    display: grid;
    grid-template-columns: auto 96px 1fr;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
}

.pick-room:hover { border-color: var(--accent-2); }
.pick-room img { width: 96px; height: 54px; object-fit: cover; border-radius: 5px; display: block; }
.pick-room span { font-size: 0.85rem; }
.pick-room small { display: block; color: var(--muted); font-size: 0.76rem; }

.board-audio {
    padding: 0.45rem 0.6rem 0;
    background: var(--card);
}

.board-audio audio {
    width: 100%;
    height: 32px;
    display: block;
    filter: invert(0.88) hue-rotate(180deg);   /* 밝은 기본 플레이어를 어두운 화면에 맞춘다 */
}

.board-audio-none,
.board-audio-msg { font-size: 0.76rem; color: var(--muted); display: block; padding: 0.1rem 0 0.2rem; }

.board-skin {
    position: absolute;
    left: 0.6rem;
    bottom: 0.6rem;
    background: rgba(0, 0, 0, 0.72);
    border-radius: 20px;
    padding: 0.1rem 0.65rem;
    font-size: 0.75rem;
}

.board-body { padding: 0.9rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.board-title { font-size: 1rem; }
.board-note { font-size: 0.85rem; color: var(--muted); }
.board-meta { font-size: 0.78rem; color: #6a6f80; }

.board-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: auto;
    padding-top: 0.6rem;
}

.board-actions .btn-primary,
.board-actions .btn-secondary,
.board-actions .btn-ghost {
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    text-decoration: none;
}

.board-actions .danger { color: var(--err); border-color: rgba(224, 85, 75, 0.4); }

/* ========================= 정답 루트 버튼 ========================= */
.ans-short-row { display: flex; gap: 0.4rem; }
.ans-short-row .ans-short { flex: 1; }

.btn-root-mini {
    flex: 0 0 42px;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-size: 1.05rem;
    cursor: pointer;
}

.btn-root-mini:hover { border-color: var(--accent-2); }

/* ========================= 댓글 ========================= */
.comment-panel {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px dashed var(--line);
}

.comment-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.8rem; }

.comment {
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
}

.comment-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

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

.comment-del {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.2rem;
}

.comment-del:hover { color: var(--err); }

.comment-text { font-size: 0.88rem; overflow-wrap: anywhere; }

.comment-form { display: flex; flex-direction: column; gap: 0.4rem; }
.comment-form-row { display: flex; gap: 0.4rem; }
.comment-form-row input { flex: 1; font-size: 0.85rem; padding: 0.45rem 0.55rem; }
.comment-form-row .btn-secondary { flex: 0 0 auto; padding: 0.45rem 0.9rem; font-size: 0.85rem; }

.comment-status { font-size: 0.8rem; min-height: 1em; }
.comment-status.working { color: var(--warn); }
.comment-status.err { color: var(--err); }

/* ========================= AI 패널 ========================= */
.ai-panel {
    margin-top: 1.25rem;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem 1.1rem;
}

.ai-panel summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.ai-panel[open] summary { margin-bottom: 1rem; }

.tag-opt {
    font-size: 0.68rem;
    font-weight: 500;
    background: var(--card-2);
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 20px;
    padding: 0.05rem 0.55rem;
    vertical-align: middle;
    margin-left: 0.3rem;
}

/* ========================= 내 글 찾기 ========================= */
.mine-panel {
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

.mine-panel summary { cursor: pointer; font-weight: 600; font-size: 0.92rem; }
.mine-panel summary small { color: var(--muted); font-weight: 400; }
.mine-panel[open] summary { margin-bottom: 0.8rem; }

.mine-form { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.mine-form input { flex: 1 1 150px; font-size: 0.88rem; padding: 0.45rem 0.6rem; }
.mine-form button { flex: 0 0 auto; padding: 0.45rem 1rem; font-size: 0.85rem; }

.admin-tag {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--warn);
    border-radius: 5px;
    color: var(--warn);
    font-size: 0.7rem;
    align-self: center;
}

.private-tag {
    background: rgba(210, 162, 60, 0.18);
    border: 1px solid rgba(210, 162, 60, 0.4);
    color: var(--warn);
    border-radius: 20px;
    padding: 0 0.5rem;
    font-size: 0.72rem;
}

/* ========================= 잠긴 카드 ========================= */
.board-card.is-locked .board-thumb {
    background-image: none !important;
    background: repeating-linear-gradient(45deg, #16161f, #16161f 12px, #1b1b26 12px, #1b1b26 24px);
}

.lock-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 2rem;
    opacity: 0.55;
}

.board-card.is-locked .board-title { color: var(--muted); }

.site-footer .credit {
    color: var(--text);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.key-links {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
    font-size: 0.82rem;
}

.key-links .btn-ghost { padding: 0.25rem 0.6rem; font-size: 0.78rem; }

/* ========================= AI 도우미 카드 ========================= */
.ai-card {
    border-color: rgba(224, 69, 95, 0.28);
    background: linear-gradient(180deg, rgba(224, 69, 95, 0.06), transparent 60%), var(--card);
    padding: 1.1rem 1.4rem;
}

.ai-card > details > summary {
    cursor: pointer;
    font-size: 0.98rem;
}

.ai-card > details[open] > summary { margin-bottom: 1rem; }
.ai-card .field { max-width: 520px; }

/* ========================= 상단 작업 바 ========================= */
.work-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.6rem 0.75rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.work-bar .btn-ghost,
.work-bar .file-label {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

.work-bar-note {
    flex: 1 1 240px;
    min-width: 0;
    font-size: 0.78rem;
    color: var(--muted);
}

.work-bar-note.ok { color: var(--ok); font-weight: 700; }

@media (max-width: 560px) {
    .work-bar-note { flex-basis: 100%; }
}

/* ========================= 배경음악 보관함 ========================= */
.bgm-library {
    margin-top: 1rem;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem;
}

.bgm-lib-head { font-size: 0.95rem; margin-bottom: 0.4rem; }
.bgm-lib-head small { color: var(--muted); font-weight: 400; }

.bgm-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.8rem; }

.bgm-item {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 0.7rem 0.85rem;
    background: var(--card-2);
}

.bgm-item.current { border-color: var(--ok); background: rgba(63, 169, 128, 0.08); }

.bgm-item-head {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.bgm-item-name { font-size: 0.88rem; font-weight: 600; }
.bgm-item-meta { font-size: 0.76rem; color: var(--muted); }

.bgm-badge {
    background: var(--ok);
    color: #05130d;
    border-radius: 20px;
    padding: 0.02rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 700;
}

.bgm-item audio { width: 100%; height: 34px; }

.bgm-item-actions { display: flex; gap: 0.4rem; margin-top: 0.55rem; flex-wrap: wrap; }

.bgm-item-actions button,
.bgm-item-actions a {
    padding: 0.32rem 0.75rem;
    font-size: 0.8rem;
    text-decoration: none;
}

.bgm-player {
    margin-top: 1rem;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    max-width: 520px;
}

.bgm-player-head {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.bgm-player-name { font-size: 0.9rem; font-weight: 600; }
.bgm-player-size { font-size: 0.78rem; color: var(--muted); }

.bgm-player audio { width: 100%; height: 36px; }

.bgm-player-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.7rem;
}

.bgm-player-actions .btn-secondary,
.bgm-player-actions .btn-ghost {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    text-decoration: none;
}

.note-warn {
    border-left-color: var(--warn);
    margin: 1rem 0;
}

.note-warn p { margin: 0.5rem 0; }
.note-warn .auth-btn { margin-top: 0.2rem; padding: 0.45rem 0.9rem; font-size: 0.85rem; }
.note-warn ul { margin: 0.5rem 0 0 1.1rem; }
.note-warn li { margin-bottom: 0.4rem; }
.note-sub { color: var(--muted); font-size: 0.85rem; }

/* 버튼 안 부제 */
.actions .btn-primary small,
.actions .btn-secondary small {
    display: block;
    font-weight: 400;
    font-size: 0.72rem;
    opacity: 0.75;
    margin-top: 0.1rem;
}

/* ========================= AI 실행 버튼 3종 ========================= */
.ai-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin: 1.2rem 0 0.5rem;
}

.ai-action {
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

/* ========================= 참고 자료 첨부 ========================= */
.ai-ref {
    margin: 1rem 0 0.4rem;
    padding: 0.85rem;
    background: #0a0a10;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.ai-ref > .help { margin: 0.35rem 0 0.7rem; }

.ai-ref-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.ai-ref-row .file-label,
.ai-ref-row .btn-ghost { padding: 0.5rem 0.9rem; font-size: 0.85rem; white-space: nowrap; }

.ai-ref-list { margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.35rem; }

.ai-ref-empty { margin: 0; font-size: 0.8rem; color: var(--muted); }

.ai-ref-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.55rem;
    background: var(--card-2);
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: 0.82rem;
}

.ai-ref-icon { flex: 0 0 auto; }

.ai-ref-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-ref-sub { flex: 0 0 auto; color: var(--muted); font-size: 0.76rem; }

.ai-ref-del {
    flex: 0 0 24px;
    height: 24px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--muted);
    line-height: 1;
    cursor: pointer;
}

.ai-ref-del:hover { border-color: var(--accent-2); color: var(--text); }

.ai-ref-sum { margin: 0.15rem 0 0; font-size: 0.76rem; color: var(--muted); }

.ai-ref-note {
    margin: 0.75rem 0 0 1.05rem;
    padding: 0;
    font-size: 0.78rem;
    color: var(--muted);
}

.ai-ref-note li { margin-bottom: 0.3rem; }
.ai-ref-note li b { color: var(--text); }

/* 배경 칸: 왼쪽에 무료 하나, 오른쪽에 키가 필요한 셋을 세로로 */
.ai-actions-bg { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* 세 칸이 왼쪽 무료 칸과 정확히 같은 높이를 나눠 갖는다 */
.ai-action-column {
    display: grid;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    min-width: 0;
}

.ai-actions-foot { margin: 0.2rem 0 0; font-size: 0.8rem; }

/* 무료 칸이 오른쪽 세 칸 높이를 그대로 받아 한 덩어리로 보이게 */
.ai-action-free { border-color: var(--accent); }

.ai-action p.ai-action-tip {
    margin-top: auto;          /* 아래 .ai-action p 의 margin:0 을 이기려면 이 선택자여야 한다 */
    padding-top: 0.6rem;
    border-top: 1px dashed var(--line);
    font-size: 0.8rem;
}

@media (max-width: 720px) {
    .ai-actions-bg { grid-template-columns: 1fr; }
}

/* 음악 칸은 3분할이 아니라 정확히 반반 (좁은 화면에서는 위아래로) */
.ai-actions-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;   /* 한쪽이 길다고 반대쪽 칸이 늘어나지 않게 */
}

@media (max-width: 720px) {
    .ai-actions-pair { grid-template-columns: 1fr; }
}

.ai-action > button,
.ai-action > .btn-link {
    width: 100%;
    padding: 0.7rem 0.9rem;
    font-size: 0.92rem;
}

/* 버튼 모양의 링크 (Suno 바로가기) */
.ai-action > .btn-link {
    display: block;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
}

/* Suno 안내 칸 */
.ai-action-guide { border-color: var(--accent); }

.ai-action-guide a { color: var(--accent-2); }
.ai-action-guide > .btn-link { color: var(--text); }

.ai-steps {
    margin: 0 0 0 1.15rem;
    padding: 0;
    font-size: 0.82rem;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ai-steps li b { color: var(--text); }

.ai-steps code {
    display: inline-block;
    margin-top: 0.2rem;
    background: #0f0f16;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0.2rem 0.4rem;
    font-size: 0.74rem;
    word-break: break-word;
}

.ai-action p { font-size: 0.85rem; color: var(--muted); margin: 0; }
.ai-action p b { color: var(--text); }
.ai-action p small { display: block; margin-top: 0.2rem; font-size: 0.78rem; opacity: 0.85; }
.ai-action p code { font-size: 0.76rem; }

.ai-action ul {
    margin: 0 0 0 1.05rem;
    padding: 0;
    font-size: 0.82rem;
    color: var(--muted);
}

.ai-action li { margin-bottom: 0.35rem; }
.ai-action li b { color: var(--text); }

/* 배경음악 생성 확인 단계 */
.bgm-confirm {
    margin-top: 0.6rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--line);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bgm-confirm .field { max-width: 140px; }
.bgm-confirm .help { margin: 0; font-size: 0.8rem; }
.bgm-confirm-actions { display: flex; gap: 0.5rem; }
.bgm-confirm-actions button { padding: 0.5rem 1rem; font-size: 0.85rem; }

/* AI 도우미 소제목 */
.ai-sub {
    font-size: 0.92rem;
    margin: 1.4rem 0 0.6rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--line);
}

.ai-sub:first-of-type { border-top: none; padding-top: 0; margin-top: 0.8rem; }

.ai-note {
    background: #0f0f16;
    border-left: 3px solid var(--warn);
    border-radius: 6px;
    padding: 0.65rem 0.8rem;
    margin: 0.7rem 0 0;
    font-size: 0.83rem;
}

.ai-card .custom-grid { max-width: none; margin-top: 0.8rem; }
.ai-card .custom-grid .field { max-width: none; }
.custom-grid .help.wide { grid-column: 1 / -1; margin: 0; }

.bgm-confirm-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.bgm-confirm-row .field { flex: 1 1 130px; max-width: none; }
.bgm-confirm .field { max-width: none; }
#bgm-prompt-preview {
    background: #0f0f16;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    font-size: 0.76rem;
    word-break: break-word;
    margin: 0;
}

.bg-room-list { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.5rem 0; }

.bg-room {
    background: var(--card-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.bg-room-top {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    cursor: pointer;
}

.bg-room-concept {
    width: 100%;
    font-size: 0.82rem;
    padding: 0.4rem 0.55rem;
}

.bg-room img {
    width: 74px;
    height: 42px;
    object-fit: cover;
    border-radius: 4px;
    flex: 0 0 auto;
}

.bg-room .bg-room-empty {
    width: 74px;
    height: 42px;
    border-radius: 4px;
    flex: 0 0 auto;
    background: repeating-linear-gradient(45deg, #16161f, #16161f 8px, #1b1b26 8px, #1b1b26 16px);
}

.bg-room-text { font-size: 0.85rem; }
.bg-room-text small { display: block; color: var(--muted); font-size: 0.76rem; }

/* ========================= AI 키 보관함 ========================= */
.ai-keyring { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.9rem; }

.ai-key-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.ai-key-name {
    flex: 0 0 140px;
    font-size: 0.85rem;
    color: var(--muted);
}

.ai-key-row.has-key .ai-key-name { color: var(--text); }
.ai-key-dot { color: var(--ok); font-size: 0.7rem; }

.ai-key-row input {
    flex: 1 1 220px;
    font-size: 0.82rem;
    padding: 0.42rem 0.55rem;
}

.ai-key-row a { font-size: 0.78rem; white-space: nowrap; }

.ai-key-note {
    flex: 1 0 100%;
    margin: 0 0 0.2rem 140px;
    font-size: 0.75rem;
    color: var(--muted);
}

.ai-key-note b { color: var(--text); }

@media (max-width: 560px) { .ai-key-note { margin-left: 0; } }
.ai-key-row .btn-ghost { padding: 0.34rem 0.6rem; font-size: 0.76rem; white-space: nowrap; }

@media (max-width: 560px) {
    .ai-key-name { flex-basis: 100%; }
}

/* ========================= 로그인 ========================= */
.authbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
    font-size: 0.88rem;
}

.auth-who { color: var(--muted); }
.auth-who b { color: var(--text); }
.auth-warn { color: var(--warn); font-size: 0.83rem; }
.authbar .auth-btn { padding: 0.35rem 0.9rem; font-size: 0.83rem; }

.auth-dialog {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 600;
}

.auth-dialog-inner {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.5rem;
    width: min(400px, 100%);
    max-height: 90vh;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.05rem;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    background: #fff;
    color: #1f1f1f;
    border: none;
    border-radius: 10px;
    padding: 0.7rem 1rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.btn-google span {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0);
    color: #fff;
    font-size: 0.72rem;
}

.btn-google:hover { filter: brightness(0.94); }

.auth-or {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--muted);
    font-size: 0.8rem;
}

.auth-or::before, .auth-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

.auth-msg { font-size: 0.83rem; min-height: 1em; white-space: pre-line; }
.auth-msg.working { color: var(--warn); }
.auth-msg.err { color: var(--err); }

.auth-actions { display: flex; gap: 0.5rem; }
.auth-actions button { flex: 1; padding: 0.6rem; font-size: 0.88rem; }

/* ========================= 게시판 필터 ========================= */
.board-filter { display: flex; gap: 0.4rem; margin-bottom: 0.9rem; }

.filter-btn {
    background: var(--card-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.35rem 1rem;
    color: var(--muted);
    font: inherit;
    font-size: 0.83rem;
    cursor: pointer;
}

.filter-btn.active { border-color: var(--accent-2); color: var(--text); }
