* {
  box-sizing: border-box;
}

/* hidden 속성이 display를 지정한 클래스(flex 등)에도 항상 우선하도록 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: #222;
  background: #f5f6f8;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- 좌측 사이드바 ---------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #1e2530;
  color: #cfd6e0;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  /* 콘텐츠가 길어져도 메뉴는 화면에 고정 (하단 로그인 영역 항상 표시) */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.logo {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  color: #fff;
  margin-bottom: 32px;
  padding: 0 8px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  display: block;
  padding: 11px 12px;
  border-radius: 8px;
  color: #cfd6e0;
  text-decoration: none;
  font-size: 15px;
  transition: background 0.15s, color 0.15s;
}

.menu-item:hover {
  background: #2b3442;
  color: #fff;
}

.menu-item.active {
  background: #3b82f6;
  color: #fff;
  font-weight: 600;
}

.auth-box {
  margin-top: auto;
  border-top: 1px solid #313b49;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-info {
  padding: 8px 12px 14px;
  font-size: 14px;
  line-height: 1.6;
}

#user-name {
  font-weight: 700;
  color: #fff;
}

/* ---------- 우측 컨텐츠 ---------- */
.content {
  flex: 1;
  padding: 48px 56px;
  max-width: 1200px;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.section h1 {
  margin-top: 0;
  font-size: 28px;
}

/* ---------- 폼 ---------- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 360px;
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  padding: 28px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.auth-form input {
  padding: 10px 12px;
  border: 1px solid #ccd2d9;
  border-radius: 8px;
  font-size: 15px;
}

.auth-form input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-message {
  margin: 0;
  font-size: 13px;
  min-height: 1em;
  color: #dc2626;
}

.form-message.success {
  color: #16a34a;
}

.btn {
  padding: 11px 16px;
  border: none;
  border-radius: 8px;
  background: #3b82f6;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  background: #2f6fe0;
}

.btn-outline {
  background: transparent;
  border: 1px solid #4a5566;
  color: #cfd6e0;
}

.btn-outline:hover {
  background: #2b3442;
}

.login-hint {
  margin: 0;
  line-height: 1.6;
}

/* ---------- 방명록 ---------- */
.hint {
  color: #6b7480;
  font-size: 14px;
}

.guestbook-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 560px;
  margin-bottom: 28px;
}

.guestbook-form textarea {
  padding: 12px;
  border: 1px solid #ccd2d9;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
}

.guestbook-form textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.guestbook-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gb-entry {
  max-width: 560px;
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
}

.gb-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 14px;
}

.gb-time {
  color: #9aa3ad;
  font-size: 12px;
}

.gb-delete {
  margin-left: auto;
  border: none;
  background: none;
  color: #dc2626;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}

.gb-delete:hover {
  text-decoration: underline;
}

.gb-body {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.gb-pagination {
  display: flex;
  gap: 6px;
  max-width: 560px;
  justify-content: center;
  margin-top: 20px;
}

.gb-page-btn {
  min-width: 36px;
  padding: 7px 10px;
  border: 1px solid #ccd2d9;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
}

.gb-page-btn:hover:not(:disabled) {
  border-color: #3b82f6;
  color: #3b82f6;
}

.gb-page-btn.current {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
  font-weight: 600;
}

.gb-page-btn:disabled:not(.current) {
  color: #b6bdc6;
  cursor: default;
}

/* ---------- 게시판 ---------- */
#section-board {
  max-width: var(--board-width, 1100px);
}

/* 게시판 화면에서는 콘텐츠 영역의 폭 제한을 풀어 커스텀 폭(최대 1600px)이 그대로 적용되게 한다 */
.content:has(#section-board.active) {
  max-width: none;
}

.board-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  min-height: 42px;
}

.btn-gray {
  background: #6b7480;
}

.btn-gray:hover {
  background: #5a6270;
}

.board-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  padding: 18px;
}

.board-form input[type="text"] {
  padding: 10px 12px;
  border: 1px solid #ccd2d9;
  border-radius: 8px;
  font-size: 15px;
}

.board-form textarea {
  padding: 12px;
  border: 1px solid #ccd2d9;
  border-radius: 8px;
  font-size: 14px;
  font-family: "SF Mono", "D2Coding", Consolas, monospace;
  line-height: 1.6;
  resize: vertical;
}

.board-form input[type="text"]:focus,
.board-form textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.board-form-actions {
  display: flex;
  gap: 8px;
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 10px;
  overflow: hidden;
  font-size: 14px;
}

.board-table th {
  background: #f1f3f6;
  color: #4b5563;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid #e3e6ea;
  white-space: nowrap;
}

.board-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #eef1f4;
  vertical-align: middle;
}

.board-table tbody tr:last-child td {
  border-bottom: none;
}

.board-table tbody tr:hover {
  background: #f8fafc;
}

.board-cell-title {
  width: 100%;
  max-width: 0; /* 긴 제목이 표를 늘리지 않고 말줄임 처리되도록 */
}

.board-row-title {
  display: block;
  font-weight: 600;
  color: #222;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-row-title:hover {
  color: #2563eb;
  text-decoration: underline;
}

.board-cell-name,
.board-cell-date,
.board-cell-views {
  white-space: nowrap;
  color: #6b7480;
  font-size: 13px;
}

.board-cell-views {
  text-align: center;
}

.board-title-count {
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
}

/* ---------- 게시판 댓글 ---------- */
.board-comments {
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  padding: 18px 24px;
  margin-bottom: 16px;
}

