/* teknlaw blog — Medium-inspired design system */

/* ─── Reset / Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Pretendard', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #242424;
  background: #fff;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ─── Tokens ───────────────────────────────────────────────────────── */
:root {
  --fg: #242424;
  --fg-muted: #6B6B6B;
  --fg-light: #9B9B9B;
  --bg: #ffffff;
  --bg-soft: #FAFAFA;
  --border: #E6E6E6;
  --accent: #1A8917;          /* Medium green */
  --accent-soft: #E8F4E5;
  --link: #1f6feb;
  --shadow: 0 1px 3px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.08);
  --radius: 8px;
  --max-content: 1240px;
}

/* ─── Header ───────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.site-logo {
  font-family: 'Charter', 'Noto Serif KR', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -.5px;
}
.site-logo span { color: var(--accent); }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.btn-text {
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 99px;
}
.btn-text:hover { background: var(--bg-soft); }
.btn-primary {
  background: var(--fg);
  color: #fff;
  border: none;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 99px;
}
.btn-primary:hover { background: #000; }
.btn-ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 99px;
}
.btn-ghost:hover { border-color: var(--fg); }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ─── Layout ───────────────────────────────────────────────────────── */
.main-layout {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 36px 28px 80px;
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 40px;
}
@media (max-width: 1080px) {
  .main-layout { grid-template-columns: 200px 1fr; }
  .sidebar-right { display: none; }
}
@media (max-width: 760px) {
  .main-layout { grid-template-columns: 1fr; padding: 24px 16px 60px; gap: 24px; }
  .sidebar-left { order: 2; }
}

/* ─── Sidebar left (sectors) ───────────────────────────────────────── */
.sidebar-left h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg-light);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin: 0 0 12px;
}
.sector-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.sector-list a {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--fg);
  transition: background .12s;
}
.sector-list a:hover { background: var(--bg-soft); }
.sector-list a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 760px) {
  .sector-list { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .sector-list a { padding: 8px 14px; background: var(--bg-soft); font-size: 14px; border-radius: 99px; }
}

/* ─── Sidebar right (visitor stats) ────────────────────────────────── */
.stats-card {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
}
.stats-card h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.stat-item { }
.stat-label { font-size: 11px; color: var(--fg-light); text-transform: uppercase; letter-spacing: .8px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--fg); font-feature-settings: 'tnum'; margin-top: 2px; }
.stat-total {
  grid-column: 1 / -1;
  padding-top: 12px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}
.stat-total .stat-value { font-size: 28px; }

