/* 게시글 작성/수정 */
.bbs-write {
    padding: 2rem 0 3.5rem;
}

.bbs-write__header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.bbs-write__header h2 {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.02em;
}

.bbs-write__header p {
    margin-top: 0.5rem;
    color: #8a8f9c;
    font-size: 0.92rem;
    line-height: 1.55;
}

.bbs-write__card {
    border-radius: 18px;
    background: var(--color-white);
    padding: 1.75rem 2rem 1.5rem;
    border: 1px solid rgba(0, 10, 87, 0.08);
    box-shadow: 0 12px 40px rgba(0, 10, 87, 0.06);
}

/* 폼 본문 */
.bbs-write__sections {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

/* 라벨 상단 · 입력 하단 (세로 스택) */
.bbs-field {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
    align-items: start;
    padding: 1rem 0;
    border-bottom: 1px solid #edf0f5;
}

.bbs-field:last-child {
    border-bottom: none;
}

.bbs-field--stack {
    grid-template-columns: 1fr;
    gap: 0.55rem;
}

/* 상단 메타(공지·카테고리) */
.bbs-form-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 0 0.25rem;
    border-bottom: 1px solid #edf0f5;
}

.bbs-form-meta .bbs-field {
    border-bottom: none;
    padding: 0;
    grid-template-columns: 1fr;
    gap: 0.55rem;
}

.bbs-field__label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #3d4451;
    padding-top: 0;
    line-height: 1.4;
}

.bbs-field__label .required {
    color: var(--color-error);
    margin-left: 2px;
}

.bbs-field__control {
    min-width: 0;
}

.bbs-field__control .input,
.bbs-field__control select.input {
    width: 100%;
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid #dfe3eb;
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.bbs-field__control .input:focus-visible,
.bbs-field__control select.input:focus-visible {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 10, 87, 0.08);
    outline: none;
}

.bbs-field__control textarea.input {
    min-height: 120px;
    resize: vertical;
}

.bbs-field__control textarea.bbs-plain-content {
    min-height: 240px;
    line-height: 1.6;
    resize: vertical;
}

.bbs-field__hint {
    margin-top: 0.35rem;
    font-size: 0.82rem;
    color: #9096a3;
    line-height: 1.55;
}

.bbs-field__hint code {
    font-size: 0.78rem;
    background: #f0f2f6;
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

/* 칩형 라디오/체크박스 */
.bbs-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.15rem;
}

.bbs-form-meta .bbs-chip-group {
    padding-top: 0;
}

.bbs-chip,
label.bbs-chip {
    position: relative;
}

/* th:field 체크박스는 hidden(false) + checkbox가 함께 렌더되므로 label로 감싸지 않음 */
.bbs-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    clip: rect(0, 0, 0, 0);
    overflow: hidden;
    pointer-events: none;
}

.bbs-chip input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    clip: rect(0, 0, 0, 0);
    overflow: hidden;
}