.board-comments h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.board-comment {
  padding: 12px 0;
  border-top: 1px solid #eef1f4;
}

.board-comment .gb-meta {
  margin-bottom: 4px;
}

.board-comment-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid #eef1f4;
}

.board-comment-form textarea {
  padding: 10px 12px;
  border: 1px solid #ccd2d9;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.board-comment-form textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.board-post {
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 16px;
}

#board-pagination {
  max-width: none;
}

.board-post h2 {
  margin: 0 0 10px;
  font-size: 22px;
  word-break: break-word;
}

.board-post-meta {
  padding-bottom: 14px;
  border-bottom: 1px solid #e9edf1;
  margin-bottom: 18px;
}

.gb-edit {
  margin-left: auto;
  border: none;
  background: none;
  color: #2563eb;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}

.gb-edit:hover {
  text-decoration: underline;
}

/* 수정 버튼이 먼저 우측으로 밀리므로 삭제 버튼은 그 옆에 붙인다 */
.board-post-meta .gb-delete {
  margin-left: 0;
}

/* ---------- Settings ---------- */
.settings-width-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-width-row input[type="range"] {
  flex: 1;
  accent-color: #3b82f6;
}

.settings-width-value {
  min-width: 110px;
  text-align: right;
  font-weight: 400;
  color: #4b5563;
  font-size: 13px;
  white-space: nowrap;
}

.settings-hint {
  margin: 0;
  line-height: 1.6;
}

/* ---------- 마크다운 본문 ---------- */
.md-body {
  font-size: 15px;
  line-height: 1.7;
  word-break: break-word;
}

.md-body h1,
.md-body h2,
.md-body h3,
.md-body h4 {
  margin: 1.2em 0 0.5em;
  line-height: 1.35;
}

.md-body h1:first-child,
.md-body h2:first-child,
.md-body h3:first-child,
.md-body p:first-child {
  margin-top: 0;
}

.md-body h1 { font-size: 24px; border-bottom: 1px solid #e9edf1; padding-bottom: 6px; }
.md-body h2 { font-size: 20px; }
.md-body h3 { font-size: 17px; }

.md-body p {
  margin: 0.6em 0;
}

.md-body a {
  color: #2563eb;
}

.md-body code {
  background: #f1f3f6;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 13px;
  font-family: "SF Mono", "D2Coding", Consolas, monospace;
}

.md-body pre {
  background: #1e2530;
  color: #e5e9ef;
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
}

.md-body pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.md-body blockquote {
  margin: 0.8em 0;
  padding: 4px 16px;
  border-left: 4px solid #cbd5e1;
  color: #55606c;
  background: #f8f9fb;
}

.md-body ul,
.md-body ol {
  padding-left: 1.6em;
  margin: 0.6em 0;
}

.md-body img {
  max-width: 100%;
  border-radius: 8px;
}

.md-body table {
  border-collapse: collapse;
  margin: 0.8em 0;
  display: block;
  overflow-x: auto;
}

.md-body th,
.md-body td {
  border: 1px solid #d7dce2;
  padding: 6px 12px;
}

.md-body th {
  background: #f1f3f6;
}

.md-body hr {
  border: none;
  border-top: 1px solid #e3e6ea;
  margin: 1.2em 0;
}

/* ---------- 자료실 ---------- */
.files-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 560px;
  margin-bottom: 28px;
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  padding: 18px;
}

.files-form input[type="text"] {
  padding: 10px 12px;
  border: 1px solid #ccd2d9;
  border-radius: 8px;
  font-size: 14px;
}

.files-form input[type="text"]:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.upload-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upload-progress-track {
  height: 10px;
  background: #e9edf1;
  border-radius: 5px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 5px;
  transition: width 0.2s ease;
}

.upload-progress-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #4b5563;
}

.upload-cancel {
  border: 1px solid #dc2626;
  background: none;
  color: #dc2626;
  font-size: 12px;
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.upload-cancel:hover {
  background: #fef2f2;
}

.file-entry {
  max-width: 560px;
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 12px;
}

.file-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-name {
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  word-break: break-all;
}

.file-name:hover {
  text-decoration: underline;
}

.file-size {
  color: #9aa3ad;
  font-size: 12px;
  white-space: nowrap;
}

.file-meta {
  margin: 6px 0 0;
}

.file-desc {
  margin-top: 8px;
  font-size: 14px;
  color: #4b5563;
}

.file-play {
  border: 1px solid #3b82f6;
  background: none;
  color: #3b82f6;
  font-size: 12px;
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.file-play:hover {
  background: #eff6ff;
}

/* ---------- 동영상 플레이어 모달 ---------- */
body.modal-open {
  overflow: hidden;
}

.player-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.player-box {
  width: min(960px, 100%);
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.player-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #fff;
}

.player-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-close {
  margin-left: auto;
  border: none;
  background: none;
  color: #cfd6e0;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}

.player-close:hover {
  color: #fff;
}

#player-video {
  display: block;
  width: 100%;
  max-height: 70vh;
  background: #000;
}

#player-image {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  margin: 0 auto;
  background: #000;
}

.file-preview {
  display: block;
  margin-top: 10px;
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid #e3e6ea;
  cursor: zoom-in;
}

/* ---------- 모바일 ---------- */
@media (max-width: 700px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: column;
    padding: 16px;
    /* 모바일(상단 배치)에서는 고정하지 않고 함께 스크롤 */
    position: static;
    height: auto;
    overflow-y: visible;
  }

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