/* itq 파일 목록 테마 — 라이트/다크 (기본: 기기 설정 따라감, 버튼으로 고정 가능) */
:root {
  color-scheme: light;
  --bg: #f4f5f7; --text: #1f2937; --muted: #6b7280; --brand: #0369a1;
  --card: #ffffff; --card-head: #f3f4f6; --border: #e3e6ea; --row-line: #eef0f3; --hover: #f1f5f9;
  --link: #0369a1; --link-hover: #075985; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.03);
  --input-bg: #ffffff; --focus: #0284c7;
  --code-bg: #ffffff; --ln: #9ca3af;
  --ok-bg: #dcfce7; --ok-border: #22c55e; --ok-text: #166534; --err: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f172a; --text: #e2e8f0; --muted: #64748b; --brand: #38bdf8;
    --card: #1e293b; --card-head: #273549; --border: #334155; --row-line: #24314a; --hover: #24314a;
    --link: #7dd3fc; --link-hover: #38bdf8; --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --input-bg: #1e293b; --focus: #38bdf8;
    --code-bg: #0d1117; --ln: #4b5563;
    --ok-bg: #14532d; --ok-border: #22c55e; --ok-text: #86efac; --err: #f87171;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a; --text: #e2e8f0; --muted: #64748b; --brand: #38bdf8;
  --card: #1e293b; --card-head: #273549; --border: #334155; --row-line: #24314a; --hover: #24314a;
  --link: #7dd3fc; --link-hover: #38bdf8; --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --input-bg: #1e293b; --focus: #38bdf8;
  --code-bg: #0d1117; --ln: #4b5563;
  --ok-bg: #14532d; --ok-border: #22c55e; --ok-text: #86efac; --err: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 20px 60px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: flex-end; }

.brand { font-size: 20px; font-weight: 600; color: var(--brand); }

#filterBox {
  flex: 1; max-width: 320px; min-width: 180px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
  font-size: 14px; outline: none;
}
#filterBox:focus { border-color: var(--focus); }

/* 테마 전환 버튼 */
.theme-btn {
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.theme-btn:hover { border-color: var(--focus); }

/* fancyindex가 생성하는 테이블 스타일 */
table {
  width: 100%; border-collapse: collapse;
  background: var(--card); border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
th {
  text-align: left; padding: 12px 16px;
  background: var(--card-head); color: var(--muted);
  font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border);
}
th a { color: var(--muted); text-decoration: none; }
td { padding: 10px 16px; border-bottom: 1px solid var(--row-line); font-size: 14px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--hover); }

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

/* 폴더/파일 구분 아이콘 (파일명 앞에 자동 표시) */
td:first-child a[href$="/"]::before { content: "📁 "; }
td:first-child a:not([href$="/"])::before { content: "📄 "; }

.footer { margin-top: 24px; text-align: center; font-size: 12px; color: var(--muted); }

/* 모바일 대응 */
@media (max-width: 600px) {
  th:nth-child(2), td:nth-child(2) { display: none; } /* 수정일 숨김 */
  .wrap { padding: 16px 12px 40px; }
}