.bbs-chip input[type="radio"] + span,
.bbs-chip__label > span {
    display: inline-block;
    padding: 0.48rem 1.05rem;
    border: 1px solid #d5dae4;
    border-radius: 999px;
    font-size: 0.88rem;
    color: #555;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.bbs-chip input[type="radio"]:checked + span,
.bbs-chip input[type="checkbox"]:checked ~ .bbs-chip__label span {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    font-weight: 500;
}

.bbs-chip input[type="radio"]:focus-visible + span,
.bbs-chip input[type="checkbox"]:focus-visible ~ .bbs-chip__label span {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.bbs-chip__label {
    margin: 0;
    cursor: pointer;
}

.bbs-publish-settings {
    margin-top: 0.75rem;
}

.bbs-publish-settings.is-hidden {
    display: none;
}

.bbs-field__label--inline {
    display: block;
    margin: 0.35rem 0 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
}

.bbs-publish-period {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin-top: 0.75rem;
}

.bbs-publish-period.is-hidden {
    display: none;
}

.bbs-publish-period__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #555;
}

.bbs-publish-period__field .input {
    min-width: 11rem;
}

/* 비회원 / 관리자 수정 필드 */
.bbs-field--guest-narrow .bbs-field__control {
    max-width: 420px;
}

.bbs-field--guest-narrow .bbs-field__control .bbs-input--md {
    width: 100%;
    max-width: 420px;
}

.bbs-tab-group {
    display: inline-flex;
    width: fit-content;
    min-width: 260px;
    max-width: 100%;
    border: 1px solid #dfe3eb;
    border-radius: 10px;
    overflow: hidden;
    background: #f3f5f9;
}

.bbs-tab {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
}

.bbs-tab input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.bbs-tab span {
    display: block;
    min-width: 7.5rem;
    padding: 0.72rem 1.25rem;
    text-align: center;
    font-size: 0.9rem;
    color: #5c6370;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s;
    border-right: 1px solid #dfe3eb;
    box-sizing: border-box;
}

.bbs-tab:last-child span {
    border-right: none;
}

.bbs-tab input:checked + span {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

.bbs-tab input:focus-visible + span {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

/* 첨부파일 */
.bbs-file {
    border: 2px dashed #d8deea;
    border-radius: 12px;
    padding: 1.15rem 1.25rem;
    background: #fafbfd;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.bbs-file__pick {
    display: inline-flex;
    cursor: pointer;
}

.bbs-file__pick-btn {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    border: 1px solid #d0d7e6;
    border-radius: 8px;
    background: #fff;
    font-size: 0.88rem;
    color: #333;
    transition: border-color 0.15s, background 0.15s;
}

.bbs-file__pick:hover .bbs-file__pick-btn {
    border-color: var(--color-primary);
    background: #f5f8ff;
}

.bbs-file__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.bbs-file__status {
    font-size: 0.88rem;
    color: #666;
}

.bbs-file:hover {
    border-color: var(--color-primary);
    background: #f5f8ff;
}

.bbs-file-list {
    margin-top: 0.85rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.bbs-file-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.9rem;
    background: #fff;
    border: 1px solid #e6eaf2;
    border-radius: 8px;
    font-size: 0.88rem;
}

.bbs-file-item__name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #444;
}

.bbs-file-item label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--color-error);
    cursor: pointer;
    font-size: 0.82rem;
    white-space: nowrap;
}

/* 코드 선택 — auto-fill grid */
.bbs-code-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.bbs-code-group select.input {
    width: 100%;
    min-width: 0;
}

/* Turnstile (비회원 캡차) — 상단 간격은 article.wrapper --bbs-stack-gap 과 동일 */
.bbs-write__turnstile {
    display: flex;
    justify-content: center;
    margin-top: var(--bbs-stack-gap, 1.25rem);
    padding: 0;
}

/* 삭제 버튼 (작성 폼) — 나머지 액션 스타일은 bbs.css .bbs-page__actions */

.bbs-page__actions .btn--danger {
    background: #fff;
    color: var(--color-error);
    border-color: var(--color-error);
}

.bbs-page__actions .btn--danger:hover {
    background: #fff5f5;
}

/* 비밀번호 확인 등 단일 필드 페이지 */
.bbs-edit-auth .bbs-write__card {
    padding: 2rem 2rem 1.75rem;
}

.bbs-edit-auth .bbs-field {
    border-bottom: none;
    padding: 0;
}

/* SunEditor */
.bbs-field__control .sun-editor {
    border-radius: 10px !important;
    border-color: #dfe3eb !important;
    overflow: hidden;
}

@media all and (max-width: 768px) {
    .bbs-write {
        padding: 1.25rem 0 2.5rem;
    }

    .bbs-write__card {
        padding: 1.25rem 1.1rem 1.25rem;
        border-radius: 14px;
    }

    .bbs-write__header h2 {
        font-size: 1.35rem;
    }

    .bbs-field--guest-narrow .bbs-field__control,
    .bbs-field--guest-narrow .bbs-field__control .bbs-input--md {
        max-width: 100%;
    }

    .bbs-tab span {
        min-width: 0;
        padding: 0.65rem 0.85rem;
        font-size: 0.85rem;
    }
}
