/* ===== Variables ===== */
:root {
  --primary: #1a2b4a;
  --primary-hover: #243d6a;
  --accent: #2e6fda;
  --accent-hover: #1f5abf;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dde1e9;
  --text-primary: #1a2035;
  --text-secondary: #5a6478;
  --text-muted: #9199ab;
  --danger: #c0392b;
  --danger-hover: #a93226;
  --success: #27ae60;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --radius: 6px;
  --font: 'Segoe UI', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }

/* ===== Header ===== */
.header {
  background: var(--primary);
  color: #fff;
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
}
.header-logo svg { opacity: 0.85; }
.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.header-nav a {
  color: rgba(255,255,255,0.75);
  font-size: 0.93rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.header-nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ===== Layout ===== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ===== Page Title ===== */
.subtitle {
  font-size:1rem;
  font-weight:500;
  letter-spacing:0.05em;
  opacity:0.75;
  border-left:1px solid rgba(255,255,255,0.3);
  padding-left:0.6rem;
  margin-left:0.1rem;
}
.subtitle-desc {
  font-size: 0.8rem;
  color: #417ad4;
  font-weight: 500;
  margin-top: 0.1rem;
  margin-left: 0.1rem;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--primary);
}
.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.page-title-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.5rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-sm); }
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); color: var(--text-primary); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

.board-title-sub {
  padding: 0 0 0.5rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.5rem;
}
/* ===== Board Table ===== */
.board-table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.board-table {
  width: 100%;
  border-collapse: collapse;
}
.board-table thead {
  background: #f0f3f8;
}
.board-table th {
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: left;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.board-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.93rem;
  vertical-align: middle;
}
.board-table tbody tr:last-child td { border-bottom: none; }
.board-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}
.board-table tbody tr:hover { background: #f7f9fc; }
.board-table .col-num { width: 60px; color: var(--text-muted); text-align: center; }
.board-table .col-title { font-weight: 500; color: var(--text-primary); }
.board-table .col-title:hover { color: var(--accent); }
.board-table .col-author { width: 110px; color: var(--text-secondary); }
.board-table .col-date { width: 130px; color: var(--text-muted); font-size: 0.85rem; }
.board-table .col-img { width: 60px; text-align: center; }

.img-badge {
  display: inline-block;
  background: #e8f0fe;
  color: var(--accent);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state svg { opacity: 0.3; margin-bottom: 0.75rem; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1.5rem;
}
.pagination button {
  min-width: 34px;
  height: 34px;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: var(--radius);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.12s;
}
.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ===== Post Detail ===== */
.post-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.post-header {
  padding: 1.5rem 1.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.post-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.75rem;
}
.post-meta {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.post-meta span { display: flex; align-items: center; gap: 0.3rem; }
.post-body {
  padding: 1.75rem;
  min-height: 200px;
  font-size: 0.97rem;
  line-height: 1.85;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}
.post-image-wrap {
  padding: 1.5rem 1.75rem 1.5rem;
}
.post-image-wrap img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ===== Image Processing ===== */
.img-process-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.img-process-wrap img {
  display: block;
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: filter 0.6s ease, opacity 0.6s ease;
}
.img-processing {
  filter: blur(3px) brightness(0.85);
  opacity: 0.7;
}
.img-processed {
  filter: none;
  opacity: 1;
}
.img-process-status {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  z-index: 2;
  transition: background 0.3s, color 0.3s;
}
.img-process-status.idle {
  background: rgba(46, 111, 218, 0.88);
  color: #fff;
  cursor: pointer;
  user-select: none;
}
.img-process-status.idle:hover {
  background: rgba(31, 90, 191, 0.95);
}
.img-process-status.processing {
  background: rgba(26, 43, 74, 0.78);
  color: #fff;
  cursor: default;
}
.img-process-status.done {
  background: rgba(39, 174, 96, 0.90);
  color: #fff;
  cursor: default;
}
.img-process-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.post-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.75rem;
  border-top: 1px solid var(--border);
  background: #fafbfd;
}

/* ===== Write Form ===== */
.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 2rem;
}
.form-group {
  margin-bottom: 1.25rem;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-input,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: #fafbfd;
  transition: border 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46,111,218,0.12);
  background: #fff;
}
.form-textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.7;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ===== Image Upload ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #fafbfd;
  position: relative;
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: #eef3fd;
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-zone-text {
  pointer-events: none;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.upload-zone-text svg { display: block; margin: 0 auto 0.5rem; opacity: 0.4; }
.upload-zone-text strong { color: var(--accent); }

.image-preview-wrap {
  margin-top: 1rem;
  display: none;
}
.image-preview-wrap.show { display: block; }
.image-preview {
  position: relative;
  display: inline-block;
}
.image-preview img {
  max-height: 200px;
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.image-preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  line-height: 1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Sidebar Layout ===== */
.app-layout {
  display: flex;
  min-height: calc(100vh - 56px);
}
.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
}
.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 1rem;
  margin-bottom: 0.35rem;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  border-right: 2px solid transparent;
}
.sidebar-nav-item svg { flex-shrink: 0; opacity: 0.65; }
.sidebar-nav-item:hover {
  background: #f0f3f8;
  color: var(--primary);
}
.sidebar-nav-item:hover svg { opacity: 1; }
.sidebar-nav-item.active {
  color: var(--accent);
  background: rgba(46, 111, 218, 0.07);
  font-weight: 600;
  border-right-color: var(--accent);
}
.sidebar-nav-item.active svg { opacity: 1; }
.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.75rem 1rem;
}
.sidebar-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.sidebar-checkbox-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.main-content {
  flex: 1;
  min-width: 0;
}

/* ===== Admin Page ===== */
.index-desc-image-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1rem;
  margin-bottom: 1.5rem;
}
.admin-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1rem;
  margin-bottom: 1.5rem;
}
.admin-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.apikey-info {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}
.apikey-info-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.92rem;
}
.apikey-info-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  min-width: 80px;
}
.apikey-info-value {
  color: var(--text-primary);
  font-weight: 500;
}
.apikey-empty {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
}
.key-warning-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 3px;
  cursor: default;
  position: relative;
  white-space: nowrap;
  flex-shrink: 0;
}
.key-warning-badge svg { flex-shrink: 0; }
.key-warning-badge::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}
.key-warning-badge::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #333;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}
.key-warning-badge:hover::after,
.key-warning-badge:hover::before { opacity: 1; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  margin: 1rem;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.25rem;
}
.err-modal-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--danger);
}
.err-modal-msg {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}
.modal-key-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f4f6f9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.6rem;
}
.modal-key-value {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 0.87rem;
  color: var(--text-primary);
  word-break: break-all;
  user-select: all;
}
.modal-notice {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
}

/* ===== Count Table ===== */
.count-table tbody tr { cursor: default; }
.count-table tbody tr:hover { background: transparent; }
.count-result-header { text-align: right; }
.count-result-cell {
  text-align: right;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .container { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .board-table .col-author,
  .board-table .col-img { display: none; }
  .sidebar { width: 160px; }
}

/* ===== Hyper Link ===== */
a:link, a:visited {
  color: #333333;
}

a:hover {
  color: #0066cc;
}

.underline-link {
  text-decoration: underline;
}