:root {
  --bg: #f7f8fb;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --line: #e4e8f0;
  --line-soft: #edf1f7;
  --text: #111827;
  --heading: #050816;
  --muted: #7b8aa2;
  --accent: #6571ff;
  --accent-strong: #5661f6;
  --accent-soft: #eef0ff;
  --danger: #ff3366;
  --success: #05a660;
  --warning: #f59e0b;
  --shadow: 0 8px 18px rgba(18, 38, 63, 0.04);
  --radius: 4px;
  --sidebar-width: 240px;
  --topbar-height: 64px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    "Pretendard",
    "Apple SD Gothic Neo",
    "Malgun Gothic",
    system-ui,
    sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(101, 113, 255, 0.13), transparent 34%),
    var(--bg);
}

.auth-panel {
  width: min(440px, 100%);
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 45px rgba(18, 38, 63, 0.08);
  display: grid;
  gap: 22px;
}

.brand-block h1,
.logo {
  margin: 0;
  color: #00156e;
  font-size: 28px;
  line-height: 1;
  font-weight: 800;
}

.logo {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
}

.logo em {
  color: var(--accent);
  font-style: normal;
  font-weight: 500;
}

.brand-block p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #f9fbff;
}

.auth-tabs a {
  min-height: 42px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.auth-tabs a.active {
  color: #fff;
  background: var(--accent);
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(var(--sidebar-width), var(--sidebar-width)) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.side-head {
  height: var(--topbar-height);
  padding: 0 22px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.main-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-height);
  padding: 0 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 2px 12px rgba(18, 38, 63, 0.03);
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #7382a0;
  background: transparent;
  font-size: 18px;
}

.icon-btn:hover {
  border-color: var(--line);
  background: #f8faff;
}

.top-search {
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8a96ad;
}

.top-search input {
  width: 100%;
  height: 40px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-chip,
.lang-chip {
  height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  color: #52627c;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.avatar {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #8f9aff);
  font-weight: 700;
}

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

.nav-bottom {
  margin-top: auto;
  padding-bottom: 20px;
}

.nav-title {
  margin: 0 0 8px;
  color: #8492ad;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav-link {
  width: 100%;
  min-height: 36px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #111827;
  background: transparent;
  border-radius: var(--radius);
}

.nav-link span:first-child {
  min-width: 0;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  overflow: visible;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent);
}

.nav-link.active {
  position: relative;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 7px;
  width: 3px;
  height: 22px;
  background: var(--accent);
}

.nav-icon {
  width: 20px;
  min-width: 20px;
  display: inline-grid;
  place-items: center;
  color: currentColor;
  font-style: normal;
  font-size: 16px;
  line-height: 1;
}

.count {
  color: #94a0b8;
  font-size: 12px;
}

.user-chip {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.user-chip small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.logout-link {
  color: #64748b;
}

.content {
  min-width: 0;
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.breadcrumb {
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6b78ff;
  font-size: 13px;
}

.breadcrumb span,
.breadcrumb strong {
  color: var(--text);
  font-weight: 500;
}

.message {
  min-height: 42px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.message.error {
  color: var(--danger);
  border-color: #ffd2dd;
  background: #fff7fa;
}

.message.success {
  color: var(--success);
  border-color: #c8f3dc;
  background: #f5fff9;
}

.page-head {
  min-height: 78px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.page-title h2 {
  margin: 0;
  color: var(--heading);
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
}

.page-title p {
  margin: 8px 0 0;
  color: #6f7f99;
  line-height: 1.6;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.ghost-btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.primary-btn {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 4px 10px rgba(101, 113, 255, 0.22);
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.secondary-btn {
  color: var(--accent);
  background: #fff;
  border: 1px solid var(--accent);
}

.danger-btn {
  color: #fff;
  background: var(--danger);
}

.ghost-btn {
  color: #5d6b83;
  background: #fff;
}

.ghost-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.form-stack {
  display: grid;
  gap: 14px;
}

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

.field span {
  color: #5c6b83;
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.title-input,
.search-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  color: var(--text);
  background: #fff;
  padding: 0 12px;
}

.field textarea {
  padding-top: 10px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.title-input:focus,
.search-input:focus,
.editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(101, 113, 255, 0.12);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.board-tools {
  margin-bottom: 24px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-form {
  flex: 1;
}

.search-input {
  max-width: 420px;
}

.view-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-switch a {
  min-width: 72px;
  min-height: 36px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: #fff;
}

.view-switch a.active {
  color: #fff;
  background: var(--accent);
}

.table,
.admin-section,
.editor-shell,
.empty-state,
.post-content,
.attachments,
.post-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.table th,
.table td {
  padding: 15px 24px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.table th {
  color: #6f7f99;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  background: #fbfcff;
}

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

.table tbody tr {
  cursor: pointer;
}

.table tbody tr:hover {
  background: #fbfcff;
}

.admin-table tbody tr,
.admin-table tbody tr:hover {
  cursor: auto;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

.post-card {
  min-height: 270px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(18, 38, 63, 0.08);
}

.thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #f1f4fb;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 18px 20px;
  display: grid;
  gap: 10px;
}

.card-body h3 {
  margin: 0;
  color: var(--heading);
  font-size: 16px;
  line-height: 1.4;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f8;
  color: #66738a;
  font-size: 12px;
  font-weight: 700;
}

.badge.approved {
  color: var(--success);
  background: #e9fbf2;
}

.badge.pending {
  color: var(--warning);
  background: #fff8e8;
}

.badge.rejected {
  color: var(--danger);
  background: #fff0f5;
}

.empty-state {
  padding: 44px 24px;
  text-align: center;
  color: var(--muted);
}

.post-view {
  max-width: 980px;
}

.post-content {
  padding: 34px;
  color: #26364c;
  line-height: 1.82;
  overflow-wrap: anywhere;
}

.post-content img,
.editor img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.body-image-grid {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.body-image-grid figure {
  margin: 0;
}

.body-image-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #f1f4fb;
}

.body-image-grid figcaption {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.attachments {
  margin-top: 18px;
  padding: 20px 24px;
}

.share-panel {
  display: none;
  margin: -6px 0 20px;
  padding: 18px 24px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.share-panel.open {
  display: block;
}

.share-form,
.share-result {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.share-form .field {
  min-width: 180px;
}

.share-result {
  margin-top: 12px;
}

.share-result input {
  flex: 1;
  min-width: 260px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: #52627c;
  background: #fbfcff;
}

.attachments h3,
.admin-section h3 {
  margin: 0 0 16px;
  color: var(--heading);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

.attachment-list,
.existing-files {
  display: grid;
  gap: 9px;
}

.attachment-item,
.existing-file {
  min-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
}

.attachment-item:hover {
  border-color: #cfd6ff;
  background: #f7f8ff;
}

.file-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--accent);
  background: var(--accent-soft);
}

.file-thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #f1f4fb;
}

.file-name,
.existing-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size,
.existing-file small,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.editor-shell {
  max-width: 980px;
  overflow: hidden;
}

.editor-top {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
}

.title-input {
  min-height: 48px;
  padding: 0;
  border: 0;
  color: var(--heading);
  font-size: 24px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: #fbfcff;
}

.toolbar button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #5e6b84;
  background: transparent;
}

.toolbar button:hover {
  color: var(--accent);
  border-color: #d6dcff;
  background: var(--accent-soft);
}

.toolbar select,
.toolbar input[type="color"] {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.toolbar select {
  padding: 0 8px;
}

.toolbar input[type="color"] {
  width: 42px;
  padding: 3px;
}

.editor {
  min-height: 430px;
  padding: 28px 34px;
  outline: none;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.editor:empty::before {
  content: "내용을 작성하세요. 이미지 버튼으로 본문 중간에 이미지를 넣고, 아래에서 파일을 첨부할 수 있습니다.";
  color: var(--muted);
}

.file-panel {
  padding: 20px 24px;
  border-top: 1px solid var(--line-soft);
  background: #fbfcff;
}

.file-panel input[type="file"] {
  width: 100%;
  border: 1px dashed #c9d1e2;
  border-radius: var(--radius);
  background: #fff;
  padding: 13px;
}

.existing-files {
  margin-top: 12px;
}

.existing-file {
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  cursor: pointer;
}

.attachment-preview {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.preview-file {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "media name"
    "media size";
  align-items: center;
  gap: 2px 9px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.preview-file img,
.preview-file span {
  grid-area: media;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
}

.preview-file img {
  object-fit: cover;
  border: 1px solid var(--line);
}

.preview-file span {
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
}

.preview-file strong {
  grid-area: name;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.preview-file small {
  grid-area: size;
  color: var(--muted);
  font-size: 12px;
}

.editor-actions {
  padding: 16px 24px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(440px, 1.25fr);
  gap: 24px;
  align-items: start;
}

.admin-section {
  padding: 24px;
}

.board-list {
  margin-top: 20px;
}

.board-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line-soft);
}

.board-item:first-of-type {
  border-top: 0;
}

.setup-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.public-body {
  background: #fff;
}

.public-page {
  min-height: 100vh;
  padding: 72px 24px 120px;
}

.public-doc {
  width: min(720px, 100%);
  margin: 0 auto;
  color: #1f2937;
}

.public-kicker {
  margin-bottom: 18px;
  color: #6b78ff;
  font-size: 13px;
}

.public-doc h1 {
  margin: 0;
  color: #202124;
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.18;
  font-weight: 800;
}

.public-meta {
  margin-top: 12px;
  color: #8b95a7;
  font-size: 13px;
}

.public-content {
  margin-top: 34px;
  font-size: 16px;
  line-height: 1.9;
}

.public-content.only-content {
  margin-top: 0;
}

.public-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.public-files {
  margin-top: 46px;
  padding-top: 20px;
  border-top: 1px solid #eceff5;
}

.public-files h2 {
  margin: 0 0 14px;
  color: #202124;
  font-size: 16px;
}

.public-files a {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1f2937;
}

.public-files a:hover strong {
  color: var(--accent);
}

.public-files small {
  color: #8b95a7;
}

.public-error {
  width: min(620px, 100%);
  margin: 12vh auto 0;
  text-align: center;
}

.public-error h1 {
  color: #202124;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
  }

  .nav-group {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    padding: 12px 16px;
  }

  .nav-bottom,
  .nav-title,
  .user-chip {
    display: none;
  }

  .main-panel {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    position: static;
    padding: 10px 16px;
    flex-wrap: wrap;
    height: auto;
  }

  .top-actions {
    margin-left: 0;
  }

  .content {
    width: calc(100% - 28px);
    padding: 22px 0 40px;
  }

  .page-head,
  .board-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    justify-content: flex-start;
  }

  .search-input {
    max-width: none;
  }

  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 961px) {
  .sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
  }

  .nav-link {
    min-width: 0;
  }
}