/* ─── Card feed ────────────────────────────────────────────────────── */
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .15s, box-shadow .15s;
  cursor: pointer;
  aspect-ratio: 4 / 5;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--border);
}
.card__body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
}
.card__sector {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .8px;
}
.card__title {
  font-family: 'Charter', 'Noto Serif KR', Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.3;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__excerpt {
  font-size: 14px;
  color: var(--fg-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.card--text .card__excerpt { -webkit-line-clamp: 5; }
.card__meta {
  font-size: 12px;
  color: var(--fg-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}
.card__meta__stat { display: inline-flex; gap: 4px; align-items: center; }

.card--text { background: linear-gradient(180deg, #fafaf7, #fff); }

/* 무한스크롤 sentinel */
.feed-end { text-align: center; padding: 30px; color: var(--fg-light); font-size: 13px; }

/* ─── Post page ────────────────────────────────────────────────────── */
.post-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 28px 80px;
}
.post-page h1 {
  font-family: 'Charter', 'Noto Serif KR', Georgia, serif;
  font-size: 42px;
  line-height: 1.2;
  margin: 0 0 18px;
}
.post-page .post-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--fg-muted);
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.post-page .post-meta .citation {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.post-page .canonical-link {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--fg-muted);
  background: var(--bg-soft);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  user-select: all;
}

/* ─── Reader (StPageFlip 모달) ─────────────────────────────────────── */
.reader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,20,20,.92);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.reader-overlay.open { display: flex; }
.reader-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  padding: 16px 24px;
  gap: 14px;
  color: #fff;
}
.reader-top h2 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-top button {
  background: rgba(255,255,255,.1);
  color: #fff;
  border: none;
  border-radius: 99px;
  padding: 8px 14px;
  font-size: 13px;
}
.reader-top button:hover { background: rgba(255,255,255,.2); }
.reader-close { width: 36px; height: 36px; padding: 0 !important; font-size: 18px !important; }

#flipbook-host {
  position: relative;
  width: min(92vw, 1100px);
  height: min(78vh, 700px);
}
.reader-bottom {
  position: absolute;
  bottom: 16px; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #ccc;
  font-size: 13px;
}
.reader-bottom button {
  background: rgba(255,255,255,.1);
  color: #fff;
  border: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 18px;
}
.reader-bottom button:hover { background: rgba(255,255,255,.2); }
.page-indicator { font-feature-settings: 'tnum'; }

/* StPageFlip 페이지 콘텐츠 */
.flip-page {
  background: #fffbf6;
  padding: 40px 44px;
  font-family: 'Charter', 'Noto Serif KR', Georgia, serif;
  font-size: 16px;
  line-height: 1.75;
  color: #2a2a2a;
  overflow: hidden;
}
.flip-page h1, .flip-page h2, .flip-page h3 { font-family: inherit; }
.flip-page h1 { font-size: 28px; margin-bottom: 16px; }
.flip-page h2 { font-size: 22px; margin: 24px 0 12px; }
.flip-page h3 { font-size: 18px; margin: 20px 0 10px; }
.flip-page p { margin: 0 0 14px; }
.flip-page img { display: block; margin: 18px auto; max-width: 100%; border-radius: 4px; }
.flip-page blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--fg-muted);
  font-style: italic;
}
.flip-page code {
  background: #f0eee5;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 14px;
}
.flip-page mark[data-hl] {
  background: rgba(255, 234, 0, .55);
  padding: 0 2px;
  border-radius: 2px;
  cursor: pointer;
}
.flip-page mark[data-hl][data-color="green"] { background: rgba(133,234,140,.5); }
.flip-page mark[data-hl][data-color="blue"]  { background: rgba(140,200,255,.5); }
.flip-page mark[data-hl][data-color="pink"]  { background: rgba(255,170,200,.55); }
.page-foot {
  position: absolute;
  bottom: 14px; left: 44px; right: 44px;
  font-size: 11px;
  color: var(--fg-light);
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #ebe6dc;
  padding-top: 8px;
}

/* 하이라이트 팝오버 */
.hl-popover {
  position: fixed;
  z-index: 1100;
  background: #1f1f1f;
  color: #fff;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.hl-popover button {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 4px;
}
.hl-popover button:hover { background: rgba(255,255,255,.1); }
.hl-color-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
}
.hl-color-dot:hover { border-color: #fff; }
.hl-color-dot.yellow { background: #fde047; }
.hl-color-dot.green  { background: #86efac; }
.hl-color-dot.blue   { background: #93c5fd; }
.hl-color-dot.pink   { background: #f9a8d4; }

/* 우측 사이드 패널 (편집 제안 / 댓글) */
.side-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  background: #fff;
  z-index: 1200;
  box-shadow: -8px 0 32px rgba(0,0,0,.15);
  transform: translateX(100%);
  transition: transform .25s;
  display: flex;
  flex-direction: column;
}
.side-panel.open { transform: translateX(0); }
.side-panel header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.side-panel header h3 { margin: 0; font-size: 16px; flex: 1; }
.side-panel header button {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--fg-muted);
}
.side-panel .body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
}
.side-panel textarea {
  width: 100%;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 120px;
  resize: vertical;
}
.side-panel .anchor-quote {
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--fg-muted);
  margin-bottom: 14px;
}
.side-panel footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
@media (max-width: 580px) {
  .side-panel { width: 100%; }
}

/* 댓글 */
.comment-list { display: flex; flex-direction: column; gap: 18px; }
.comment {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.comment__head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-muted); margin-bottom: 6px; }
.comment__head .nick { color: var(--fg); font-weight: 600; }
.comment__body { font-size: 14px; line-height: 1.55; color: var(--fg); white-space: pre-wrap; }
.comment__actions { display: flex; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--fg-muted); }
.comment__actions button { background: transparent; border: none; color: var(--fg-muted); font-size: 12px; padding: 2px 6px; }
.comment__actions button:hover { color: var(--fg); }
.comment__actions button.liked { color: var(--accent); }

