:root {
  --bg: #0f1013;
  --panel: #17191e;
  --panel-2: #1e2128;
  --line: #2a2e37;
  --text: #e8e9ec;
  --muted: #8b909c;
  --accent: #7fd1b9;
  --accent-ink: #0f1013;
  --warn: #f2b56b;
  --danger: #ef6f6c;
  --radius: 10px;
  font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; font-size: 14px; line-height: 1.5; }
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 로그인 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px 24px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: .02em; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); }
.login-card input[type=password] { width: 100%; font-size: 18px; letter-spacing: .3em; text-align: center; }
.login-card label.check { display: flex; gap: 8px; align-items: center; margin: 14px 0; color: var(--muted); }
.login-card button { width: 100%; padding: 10px; }
.error { color: var(--danger); min-height: 1.5em; margin-top: 10px; font-size: 13px; }

/* 메인 */
header.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: rgba(15,16,19,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
header.top .brand { font-weight: 700; letter-spacing: .03em; }
header.top .brand span { color: var(--accent); }
header.top .spacer { flex: 1; }
header.top .device { display: flex; align-items: center; gap: 6px; color: var(--muted); }

/* Gumroad처럼 왼쪽 필터 + 오른쪽 카드 그리드 */
.layout {
  max-width: 1180px; margin: 0 auto; padding: 24px 16px;
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start;
}
.side { position: sticky; top: 72px; }
.side-box { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.side-row { padding: 12px; border-top: 1px solid var(--line); display: block; }
.side-row:first-child { border-top: none; }
.side-row.count { color: var(--muted); font-size: 13px; }
.side-row input[type=search] { width: 100%; }
.side-row.select { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); }
.side-row.select select { flex: 1; min-width: 0; }
.seg { display: flex; gap: 0; }
.seg button { flex: 1; border-radius: 0; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; border-left: none; }
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
input[type=search] { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.content { min-width: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.card:hover, .card:focus-visible {
  transform: translate(-3px, -3px); border-color: var(--accent);
  box-shadow: 3px 3px 0 var(--accent); outline: none;
}
.card .thumb { aspect-ratio: 1 / 1; background: var(--panel-2); border-bottom: 1px solid var(--line); position: relative; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: auto; }
.thumb .ext {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 700; letter-spacing: .08em; color: var(--muted); font-size: 18px;
}
.thumb .ext small { display: block; font-size: 11px; font-weight: 500; letter-spacing: 0; margin-top: 4px; text-align: center; }
.thumb.blend .ext { color: #f0a35e; }
/* 블렌더 미리보기는 128px에 배경이 투명 → 은은한 배경 위에 가운데로 */
.thumb.blend, .thumb.folder { background: radial-gradient(circle at 50% 42%, #2c313b 0%, #1b1e24 70%); }
.thumb.blend img, .thumb.folder img { object-fit: contain; padding: 10%; }
.thumb.image img { object-fit: cover; padding: 0; }
.folder-flag {
  position: absolute; left: 8px; top: 8px; font-size: 11px; font-weight: 700; padding: 1px 7px;
  border-radius: 6px; background: rgba(15,16,19,.75); color: var(--muted); border: 1px solid var(--line);
}
.thumb.denxia .ext { color: var(--accent); }
.thumb .mosaic { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.thumb .mosaic img { width: 100%; height: 100%; object-fit: cover; }
.thumb .folder-ic { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; color: var(--muted); }
.card .c-body { padding: 10px 12px 8px; flex: 1; }
.card .c-title { font-size: 15px; line-height: 1.35; word-break: break-all; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .c-meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; color: var(--muted); font-size: 12px; }
.card .c-last { margin-top: 4px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .c-foot { border-top: 1px solid var(--line); padding: 8px 12px; display: flex; align-items: center; gap: 8px; }
.card .c-foot .spacer { flex: 1; }
.card .c-foot button { padding: 4px 10px; font-size: 13px; }
/* Gumroad 가격표 모양 리본 */
.tag {
  position: relative; display: inline-block; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 700; padding: 2px 14px 2px 8px; line-height: 1.5;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 50%, 100% 100%, 0 100%);
}
.tag.folder { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); clip-path: none; padding: 1px 8px; font-weight: 600; }

/* 상세 창 */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card {
  position: relative; width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  display: grid; grid-template-columns: 280px minmax(0, 1fr);
}
.modal-x { position: absolute; top: 8px; right: 8px; z-index: 1; }
.m-thumb { aspect-ratio: 1 / 1; background: var(--panel-2); position: relative; border-right: 1px solid var(--line); }
.m-inner { position: absolute; inset: 0; }
.m-body { padding: 20px 20px 16px; min-width: 0; }
.m-body h2 { margin: 0 32px 4px 0; font-size: 18px; word-break: break-all; }
.m-body h3 { margin: 18px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.m-path { color: var(--muted); font-size: 12px; word-break: break-all; }
.m-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.m-versions .v { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.m-versions .v:first-child { border-top: none; }
.m-versions .when { flex: 1; color: var(--muted); }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; gap: 14px; padding-top: 14px; }
  .side { position: static; }
  .side-box { display: grid; grid-template-columns: 1fr 1fr; }
  .side-row { border-top: none; padding: 8px; }
  .side-row.count { display: none; }
  .side-row:nth-child(2), .side-row.seg { grid-column: 1 / -1; }
  .side-row.select { flex-direction: column; align-items: stretch; gap: 4px; font-size: 12px; }
  header.top .device { font-size: 0; }
  header.top .device select { font-size: 14px; }
  header.top { flex-wrap: nowrap; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .modal-card { grid-template-columns: 1fr; }
  .m-thumb { border-right: none; border-bottom: 1px solid var(--line); max-height: 260px; aspect-ratio: auto; height: 260px; }
}
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .back { font-weight: 600; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.crumbs button { border: none; background: none; padding: 4px 6px; color: var(--muted); }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--line); }

.drop {
  border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center;
  color: var(--muted); margin-bottom: 14px; transition: .15s;
}
.drop.over { border-color: var(--accent); color: var(--accent); background: rgba(127,209,185,.06); }
.drop button { margin-left: 6px; }

.queue { margin-bottom: 14px; display: grid; gap: 6px; }
.qitem { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.qitem .row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.qitem .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 4px; background: var(--panel-2); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.qitem.err .bar > i { background: var(--danger); }

.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.entry { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.entry:first-child { border-top: none; }
.entry .icon { width: 22px; text-align: center; color: var(--muted); flex: none; }
.entry .info { flex: 1; min-width: 0; }
.entry .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry.folder .title { cursor: pointer; font-weight: 600; }
.entry .meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.entry .actions { display: flex; gap: 6px; flex: none; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); }
.badge.other { color: var(--warn); border-color: rgba(242,181,107,.45); }
.badge.mine { color: var(--accent); border-color: rgba(127,209,185,.4); }
.versions { background: var(--panel-2); border-top: 1px solid var(--line); padding: 4px 12px 8px 44px; }
.versions .v { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; border-top: 1px dashed var(--line); }
.versions .v:first-child { border-top: none; }
.versions .v .when { flex: 1; color: var(--muted); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.note { color: var(--muted); font-size: 12px; margin-top: 10px; }

@media (max-width: 560px) {
  header.top { flex-wrap: wrap; }
  .entry { flex-wrap: wrap; }
  .entry .actions { width: 100%; justify-content: flex-end; }
  .versions { padding-left: 12px; }
}
