:root {
  --text: #212529;
  --muted: #495057;
  --bg: #ffffff;
  --border: #eaeaea;
  --accent: #12b886;
  --accent-active: #20c997;
  --tag-bg: #f8f9fa;
  --max-width: 1120px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "system-ui", "Helvetica Neue", "Apple SD Gothic Neo",
    "Malgun Gothic", 나눔고딕, "Nanum Gothic", "Noto Sans KR", "Noto Sans CJK KR",
    arial, 돋움, Dotum, Tahoma, Geneva, sans-serif;
  line-height: 1.7;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* header */
.site-header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding: 28px 0;
  margin-bottom: 48px;
}
.site-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-header-profile {
  margin-top: 6px;
}
.site-header-profile .profile-bio {
  margin: 0 0 10px;
  color: var(--muted);
}
.site-header-profile .profile-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0;
  margin: 0;
  font-size: 14px;
}
.site-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
}
.mascot {
  height: 32px;
  width: auto;
  display: block;
  animation: mascot-waddle 0.7s ease-in-out infinite;
  transform-origin: 70% 100%;
}
@keyframes mascot-waddle {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-3px) rotate(6deg); }
}
@media (prefers-reduced-motion: reduce) {
  .mascot { animation: none; }
}
.site-nav {
  display: flex;
  gap: 24px;
}
.site-nav a {
  position: relative;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  padding-bottom: 4px;
}
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a.is-active {
  color: var(--accent-active);
}
.site-nav a.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 2px;
  background: var(--accent-active);
}

/* main */
main.wrap {
  flex: 1;
  padding-top: 0;
  padding-bottom: 64px;
}

.intro {
  margin-bottom: 40px;
  color: var(--muted);
}

/* tag filter (home) */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 32px 0 28px;
}
.tag-chip {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  height: 32px;
  padding: 0 16px;
  border-radius: 16px;
  border: none;
  background: var(--tag-bg);
  color: var(--accent);
  cursor: pointer;
}
.tag-chip.is-active {
  background: var(--accent);
  color: #fff;
}

/* home layout: tag sidebar + post list */
.home-layout {
  display: flex;
  align-items: flex-start;
  gap: 40px;
  margin-top: 32px;
}
.tag-sidebar {
  flex: 0 0 160px;
  width: 160px;
  position: sticky;
  top: 24px;
}
.tag-sidebar-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.tag-sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tag-sidebar-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  font-size: 14px;
  cursor: pointer;
}
.tag-sidebar-name { color: var(--text); }
.tag-sidebar-count { color: var(--muted); }
.tag-sidebar-item:hover .tag-sidebar-name { color: var(--accent); }
.tag-sidebar-item.is-active .tag-sidebar-name {
  color: var(--accent-active);
  font-weight: 600;
}
.home-main { flex: 1; min-width: 0; }

@media (max-width: 700px) {
  .home-layout { flex-direction: column; }
  .tag-sidebar {
    position: static;
    width: 100%;
  }
  .tag-sidebar-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
  }
}

/* post list */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
}
.post-item[hidden] { display: none; }
.post-item:first-child { padding-top: 0; }
.post-item-body { flex: 1; min-width: 0; }
.post-thumb {
  display: block;
  flex: 0 0 96px;
  width: 96px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--tag-bg);
}
.post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
@media (max-width: 500px) {
  .post-thumb { flex-basis: 72px; width: 72px; height: 72px; }
}
.post-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  display: block;
}
.post-date {
  font-size: 13px;
  color: var(--muted);
}
.post-excerpt {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}
.post-item .badge { margin-bottom: 8px; }
.post-item .post-tags { margin-top: 12px; }

