:root {
  --bg: #0f1115; --panel: #171a21; --panel-2: #1e222b; --line: #2a2f3a;
  --text: #e6e8ee; --muted: #8b93a7; --accent: #7c5cff; --accent-2: #5b8cff;
  --ok: #3ccf8e; --warn: #f4b942; --bad: #ff6b6b; --chip: #262b36;
  --radius: 10px; --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f5f6fa; --panel: #ffffff; --panel-2: #f0f2f7; --line: #dfe3ec; --text: #171a21;
          --muted: #5f6778; --chip: #e9ecf3; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
a { color: var(--accent-2); text-decoration: none; }
code { background: var(--chip); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
h3 { margin: 18px 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
       padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: baseline; font-weight: 600; }
.brand .logo { color: var(--accent); font-size: 18px; }
.brand .muted { font-weight: 400; font-size: 12px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs button { background: transparent; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 8px;
               cursor: pointer; font: inherit; position: relative; }
.tabs button.active, .tabs button:hover { background: var(--panel-2); color: var(--text); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
       margin-left: 6px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.tab { display: none; } .tab.active { display: block; }

/* controls */
input, select, button { font: inherit; color: var(--text); }
input[type=search], input[type=text], input:not([type]), select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; }
button.small { padding: 4px 10px; font-size: 13px; }
button[disabled] { opacity: .5; cursor: wait; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); white-space: nowrap; }

.searchbar { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.toolbar.compact { margin: 6px 0; }
.toolbar input { flex: 1; }
.summary { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-right: auto; }
.summary b { color: var(--text); }

.pills { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer;
        background: var(--panel); color: var(--muted); user-select: none; }
.pill.on { background: var(--chip); color: var(--text); border-color: var(--accent); }
.pill .n { opacity: .7; margin-left: 4px; }
.pill.err { border-color: var(--bad); }

.meta { font-size: 13px; color: var(--muted); margin: 6px 0 12px; }
.meta div { margin: 2px 0; }

/* result cards */
.results { display: grid; gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.card .title { font-weight: 600; font-size: 16px; }
.score { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.chip { display: inline-block; background: var(--chip); border-radius: 6px; padding: 1px 7px; font-size: 12px; color: var(--muted); }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); }
.srcs { display: grid; gap: 6px; margin-top: 8px; }
.src { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center;
       padding: 6px 8px; border-radius: 8px; background: var(--panel-2); font-size: 14px; }
.src .name { font-weight: 600; }
.src .info { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src .actions { display: flex; gap: 6px; }
@media (max-width: 640px) {
  .searchbar { grid-template-columns: 1fr 1fr; }
  .src { grid-template-columns: 1fr; }
}

/* library grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.lib { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
       display: flex; flex-direction: column; }
.lib .poster { aspect-ratio: 2 / 3; background: var(--panel-2); object-fit: cover; width: 100%; display: block; }
.lib .body { padding: 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.lib .t { font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib .row { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.lib .actions { margin-top: auto; display: flex; gap: 6px; }
.lib .actions button { flex: 1 1 0; min-width: 0; padding: 7px 4px; display: flex; align-items: center; justify-content: center; }
.lib .actions button svg { flex: none; }

/* runs */
.log { background: #0b0d11; color: #d5dae6; border: 1px solid var(--line); border-radius: var(--radius);
       padding: 12px; height: 55vh; min-height: 240px; overflow: auto; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
       white-space: pre-wrap; word-break: break-word; }
@media (prefers-color-scheme: light) { .log { background: #1b1e27; } }
.runs { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.runs li { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 8px; background: var(--panel); cursor: pointer; font-size: 13px; }
.runs li:hover { background: var(--panel-2); }
.runs .st { width: 60px; font-weight: 600; }
.st.running { color: var(--ok); } .st.failed { color: var(--bad); } .st.done { color: var(--muted); }
.st.queued { color: var(--warn); } .st.cancelled { color: var(--muted); text-decoration: line-through; }

/* settings */
.env { width: 100%; border-collapse: collapse; }
.env th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; padding: 6px 8px; }
.env td { padding: 4px 8px; border-top: 1px solid var(--line); }
.env td:first-child { font-family: ui-monospace, monospace; font-size: 13px; width: 34%; }
.env input { width: 100%; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(760px, 100%); max-height: 90vh;
              display: flex; flex-direction: column; padding: 14px 16px; }
.modal-head { display: flex; align-items: center; } .modal-head h3 { margin: 0; flex: 1; color: var(--text); text-transform: none; font-size: 17px; }
.chapters { overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px; margin-top: 8px; }
.chap { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 6px; background: var(--panel-2); font-size: 13px; }
.chap.have { opacity: .6; }
.chap .no { width: 48px; font-variant-numeric: tabular-nums; color: var(--muted); }
.chap .ct { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 20; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px;
         padding: 10px 14px; max-width: 420px; box-shadow: 0 8px 24px rgba(0,0,0,.35); font-size: 14px; }
.toast.bad { border-left-color: var(--bad); } .toast.ok { border-left-color: var(--ok); }
.empty { color: var(--muted); padding: 30px; text-align: center; }

/* 18+ visibility toggle: a crossed-out eye when hidden, an open eye when shown */
.eye { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 32px;
       padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
       color: var(--muted); cursor: pointer; }
.eye:hover { color: var(--text); }
.eye.on { color: var(--warn); border-color: var(--warn); }
.eye:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