/* ─── 로그인 모달 ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: min(90vw, 420px);
  padding: 32px 28px;
  text-align: center;
  position: relative;
}
.modal h2 { margin: 0 0 6px; font-size: 22px; }
.modal p.modal-sub { margin: 0 0 22px; color: var(--fg-muted); font-size: 14px; }
.modal .oauth-buttons { display: flex; flex-direction: column; gap: 10px; }
.oauth-btn {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--fg);
}
.oauth-btn:hover { background: var(--bg-soft); }
.oauth-btn--kakao { background: #fee500; border-color: #fee500; }
.oauth-btn--kakao:hover { background: #ffd900; }
.oauth-btn--naver { background: #03c75a; border-color: #03c75a; color: #fff; }
.oauth-btn--naver:hover { background: #02b452; }
.oauth-btn--apple { background: #000; border-color: #000; color: #fff; }
.modal .close-x {
  position: absolute;
  top: 14px; right: 14px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--fg-muted);
}

/* ─── Buttons (share / cite) ──────────────────────────────────────── */
.share-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 0; }
.share-btn {
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.share-btn:hover { background: var(--bg-soft); }
.share-btn--kakao { background: #fee500; border-color: #fee500; }
.share-btn--copy.copied { background: var(--accent-soft); color: var(--accent); }

/* ─── Admin ────────────────────────────────────────────────────────── */
.admin-shell { max-width: 1240px; margin: 0 auto; padding: 30px 28px 60px; display: grid; grid-template-columns: 220px 1fr; gap: 40px; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav button {
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--fg);
  font-size: 14px;
}
.admin-nav button:hover { background: var(--bg-soft); }
.admin-nav button.active { background: var(--fg); color: #fff; font-weight: 600; }
.admin-section { display: none; }
.admin-section.active { display: block; }
.admin-section h2 { font-size: 22px; margin: 0 0 18px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--fg); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.field textarea { min-height: 320px; line-height: 1.6; font-family: 'Charter', 'Noto Serif KR', Georgia, serif; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.admin-table th { font-weight: 600; color: var(--fg-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.admin-table tr:hover { background: var(--bg-soft); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge--published { background: var(--accent-soft); color: var(--accent); }
.badge--draft { background: #fef3c7; color: #92400e; }
.badge--archived { background: #f3f4f6; color: var(--fg-muted); }

.suggestion-card { border: 1px solid var(--border); border-radius: 8px; padding: 18px; margin-bottom: 16px; }
.suggestion-card .anchor { background: var(--bg-soft); padding: 10px; border-radius: 4px; font-size: 13px; color: var(--fg-muted); margin-bottom: 10px; }
.suggestion-card .suggested { background: #fff7e8; padding: 10px; border-radius: 4px; font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
.suggestion-card .meta { font-size: 12px; color: var(--fg-light); margin-bottom: 10px; }
.suggestion-card .actions { display: flex; gap: 8px; }

@media (max-width: 760px) {
  .admin-shell { grid-template-columns: 1fr; gap: 20px; padding: 20px 16px 40px; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; }
}

/* ─── Toast ────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%);
  background: #1f1f1f;
  color: #fff;
  padding: 12px 20px;
  border-radius: 99px;
  font-size: 14px;
  z-index: 3000;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ─── Scrollbar (subtle) ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.3); }