/* single post */
.post {
  max-width: 960px;
  margin: 0 auto;
}
.post-header h1 {
  margin-bottom: 12px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.post-meta {
  color: var(--muted);
  font-size: 14px;
  margin-top: 0;
}
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.post-header .post-tags { margin-top: 14px; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  border-radius: 16px;
  background: var(--tag-bg);
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
}
.tag:hover { text-decoration: none; opacity: 0.85; }
.post-content h2 { font-size: 22px; margin-top: 40px; }
.post-content h3 { font-size: 18px; }
.post-content pre {
  background: #f6f6f6;
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 14px;
}
.post-content code {
  background: #f6f6f6;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
.post-content pre code { background: none; padding: 0; }
.post-content img { max-width: 100%; border-radius: 6px; }
.post-content blockquote {
  border-left: 3px solid var(--border);
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
}

/* profile */
.profile {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.profile h1 { margin-bottom: 4px; }
.profile-bio { color: var(--muted); margin-top: 0; }
.profile-links {
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
}
.profile-links li { margin-bottom: 8px; }

/* series / tags */
.badge {
  display: inline-flex;
  align-items: center;
  height: 28px;
  font-size: 13px;
  font-weight: 500;
  padding: 0 14px;
  border: none;
  border-radius: 14px;
  background: var(--tag-bg);
  color: var(--accent);
  margin-right: 6px;
}
.badge:hover { text-decoration: none; opacity: 0.85; }
.badge[hidden] { display: none; }
.series-list {
  list-style: none;
  padding: 0;
  margin: 32px 0 0;
}
.series-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-family: inherit;
  text-align: left;
  padding: 20px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}
.series-link:hover .series-name { color: var(--accent); }
.series-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.series-count {
  font-size: 13px;
  color: var(--muted);
}
.series-back-btn {
  font-family: inherit;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: 24px;
  cursor: pointer;
}
.series-back-btn:hover { color: var(--text); }

.group-section { margin-bottom: 40px; }
.group-title {
  font-size: 20px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.group-list { list-style: none; padding: 0; margin: 12px 0 0; }
.group-list li { padding: 8px 0; }
.group-list .post-date { margin-left: 8px; }

.tag-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}

.post-footer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 960px;
  margin: 32px auto 0;
}
.back-link {
  display: block;
  font-size: 14px;
  color: var(--muted);
}
.edit-link {
  font-size: 14px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
}
.edit-link:hover { color: var(--accent); text-decoration: none; }

/* write form */
.write-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 24px;
}
.write-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}
.write-form input,
.write-form textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.write-form textarea { resize: vertical; line-height: 1.6; }
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: -8px;
}
.chip-row .tag-chip { font-size: 12px; padding: 4px 10px; }
.req { color: #e11d48; }
.hint { color: var(--muted); font-size: 12px; }
.write-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.write-actions button {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
}
.write-actions button#copy-btn {
  background: transparent;
  color: var(--text);
}
#save-hint { margin-top: 4px; }


.gh-connect {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 28px;
}
.gh-connect summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.gh-connect .hint { margin: 12px 0; line-height: 1.6; }
.gh-connect .hint a { color: var(--accent); }
.gh-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.gh-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.gh-grid input {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.gh-remember {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 10px;
}
#gh-clear {
  font-family: inherit;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.gh-publish {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
.gh-publish:disabled {
  background: var(--border) !important;
  color: var(--muted) !important;
  border-color: var(--border) !important;
  cursor: not-allowed;
}
#gh-status { margin-top: 8px; }
#gh-auth-status { margin-top: 10px; }

/* post management */
.post-manage {
  max-width: 640px;
  margin: 56px 0 40px;
  border-top: 1px solid var(--border);
  padding-top: 32px;
}
.post-manage h2 { font-size: 20px; margin-bottom: 8px; }
#pm-load-btn {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  margin-top: 8px;
}
#pm-load-btn:disabled {
  color: var(--muted);
  cursor: not-allowed;
}
#pm-status { margin-top: 10px; }
.pm-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}
.pm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.pm-name { font-size: 14px; }
.pm-delete {
  font-family: inherit;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #e11d48;
  background: transparent;
  color: #e11d48;
  cursor: pointer;
  flex-shrink: 0;
}
.pm-delete:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.pm-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.pm-edit {
  font-family: inherit;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.pm-edit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* edit mode */
.edit-banner {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.edit-banner[hidden] { display: none; }
.edit-banner #edit-cancel-btn {
  font-family: inherit;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #92400e;
  background: transparent;
  color: #92400e;
  cursor: pointer;
  margin-left: auto;
}
.write-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}
@media (max-width: 860px) {
  .write-layout { grid-template-columns: 1fr; }
}

.editor-toolbar {
  margin-bottom: 8px;
}
.editor-toolbar button {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.write-preview-panel {
  position: sticky;
  top: 24px;
}
.preview-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 12px;
}
.preview-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.preview-card .post-header h1 { word-break: break-word; }
.preview-card .post-content img { margin: 12px 0; }

/* footer */
.site-footer {
  flex-shrink: 0;
  margin-top: 40px;
  border-top: 1px solid var(--border);
  padding: 24px 0 48px;
  color: var(--muted);
  font-size: 13px;
}
.site-footer .wrap {
  display: flex;
  gap: 16px;
  align-items: center;
}
.site-footer a { color: var(--muted); }

