/* 부품 도감 화면 — 편집기와 같은 어두운 작업 화면, 카드는 미리보기 영상이 주인공. */

:root {
  --bg: #0a0c11; --panel: #11141b; --card: #141821; --raise: #1c2130; --line: #232a39; --line2: #2f3649;
  --ink: #eef1f7; --sub: #a6aec0; --mute: #6c758a; --acc: #38bdf8; --acc-ink: #04121c; --pink: #ff4d8d;
  color-scheme: dark; font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; padding-bottom: 150px;
  background: radial-gradient(1200px 520px at 20% -10%, rgba(124,58,237,.16), transparent 60%),
              radial-gradient(1000px 500px at 90% 0%, rgba(34,211,238,.10), transparent 60%), var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
[hidden] { display: none !important; }
.muted { color: var(--mute); }
button { height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line2); background: var(--raise); cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled) { border-color: #45506b; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); font-weight: 700; }
button.primary:hover:not(:disabled) { background: #74d3fb; }
button.ghost { background: transparent; border-color: transparent; color: var(--sub); }
button.ghost:hover:not(:disabled) { background: var(--raise); color: var(--ink); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* 위 막대 */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; height: 56px; padding: 0 28px;
  background: rgba(10,12,17,.82); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand b { letter-spacing: .08em; font-weight: 800; font-size: 15px; }
.brand b i { font-style: normal; color: var(--acc); }
.brand span { color: var(--sub); }
.modes { display: flex; gap: 4px; margin-left: 12px; }
.modes a { padding: 7px 14px; border-radius: 99px; color: var(--sub); text-decoration: none; }
.modes a:hover { color: var(--ink); background: var(--raise); }
.modes a.on { color: var(--acc-ink); background: var(--acc); font-weight: 700; }

/* 머리말·거르기 */
.hero { max-width: 1480px; margin: 0 auto; padding: 44px 28px 18px; }
.hero h1 { margin: 0 0 10px; font-size: 34px; font-weight: 800; letter-spacing: -.01em; }
.hero p { margin: 0; max-width: 760px; color: var(--sub); line-height: 1.75; font-size: 15px; }
.hero p b { color: var(--ink); }
.filters { display: flex; align-items: center; gap: 14px; margin-top: 26px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { height: 36px; border-radius: 99px; padding: 0 16px; background: var(--panel); color: var(--sub); }
.tabs button span { margin-left: 6px; color: var(--mute); font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif; font-size: 12px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #0b0d12; border-color: var(--ink); font-weight: 700; }
.tabs button[aria-selected="true"] span { color: #5b6275; }
.search { margin-left: auto; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; min-width: 280px;
  border-radius: 99px; border: 1px solid var(--line2); background: var(--panel); color: var(--mute); }
.search input { border: 0; background: transparent; outline: none; flex: 1; color: var(--ink); }

/* 카드 격자 */
.grid { max-width: 1480px; margin: 0 auto; padding: 10px 28px 40px; display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.section-title { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 12px; margin: 22px 0 -4px; }
.section-title h3 { margin: 0; font-size: 19px; font-weight: 800; white-space: nowrap; flex: none; }
.section-title p { margin: 0; color: var(--mute); font-size: 13px; }
.card { position: relative; border-radius: 16px; background: var(--card); border: 1px solid var(--line); overflow: hidden;
  display: flex; flex-direction: column; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.card:hover { transform: translateY(-3px); border-color: #3a4560; box-shadow: 0 18px 40px rgba(0,0,0,.45); }
.card.is-picked { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc), 0 18px 40px rgba(56,189,248,.12); }
.media { position: relative; flex: none; display: block; width: 100%; height: auto; padding: 0; border: 0; border-radius: 0;
  aspect-ratio: 16 / 9; background: #07060f; cursor: zoom-in; overflow: hidden; }
.media:focus-visible { outline-offset: -3px; }
.media img, .media video, .media .still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.media .still { background-repeat: no-repeat; }
.media video { opacity: 0; transition: opacity .2s; }
.card:hover .media video.ready { opacity: 1; }
.media .none { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mute); font-size: 13px; }
.media .play { position: absolute; right: 10px; bottom: 10px; padding: 4px 9px; border-radius: 99px; background: rgba(0,0,0,.55);
  font-size: 11px; color: #dfe6f3; backdrop-filter: blur(6px); }
.card:hover .media .play { opacity: 0; }
.play .on-touch { display: none; }
@media (hover: none) { .play .on-hover { display: none; } .play .on-touch { display: inline; } .card:hover .media .play { opacity: 1; } }
.badge { position: absolute; left: 10px; top: 10px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 99px; display: grid; place-items: center;
  background: var(--acc); color: var(--acc-ink); font: 700 13px "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.name { display: flex; align-items: center; gap: 8px; }
.name h4 { margin: 0; font-size: 16.5px; font-weight: 800; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; background: var(--raise); color: var(--sub); white-space: nowrap; }
.chip.transition { background: rgba(255,77,141,.14); color: #ff9dbf; }
.chip.d3 { background: rgba(124,58,237,.18); color: #c7b3ff; }
.desc { margin: 0; color: var(--sub); line-height: 1.6; font-size: 13.5px; }
.when { margin: 0; color: var(--mute); font-size: 12.5px; line-height: 1.55; }
.when b { color: #8fd7f7; font-weight: 600; margin-right: 4px; }
.foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.foot .len { color: var(--mute); font: 12px "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif; }
.pick { height: 32px; }
.card.is-picked .pick { background: rgba(56,189,248,.14); color: var(--acc); border-color: rgba(56,189,248,.5); }
.empty { grid-column: 1 / -1; padding: 60px 0; text-align: center; color: var(--mute); }

/* 아래 고른 목록 */
.tray { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 12px 28px 14px; background: rgba(13,16,23,.94);
  backdrop-filter: blur(14px); border-top: 1px solid var(--line2); box-shadow: 0 -18px 40px rgba(0,0,0,.4); }
.tray-head { display: flex; align-items: baseline; gap: 12px; }
.tray-head em { font-style: normal; color: var(--acc); }
.picked { list-style: none; margin: 10px 0; padding: 0; display: flex; gap: 8px; overflow-x: auto; min-height: 38px; align-items: center; }
.picked li { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 6px 0 12px; border-radius: 99px; background: var(--raise);
  border: 1px solid var(--line2); white-space: nowrap; font-size: 13px; }
.picked li.transition { border-style: dashed; border-color: rgba(255,77,141,.6); color: #ffb3cd; }
.picked li .n { font: 700 12px "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif; color: var(--acc); }
.picked li .moves { display: flex; gap: 1px; margin-left: 2px; }
.picked li button { height: 26px; width: 26px; padding: 0; border-radius: 99px; border: 0; background: transparent; color: var(--mute); }
.picked li button:hover:not(:disabled) { background: #2a3144; color: var(--ink); }
.picked li button:disabled { opacity: .25; }
.picked .arrow { color: var(--mute); }
.tray-foot { display: flex; gap: 10px; align-items: center; }
.tray-foot input { flex: 1; max-width: 420px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2); background: #0c0f16; }
.tray-foot .primary { height: 40px; padding: 0 22px; margin-left: auto; font-size: 15px; }
.tray-foot select { height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line2); background: #0c0f16; color: inherit; font: inherit; }

/* 크게 보기 — 창 전체가 화면 높이 안에 들어오게 영상 폭을 줄이고(글 칸 몫 330px: 제목·설명·이럴 때·프롬프트·버튼), 닫기(×)는 늘 보이는 오른쪽 위 */
.modal { --pad: 30px; position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--pad);
  background: rgba(4,6,10,.8); backdrop-filter: blur(6px); }
.sheet { --ratio: 1.7778; position: relative; display: flex; flex-direction: column;
  width: min(1120px, 100%, max(460px, calc((100vh - 2 * var(--pad) - 330px) * var(--ratio))));
  width: min(1120px, 100%, max(460px, calc((100dvh - 2 * var(--pad) - 330px) * var(--ratio))));
  max-height: calc(100vh - 2 * var(--pad)); max-height: calc(100dvh - 2 * var(--pad));
  border-radius: 18px; overflow: hidden; background: var(--panel); border: 1px solid var(--line2); box-shadow: 0 40px 100px rgba(0,0,0,.6); }
.sheet-media { position: relative; flex: none; background: #000; }
.sheet video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; object-fit: contain; }
.sheet-x { position: absolute; top: 10px; right: 10px; z-index: 2; width: 40px; height: 40px; padding: 0; border-radius: 99px;
  font-size: 22px; line-height: 1; background: rgba(8,10,15,.72); border-color: rgba(255,255,255,.18); backdrop-filter: blur(6px); }
.media-err { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; color: var(--sub); background: rgba(0,0,0,.7); }
.sheet-body { padding: 20px 24px 22px; display: grid; gap: 10px; overflow-y: auto; min-height: 0; }
.sheet-body .note { font-size: 13px; color: #8fd7f7; }
.sheet-title { display: flex; align-items: center; gap: 10px; }
.sheet-title h2 { margin: 0; font-size: 22px; }
.sheet-body p { margin: 0; color: var(--sub); line-height: 1.7; }
.sheet-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }
.sheet-actions .muted { margin-right: auto; min-width: max-content; }
.toast { position: fixed; left: 50%; bottom: 170px; transform: translateX(-50%); z-index: 60; padding: 11px 18px; border-radius: 10px;
  background: #1d2433; border: 1px solid var(--line2); box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.toast.bad { border-color: rgba(248,113,113,.6); color: #ffd0d0; }
@media (max-width: 720px) {
  .modal { --pad: 12px; }
  .sheet-body { padding: 16px 16px 18px; }
  .top { padding: 0 16px; gap: 10px; }
  .hero { padding: 28px 16px 10px; } .hero h1 { font-size: 26px; } .hero p { font-size: 14px; }
  .search { min-width: 0; width: 100%; margin-left: 0; }
  .grid { padding: 8px 16px 40px; gap: 16px; grid-template-columns: 1fr; }
  .tray { padding: 10px 16px 12px; } .tray-head { flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }
  .picked { margin: 8px 0; }
  .picked:empty { display: none; }
  .tray-foot { flex-wrap: wrap; } .tray-foot input { max-width: none; }
  .tray-foot .primary { height: 38px; }
}
@media (hover: none), (pointer: coarse) { .esc-hint { display: none; } }   /* 휴대폰에는 Esc 키가 없다 */

/* AI 프롬프트 복사(카드 아래 작은 버튼) — 복사가 막힐 때 잠깐 쓰는 글 상자는 화면 밖에 */
.foot .prompt-btn { margin-left: auto; margin-right: 6px; color: var(--sub); }
.foot .prompt-btn:hover:not(:disabled) { color: var(--acc); }
.copy-tmp { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }