:root {
  --bg: #ececec;
  --sidebar-bg: rgba(250, 250, 250, 0.85);
  --content-bg: #ffffff;
  --text: rgba(0, 0, 0, 0.85);
  --text-secondary: rgba(0, 0, 0, 0.6);
  --muted: rgba(0, 0, 0, 0.4);
  --border: rgba(0, 0, 0, 0.12);
  --active: #0068ed;
  --active-bg: rgba(0, 104, 237, 0.10);
  --sidebar-width: 250px;
  --font: "Aspekta", "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

.screen_out {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ── Layout ── */

#wrap {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#sidebar .blank { display: none; }

.sidebar-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  padding-bottom: 0.1rem;
}

.traffic-lights {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.15rem 0;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.red    { background: rgb(255, 92, 95); }
.dot.yellow { background: rgb(250, 200, 0); }
.dot.green  { background: rgb(52, 199, 89); }

#sidebar h1 {
  font-size: 0.92rem;
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

#sidebar h1 a {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* ── Widgets ── */

.widget-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.5rem 0.25rem;
}

.widget {
  display: flex;
  flex-direction: column;
}

/* Hide widgets that have nothing to show */
.widget:not(.category):not(.counter):not(.search):has(> ul:empty) {
  display: none;
}

.widget > ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.widget > ul > li > a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.86rem;
  color: var(--text);
  transition: background 0.1s;
}

.widget > ul > li > a svg {
  color: var(--muted);
  flex-shrink: 0;
}

.widget > ul > li > a:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Counter widget */

.widget.counter {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
  padding: 0.35rem 0.5rem;
  border-top: 1px solid var(--border);
  letter-spacing: 0.02em;
}

.widget.counter .today {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Search widget — Finder pill style ── */

.widget.search {
  width: 100%;
  position: relative;
}

.widget.search::before {
  content: '';
  position: absolute;
  left: 0.62rem;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  /* SVG magnifier icon as data URI */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='16.5' y1='16.5' x2='22' y2='22'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  z-index: 1;
}

input.search,
.widget.search input {
  width: 100%;
  padding: 0.36rem 0.75rem 0.36rem 1.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

input.search:focus,
.widget.search input:focus {
  border-color: var(--active);
  background: #fff;
}

input.search::placeholder,
.widget.search input::placeholder {
  color: var(--muted);
}

/* ── New post button ── */

.new-post-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  background: var(--active);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.12s, transform 0.05s;
}

.new-post-btn svg {
  flex-shrink: 0;
}

.new-post-btn:hover {
  background: #0058c8;
}

.new-post-btn:active {
  transform: translateY(1px);
}

/* ── Category home link ── */

.category-home-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.86rem;
  color: var(--text);
  transition: background 0.1s;
  margin-bottom: 2px;
}

.category-home-link::before {
  content: '';
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  flex-shrink: 0;
}

.category-home-link:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* ── Tistory category tree (.tt_category) — Finder-styled ── */

.tt_category,
.tt_category *,
.tt_category li,
.tt_category li a,
.tt_category li a span {
  background-image: none !important;
  list-style: none;
}

.tt_category img { display: none !important; }

.tt_category .c_fold,
.tt_category .btn_fold { display: none !important; }

