:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #8a8a8e;
  --line: #e7e5e0;
  --accent: #e8a33d;
  --mark: rgba(232, 163, 61, 0.28);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --play: #2f7cf6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #1b1b1e;
    --text: #ececef;
    --muted: #7c7c84;
    --line: #2a2a2f;
    --accent: #f0b04e;
    --mark: rgba(240, 176, 78, 0.3);
    --shadow: none;
    --play: #4c95ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

.loading {
  position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 10;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 50% 100%; background-repeat: no-repeat;
  animation: slide 1s linear infinite;
}
.loading.done { display: none; }
@keyframes slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }

header {
  position: sticky; top: 0; z-index: 5;
  padding: 20px 16px 10px;
  background: linear-gradient(var(--bg) 80%, transparent);
}
.bar {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.bar:focus-within { border-color: var(--accent); }
.bar .icon { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.bar input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 17px;
}
.bar input::placeholder { color: var(--muted); }
.bar input::-webkit-search-cancel-button { -webkit-appearance: none; }

.chip {
  flex: none; display: flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 8px 0 3px; max-width: 45%;
  border: 0; border-radius: 16px; cursor: pointer;
  background: var(--mark); color: var(--text); font: inherit; font-size: 14px;
}
.chip[hidden] { display: none; }
.chip img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip svg { width: 14px; height: 14px; flex: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; }

.ops {
  max-width: 720px; margin: 10px auto 0;
  display: flex; gap: 8px; overflow-x: auto;
}
.ops:empty { display: none; }
.ops { padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; overscroll-behavior-x: contain; }
.ops::-webkit-scrollbar { height: 6px; }
.ops::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.op {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 64px; padding: 4px 0; border: 0; background: none; cursor: pointer;
  color: var(--text); font: inherit; font-size: 12px;
}
.op img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--line); }
.op span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }

.list { max-width: 720px; margin: 0 auto; padding: 4px 16px 24px; }
.card {
  position: relative; overflow: hidden;
  display: flex; gap: 12px;
  padding: 14px 14px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.card .av {
  flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: var(--line) center / cover no-repeat; cursor: pointer;
}
.card .body { min-width: 0; flex: 1; }
.card .meta { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.card .name { font-weight: 700; font-size: 16px; }
.card .sub, .card .title { color: var(--muted); }
.card .title::before { content: "·"; margin-right: 6px; }
.card .text { margin-top: 3px; cursor: pointer; word-break: keep-all; overflow-wrap: anywhere; white-space: pre-line; }
.card mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.card .progress { position: absolute; left: 0; bottom: 0; width: 0; height: 3px; background: var(--play); }

.empty { display: flex; justify-content: center; padding: 48px 0; color: var(--muted); }
.empty svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  padding: 8px 16px; border-radius: 18px;
  background: var(--text); color: var(--bg); font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

footer { padding: 8px 16px 28px; text-align: center; color: var(--muted); font-size: 11px; }

/* Filters */
:root { --side-w: 304px; --chip-bg: #26262b; --chip-bg-on: #34343b; }
.side {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 20;
  width: var(--side-w); overflow-y: auto;
  padding: 24px 18px;
  display: flex; flex-direction: column; gap: 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.page { margin-left: var(--side-w); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-f {
  height: 34px; padding: 0 11px;
  border: 1.5px solid transparent; border-radius: 17px;
  font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: border-color .12s, background .12s, opacity .12s;
}
.rarity .chip-f {
  background: var(--chip-bg); color: var(--c);
  letter-spacing: -1px; font-size: 14px;
}
.rarity .chip-f.on { border-color: var(--c); background: var(--chip-bg-on); }
.prof { display: grid; grid-template-columns: repeat(4, auto); justify-content: stretch; }
.prof .chip-f {
  padding: 0 7px; font-size: 12px;
  background: transparent; color: var(--text); border-color: var(--line);
}
.prof .chip-f.on { background: var(--mark); border-color: var(--accent); }

.select { position: relative; }
.select select {
  width: 100%; height: 40px; padding: 0 36px 0 14px;
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.select select:focus { outline: 0; border-color: var(--accent); }
.select svg {
  position: absolute; right: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none;
}

.reset {
  align-self: flex-start; width: 36px; height: 36px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer;
}
.reset[hidden] { display: none; }
.reset svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.filter-btn {
  display: none; position: relative; flex: none;
  width: 36px; height: 36px; margin-right: -6px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  place-items: center;
}
.filter-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.filter-btn i { display: none; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.filter-btn.active i { display: block; }
.scrim { display: none; }

@media (max-width: 899px) {
  .page { margin-left: 0; }
  .side {
    width: min(var(--side-w), 86vw);
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: none;
  }
  body.drawer .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .22s; }
  body.drawer .scrim { opacity: 1; pointer-events: auto; }
  .filter-btn { display: grid; }
}

/* Voice playback */
.card { transition: border-color .15s; }
.card.playing, .card.loading-voice { border-color: var(--play); }
.card.novoice { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Language */
.seg { display: flex; padding: 3px; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.seg button {
  flex: 1; height: 34px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font: inherit; font-size: 14px; cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.card .text.voice-only { display: flex; align-items: center; height: 26px; color: var(--muted); }
.card .text.voice-only svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.chip-f.unreleased { background: transparent; color: var(--text); border-color: var(--line); font-size: 12.5px; }
.chip-f.unreleased.on { background: var(--mark); border-color: var(--accent); }