/* ===== 색상 포인트: 남색(인디고) 한 가지 색으로 통일 ===== */
:root { --accent: #4f46e5; --accent-soft: #eef2ff; --accent-line: #c7d2fe; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --accent: #818cf8; --accent-soft: #1e1b4b; --accent-line: #3730a3; }
}
:root[data-theme="dark"] { --accent: #818cf8; --accent-soft: #1e1b4b; --accent-line: #3730a3; }

/* 화면 맨 위 얇은 색 띠 */
body { border-top: 4px solid var(--accent); }

/* 로고 */
a.brand, a.brand:hover { color: var(--accent); font-weight: 800; letter-spacing: -0.3px; text-decoration: none; }

/* 현재 경로(fancyindex의 h1) */
h1 {
  display: inline-block; margin: 0 0 14px; padding: 5px 12px;
  font-size: 14px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px;
}

/* 검색창·버튼 */
#filterBox:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-btn:hover, .code-btn:hover { border-color: var(--accent); color: var(--accent); }

/* 표 머리글 아래 색 선 */
th { border-bottom: 2px solid var(--accent-line); }
th a:hover { color: var(--accent); }

/* 행 hover: 옅은 색 + 왼쪽 막대 */
tbody tr:hover td { background: var(--accent-soft); }
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* 폴더 이름은 굵게, 크기·날짜는 흐리게 */
td:first-child a[href$="/"] { font-weight: 600; }
td.size, td.date { color: var(--muted); font-variant-numeric: tabular-nums; }
td:first-child a[href="../"] { color: var(--muted); font-weight: 500; }
td:first-child a[href="../"]::before { content: "↩ "; }

/* 파일 종류 배지(옅은 바탕 + 같은 계열 글자색) */
td:first-child a:not([href$="/"])::before {
  --c: #64748b; content: "FILE";
  display: inline-block; min-width: 40px; margin-right: 8px; padding: 1px 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .3px; text-align: center; border-radius: 4px;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); vertical-align: 1px;
}
td:first-child a[href$=".pdf" i]::before { --c: #dc2626; content: "PDF"; }
td:first-child a[href$=".jpg" i]::before, td:first-child a[href$=".jpeg" i]::before,
td:first-child a[href$=".png" i]::before, td:first-child a[href$=".gif" i]::before { --c: #0d9488; content: "IMG"; }
td:first-child a[href$=".wmv" i]::before, td:first-child a[href$=".mp4" i]::before { --c: #9333ea; content: "VIDEO"; }
td:first-child a[href$=".hwp" i]::before, td:first-child a[href$=".hwpx" i]::before { --c: #0284c7; content: "HWP"; }
td:first-child a[href$=".xlsx" i]::before, td:first-child a[href$=".xls" i]::before { --c: #16a34a; content: "XLS"; }
td:first-child a[href$=".pptx" i]::before, td:first-child a[href$=".ppt" i]::before { --c: #ea580c; content: "PPT"; }
td:first-child a[href$=".docx" i]::before, td:first-child a[href$=".doc" i]::before { --c: #2563eb; content: "DOC"; }
td:first-child a[href$=".zip" i]::before { --c: #78716c; content: "ZIP"; }
td:first-child a[href$=".py" i]::before { --c: #ca8a04; content: "PY"; }
td:first-child a[href$=".c" i]::before, td:first-child a[href$=".cpp" i]::before, td:first-child a[href$=".h" i]::before { --c: #4f46e5; content: "C"; }

/* 코드 보기 화면 파일명 */
.code-filename { color: var(--accent) !important; font-weight: 700; }
/* 다크 화면에서는 배지 글자를 밝게 */
:root[data-theme="dark"] td:first-child a:not([href$="/"])::before { color: color-mix(in srgb, var(--c) 55%, white); background: color-mix(in srgb, var(--c) 22%, transparent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) td:first-child a:not([href$="/"])::before { color: color-mix(in srgb, var(--c) 55%, white); background: color-mix(in srgb, var(--c) 22%, transparent); }
}
/* 표 너비 확대 + 머리글 굵게 */
.wrap { max-width: 1200px; }
th, th a { font-weight: 700; font-size: 13.5px; }
td:first-child a[href$=".ino" i]::before { --c: #0891b2; content: "INO"; }
/* 언어별 배지 세분화: C / C++ / H 구분 + 자주 쓰는 형식 추가 */
td:first-child a[href$=".c" i]::before { --c: #4f46e5; content: "C"; }
td:first-child a[href$=".cpp" i]::before, td:first-child a[href$=".cc" i]::before,
td:first-child a[href$=".cxx" i]::before { --c: #c026d3; content: "C++"; }
td:first-child a[href$=".h" i]::before, td:first-child a[href$=".hpp" i]::before { --c: #64748b; content: "H"; }
td:first-child a[href$=".java" i]::before { --c: #b91c1c; content: "JAVA"; }
td:first-child a[href$=".js" i]::before { --c: #a16207; content: "JS"; }
td:first-child a[href$=".html" i]::before, td:first-child a[href$=".htm" i]::before { --c: #e11d48; content: "HTML"; }
td:first-child a[href$=".txt" i]::before, td:first-child a[href$=".md" i]::before { --c: #475569; content: "TXT"; }
td:first-child a[href$=".ipynb" i]::before { --c: #f97316; content: "IPYNB"; }