.tt_category {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Always expanded */
.tt_category li > ul {
  display: flex !important;
  flex-direction: column;
  gap: 1px;
  margin-top: 1px;
}

.tt_category li a {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  font-size: 0.86rem;
  color: var(--text);
  transition: background 0.1s;
}

/* Hide "분류 전체보기" root label */
.tt_category > li > a.link_tit {
  display: none !important;
}

/* folder icon — parent categories (class added by main.js) */
.tt_category li.cat-parent > a:not(.link_tit)::before {
  content: '';
  display: inline-block;
  width: 0.9rem;
  height: 0.82rem;
  background-image: url('./images/folder.png');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  flex-shrink: 0;
  vertical-align: middle;
}

/* folder icon — leaf items */
.tt_category li.cat-leaf > a:not(.link_tit)::before {
  content: '';
  display: inline-block;
  width: 0.9rem;
  height: 0.82rem;
  background-image: url('./images/folder.png');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Only indent subcategories (2nd level and deeper), not top-level categories */
.tt_category > li > ul > li > ul li > a {
  padding-left: 1.35rem;
}

/* Hide Tistory's injected icon spans */
.tt_category li a > span:not(.c_cnt):not(.c_name) {
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  padding: 0 !important;
  margin: 0 !important;
  font-size: 0 !important;
}

.tt_category li a:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Active state — full-width pill highlight */
.tt_category li.selected > a {
  color: var(--active);
  background: var(--active-bg);
  border-color: transparent;
}

.tt_category .c_cnt {
  font-size: 0.73rem;
  color: var(--muted);
  margin-left: auto;
}

/* ── Main content ── */

#content {
  grid-column: 2;
  padding: 1.5rem;
  min-height: 100vh;
}

.content-box {
  background: var(--content-bg);
  border: 1px solid var(--border);
  border-radius: 1.8rem;
  padding: 3rem;
  min-height: calc(100vh - 2rem);
}

/* ── Post grid — Finder icon view ── */

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 2rem 1.75rem;
}

.post-icon {
  display: contents;
}

.post-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  cursor: pointer;
  width: 100%;
  max-width: 120px;
  margin: 0 auto;
}

.post-card:hover .post-thumb {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
}

.post-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: #e0e0e0 url('./images/about.png') center / 55% no-repeat;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.post-meta {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.post-title {
  font-size: 0.75rem;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  width: 100%;
  line-height: 1.35;
  word-break: break-word;
}

.post-date {
  font-size: 0.68rem;
  color: var(--muted);
}

/* ── Single post ── */

.post-full {
  display: none;
  width: 100%;
  max-width: none;
}

body#tt-body-page .post-card { display: none; }
body#tt-body-page .post-full { display: block; }
body#tt-body-page .post-grid { display: block; }

.back-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.82rem;
  color: var(--active);
  margin-bottom: 1.5rem;
  transition: opacity 0.1s;
}

.back-link:hover {
  opacity: 0.75;
}

.article-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.article-title {
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.article-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.article-body {
  width: 100%;
  max-width: none;
  font-size: 0.97rem;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 2rem;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
}

.article-body p {
  margin-bottom: 1rem;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  margin-top: 1.75rem;
  margin-bottom: 0.6rem;
  line-height: 1.3;
}

.article-body pre {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.article-body code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.article-body blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* ── Tags ── */

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.tag {
  display: inline-block;
  padding: 0.22rem 0.6rem;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  font-size: 0.77rem;
  color: var(--text-secondary);
  transition: background 0.1s;
}

.tag:hover {
  background: rgba(0, 0, 0, 0.11);
}

/* ── Pagination ── */

.pagination {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.page-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 0.4rem;
  border-radius: 0.4rem;
  font-size: 0.83rem;
  color: var(--text-secondary);
  transition: background 0.1s;
}

.page-num:hover {
  background: rgba(0, 0, 0, 0.07);
}

.page-num.on,
.page-num[aria-current="page"] {
  color: var(--active);
  background: var(--active-bg);
  font-weight: 500;
}

/* ── Mobile header ── */

.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--sidebar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 0 0 1.4rem 1.4rem;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
  z-index: 200;
}

.mobile-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  transition: color 0.15s;
}

.hamburger:hover {
  color: var(--text);
}

/* ── Sidebar overlay (mobile) ── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 99;
}

body.sidebar-open .sidebar-overlay {
  display: block;
}

/* ── Mobile responsive ── */

@media (max-width: 768px) {
  #wrap {
    grid-template-columns: 1fr;
  }

  .mobile-header {
    display: flex;
  }

  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  body.sidebar-open #sidebar {
    transform: translateX(0);
  }

  #content {
    grid-column: 1;
    padding: 0.5rem;
    min-height: auto;
  }

  .content-box {
    border-radius: 1rem;
    padding: 1.75rem;
    min-height: auto;
  }

  .post-grid {
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    gap: 2rem 1.75rem;
  }

  .post-full {
    max-width: 100%;
  }

  .article-title {
    font-size: 1.35rem;
  }
}
