@font-face { font-family: "Paperlogy"; src: url("/fonts/Paperlogy-6SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
:root {
  --bg: #f4f3ef;
  --paper: #ffffff;
  --ink: #17181b;
  --sub: #6b6e75;
  --faint: #9a9ca2;
  --line: #e2e0da;
  --game: #3d5a99;
  --style: #6b5b95;
  --fx: #a8642a;
  --font: #2a7f7a;
  --place: #4a7c59;
  --topic: #8a4f7d;
  --radius: 12px;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  font-family: 'Pretendard Variable', Pretendard, system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; transition: background .15s, border-color .15s, transform .1s; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .35; cursor: default; }
.primary { background: var(--ink); color: #fff; padding: 12px 26px; font-weight: 700; letter-spacing: .01em; }
.primary:hover:not(:disabled) { background: #000; }
.ghost { background: transparent; color: var(--ink); padding: 8px 14px; border: 1px solid var(--line); font-weight: 600; }
.ghost:hover:not(:disabled) { border-color: #c9c6be; background: #fff; }
.tiny { padding: 5px 11px; font-size: 13px; }

/* 머리 */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 32px; padding: 0 32px; height: 64px; background: rgba(244,243,239,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand b { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.brand small { font: 500 11px var(--mono); letter-spacing: .14em; color: var(--faint); text-transform: uppercase; }
.brand svg { width: 26px; height: 26px; }
.brand .c1 { fill: #b9b6ad; } .brand .c2 { fill: var(--ink); } .brand .ln { stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.tabs { display: flex; gap: 26px; height: 100%; }
.tabs button { background: transparent; padding: 0; border-radius: 0; height: 100%; color: var(--sub); font-weight: 600; font-size: 15px; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.quota { margin-left: auto; color: var(--sub); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

main { padding: 28px 32px 56px; }
.tab { display: none; } .tab.on { display: block; }

/* 조합 */
.mix { display: grid; grid-template-columns: minmax(0, 1fr) minmax(440px, 46%); gap: 36px; align-items: start; }
.deckBar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.deckBar p { margin: 0; color: var(--sub); font-size: 14px; }
.group { margin-bottom: 30px; }
.group h3 { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.group h3 em { font: 500 13px var(--mono); font-style: normal; color: var(--gc); letter-spacing: .06em; }
.group h3 small { margin-left: auto; color: var(--faint); font-size: 12.5px; font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 14px; }
.card { position: relative; display: flex; flex-direction: column; justify-content: flex-start; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; overflow: hidden; transition: border-color .15s, box-shadow .2s, transform .2s; }
.card:hover { border-color: #c9c6be; box-shadow: 0 10px 24px rgba(23,24,27,.07); transform: translateY(-2px); }
.card.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink), 0 10px 24px rgba(23,24,27,.1); }
.card.on::after { content: ''; position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%; background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12l4 4 8-8' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/15px no-repeat; box-shadow: 0 0 0 3px rgba(255,255,255,.7); }
.card .demo { aspect-ratio: 16 / 10; background: #efeee9; overflow: hidden; position: relative; border-bottom: 1px solid var(--line); }
.card .txt { padding: 12px 14px 14px; }
.card b { display: block; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.card em { display: block; font: 500 10.5px var(--mono); font-style: normal; letter-spacing: .06em; color: var(--gc); margin-top: 3px; text-transform: uppercase; }
.card span { display: block; color: var(--sub); font-size: 12.5px; line-height: 1.5; margin-top: 6px; }
.card .spec { display: none; font-size: 12px; line-height: 1.6; color: var(--ink); background: #f6f5f1; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 10px; }
.deck.showSpec .card .spec { display: block; }

.stage { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 14px; }
.picked, .chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 34px; align-items: center; }
.picked .cnt { font-size: 12.5px; font-weight: 700; color: var(--faint); margin-right: 4px; font-variant-numeric: tabular-nums; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--gc); }
.picked .need { color: var(--fx); font-size: 13px; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions.small button { font-size: 13px; padding: 6px 12px; }
.mix > *, .compare > *, .ref > *, .side { min-width: 0; }
.screen { position: relative; width: 100%; aspect-ratio: 16 / 10; background: #fff; border-radius: 14px; overflow: hidden; border: 1px solid #d8d6cf; box-shadow: 0 24px 48px rgba(23,24,27,.12), 0 2px 6px rgba(23,24,27,.06); }
/* 도구는 교실 화면 크기(1280x800)로 그리고 칸에 맞게 줄인다. 배율은 app.js가 정한다. */
.screen iframe { width: 1280px; height: 800px; border: 0; display: block; background: #fff; transform-origin: 0 0; transform: scale(var(--fit, .4)); }
.screen .empty[hidden] { display: none; }
.screen .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); text-align: center; padding: 20px; pointer-events: none; font-size: 14px; background: repeating-linear-gradient(0deg, transparent 0 31px, #f0efea 31px 32px), repeating-linear-gradient(90deg, transparent 0 31px, #f0efea 31px 32px); }
.status { font-size: 13.5px; color: var(--sub); min-height: 20px; font-variant-numeric: tabular-nums; }
.status.err { color: #b3261e; font-family: inherit; }
.status b { color: var(--ink); }
.code { margin: 0; max-height: 160px; overflow: auto; background: #17181b; color: #c9cdd4; font: 12px/1.5 var(--mono); padding: 12px 14px; border-radius: 10px; white-space: pre-wrap; word-break: break-all; }

/* 비교 */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.side { display: flex; flex-direction: column; gap: 10px; }
.side h2 { margin: 0; font-size: 18px; }
.ask { margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-family: inherit; font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.side .primary { align-self: flex-start; }

/* 카드 만들기 */
.ref { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.drop { min-height: 360px; border: 2px dashed #cfcfc8; border-radius: var(--radius); display: grid; place-items: center; text-align: center; background: var(--paper); color: var(--sub); padding: 16px; }
.drop.over { border-color: var(--ink); }
.drop img { max-width: 100%; max-height: 520px; border-radius: 8px; }
.refOut .hint { color: var(--sub); line-height: 1.6; }
.made { background: var(--paper); border-radius: var(--radius); padding: 20px; border-top: 6px solid var(--fx); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.made h2 { margin: 0 0 4px; }
.made p { margin: 6px 0; line-height: 1.6; }
.made ul { margin: 8px 0; padding-left: 20px; line-height: 1.7; }
.made .specBox { background: #f3f3ef; border-radius: 8px; padding: 10px 12px; font-size: 14px; line-height: 1.6; }

/* 모아 보기 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tool { background: var(--paper); border-radius: var(--radius); overflow: hidden; text-align: left; padding: 0; box-shadow: 0 1px 3px rgba(0,0,0,.07); }
.tool .thumb { aspect-ratio: 16 / 10; overflow: hidden; position: relative; background: #fff; border-bottom: 1px solid var(--line); }
.tool .thumb iframe { width: 1280px; height: 800px; transform: scale(var(--fit, .2)); transform-origin: 0 0; border: 0; pointer-events: none; }
.tool .meta { padding: 10px 12px 12px; }
.tool .meta b { display: block; }
.tool .meta .chips { margin-top: 6px; min-height: 0; }
.tool .meta .chip { font-size: 12px; padding: 2px 8px; }
.gallery .none { color: var(--sub); }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(1100px, 94vw); max-height: 92vh; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20,20,24,.45); }
.dlgHead { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#dlgBody { padding: 16px; overflow: auto; max-height: calc(92vh - 60px); }
#dlgBody pre { margin: 0; white-space: pre-wrap; font-family: inherit; font-size: 15px; line-height: 1.7; }

.gate { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: grid; place-items: center; }
.gate[hidden] { display: none; }
.gate form { display: flex; flex-direction: column; gap: 12px; width: min(360px, 90vw); text-align: center; }
.gate b { font-size: 24px; }
.gate p { margin: 0; color: var(--sub); }
.gate input { font: inherit; font-size: 20px; text-align: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.gate .err { color: #c92a2a; min-height: 20px; }

/* 카드 앞면 예시: 640x400 데모를 카드 너비에 맞게 줄인다 */
.demo-host { position: absolute; left: 0; top: 0; width: 640px; height: 400px; transform-origin: 0 0; transform: scale(var(--fit, .28)); pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .demo-host { display: none; } }

@media (max-width: 1000px) {
  .mix, .compare, .ref { grid-template-columns: 1fr; }
  .stage { position: static; }
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  main { padding: 16px; }
}
