:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6d6a64;
  --line: #e4e1db;
  --accent: #1c1b19;
  --accent-text: #ffffff;
  --chip: #eeebe5;
  --danger: #c43d2f;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1d1c1a;
    --text: #ecebe7;
    --muted: #9b978f;
    --line: #2e2c29;
    --accent: #ecebe7;
    --accent-text: #141413;
    --chip: #2a2825;
    --danger: #ef6f60;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* 상단 */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.logo { font-weight: 800; font-size: 18px; text-decoration: none; letter-spacing: -.02em; white-space: nowrap; }
.search { flex: 1; min-width: 0; }
.search input {
  width: 100%; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.search input:focus { border-color: var(--muted); }
.me { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.me .avatar { width: 30px; height: 30px; }

/* 버튼 */
.btn {
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }

/* 이용 안내 (맨 위) */
.terms {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 20px; font-size: 14px; line-height: 1.65;
  word-break: keep-all; overflow-wrap: anywhere; /* 한국어를 단어 중간에서 자르지 않음 */
}
.terms h2 { margin: 0 0 6px; font-size: 15px; letter-spacing: -.01em; }
.terms p { margin: 0 0 6px; }
.terms ul { margin: 0 0 8px; padding-left: 20px; }
.terms li { margin: 2px 0; }
.terms strong { color: var(--danger); }
.terms .terms-ban { margin: 0; font-weight: 600; }

/* 분류 탭 */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab {
  flex: none; padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }

/* 탭별 안내 상자 */
.box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 18px; margin-bottom: 20px; font-size: 14px; line-height: 1.6; word-break: keep-all;
}
.box p { margin: 0; }
.box code { background: var(--chip); border-radius: 6px; padding: 1px 6px; font-size: 13px; }
/* 에셋 하위 탭 */
.subtabs { display: flex; gap: 6px; margin: -6px 0 16px; }
.subtab {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.subtab[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.box.warn { border-color: var(--danger); }
.box.warn > p:first-child { font-weight: 600; }
.unlock { display: flex; gap: 8px; margin-top: 10px; max-width: 360px; }
.unlock input, .fmt-row input {
  flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: inherit; font: inherit; outline: none;
}
.unlock input:focus, .fmt-row input:focus { border-color: var(--muted); }
.box .err { margin: 8px 0 0; }
#adultLock { margin-top: 10px; }
/* OOC 표기 고르기 */
.fmt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 10px; }
.fmt-row .lbl { font-weight: 600; min-width: 72px; }
.fmt-row input { flex: 1 1 160px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  color: inherit; font: inherit; font-size: 13px; cursor: pointer;
}
.seg button.code { font-family: ui-monospace, Consolas, monospace; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.names-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; margin-bottom: 8px; }
.names-row label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; flex: 1 1 180px; }
.names-row .lbl { display: flex; align-items: center; gap: 6px; }
.names-row input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  color: inherit; font: inherit; font-weight: 400; outline: none; width: 100%;
}
.names-row input:focus { border-color: var(--muted); }
.box .hint { color: var(--muted); font-size: 13px; }
.form select {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: inherit; font: inherit;
}

.filter { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; color: var(--muted); }
.notice {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin: 0 0 16px;
}

/* 카드 */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .12s;
}
.card:hover { transform: translateY(-2px); }
.card .thumb { aspect-ratio: 4 / 3; background: var(--chip); }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .inner { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { margin: 0; font-size: 16px; line-height: 1.35; letter-spacing: -.01em; }
.card .preview {
  margin: 0; color: var(--muted); font-size: 13.5px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap; word-break: break-word;
}
.card .foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: var(--chip); border: 0; border-radius: 999px;
  padding: 2px 10px; font-size: 12.5px; cursor: pointer;
}
.tag:hover { outline: 1px solid var(--muted); }

.author { display: flex; align-items: center; gap: 8px; min-width: 0; text-decoration: none; }
.author:hover .name { text-decoration: underline; }
.author .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.author .name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.author .handle { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: var(--chip); flex: none; }

.count { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.count:empty { display: none; }
.dlg.narrow { width: min(400px, calc(100vw - 32px)); }
.view-head h2 { margin: 0; }

.empty, .more { text-align: center; color: var(--muted); margin-top: 24px; }

/* 다이얼로그 */
.dlg {
  border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text);
  width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
}
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg-body { padding: 22px; }
.dlg h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: -.01em; }
.dlg .sub { color: var(--muted); margin: -6px 0 14px; font-size: 14px; }

.view-img { width: 100%; border-radius: 12px; display: block; margin-bottom: 16px; }
/* 이미지 저장 막기: 모바일 길게 누르기 메뉴·선택 끄기 */
.thumb img, .view-img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
.view-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.view-text {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; white-space: pre-wrap; word-break: break-word;
  font-size: 14px; max-height: 50vh; overflow: auto; margin: 12px 0;
}
.view-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.view-actions .left, .view-actions .right { display: flex; gap: 8px; flex-wrap: wrap; }
.date { color: var(--muted); font-size: 12.5px; }

/* 폼 */
.form label, .form .lbl { display: block; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.form small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.form input:not([type=file]), .form textarea {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); outline: none; resize: vertical;
}
.form input:focus, .form textarea:focus { border-color: var(--muted); }
/* 비밀번호 보기 (눈 모양). 가려진 상태면 사선이 그어져 있음 */
.pw { position: relative; display: block; }
.pw input { padding-right: 44px !important; }
.pw-eye { position: absolute; right: 4px; top: calc(50% + 3px); transform: translateY(-50%); width: 36px; height: 36px;
  display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 8px; }
.pw-eye:hover { color: inherit; }
.pw-eye.on .pw-slash { display: none; }
.imgfield { margin-bottom: 14px; }
.imgfield .lbl { margin-bottom: 6px; }
.imgbox {
  position: relative; border: 1.5px dashed var(--line); border-radius: 12px;
  min-height: 120px; display: grid; place-items: center; overflow: hidden;
  color: var(--muted); font-size: 14px; background: var(--bg);
}
.imgbox.drag { border-color: var(--muted); }
.imgbox img { max-width: 100%; max-height: 260px; display: block; }
.imgbox input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.imgmeta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; color: var(--muted); font-size: 13px; min-height: 28px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.err { color: var(--danger); font-size: 14px; margin: 0 0 10px; }

.banadd { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.banadd input { flex: 1 1 140px; margin: 0 !important; }
.banlist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.banlist li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.banlist .reason { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--accent); color: var(--accent-text); padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .top-inner { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; }
  .me { margin-left: auto; }
  .dlg-body { padding: 16px; }
}

/* hidden 속성이 .btn 의 display 에 덮여서 '더 보기'가 글이 없어도 보이던 문제 */
[hidden] { display: none !important; }
