/* Coriworks Templates gallery. Tokens first, all numbers here. */
:root {
  --bg: #ffffff;
  --surface: #f4f6f9;
  --line: #e3e7ee;
  --ink: #0e1726;
  --muted: #5b6475;
  --navy: #0b1f44;
  --accent: #1b5bff;
  --accent-ink: #ffffff;
  --backdrop: rgba(11, 31, 68, 0.48);

  --fs-xs: 13px;
  --fs-s: 14px;
  --fs-m: 16px;
  --fs-l: 20px;
  --fs-xl: 32px;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r1: 8px; --r2: 12px; --r-pill: 999px;
  --sh1: 0 1px 2px rgba(14, 23, 38, 0.06);
  --sh2: 0 12px 40px rgba(14, 23, 38, 0.18);

  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --maxw: 1440px;
  --pad: 24px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 var(--fs-m)/1.5 var(--font);
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip:focus { position: fixed; top: var(--s2); left: var(--s2); z-index: 100; background: var(--bg); padding: var(--s3) var(--s4); border-radius: var(--r1); box-shadow: var(--sh2); }

/* Header */
.top { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, 0.94); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.top__in { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); height: 64px; display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.logo { display: inline-flex; align-items: center; gap: var(--s2); text-decoration: none; min-height: 44px; }
.logo__mark { width: 28px; height: 28px; flex: none; }
.logo__word { font-weight: 700; letter-spacing: 0.08em; font-size: var(--fs-m); color: var(--navy); }
.logo__sub { font-size: var(--fs-s); color: var(--muted); font-weight: 500; }
.top__nav { display: flex; align-items: center; gap: var(--s2); }
.top__link { font-size: var(--fs-s); color: var(--muted); text-decoration: none; padding: 0 var(--s2); min-height: 44px; display: inline-flex; align-items: center; border-radius: var(--r1); }
.top__link:hover { color: var(--ink); }
.lang { display: inline-flex; background: var(--surface); border-radius: var(--r-pill); padding: 2px; }
.lang__btn { border: 0; background: transparent; min-width: 44px; padding: 0 8px; min-height: 44px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; color: var(--muted); cursor: pointer; }
.lang__btn[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: var(--sh1); }

/* Intro */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); }
.intro { padding: var(--s6) 0 var(--s4); }
.intro__title { margin: 0; font-size: var(--fs-xl); line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.intro__lead { margin: var(--s2) 0 0; color: var(--muted); font-size: var(--fs-m); max-width: 640px; }

/* Tabs */
.tabs-wrap { position: sticky; top: 64px; z-index: 10; background: var(--bg); margin: 0 calc(var(--pad) * -1); padding: var(--s2) var(--pad); }
.tabs { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 0; background: transparent; min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-pill); font-size: var(--fs-s); font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: var(--s2); }
.tab:hover { background: var(--surface); color: var(--ink); }
.tab[aria-selected="true"] { background: var(--navy); color: #fff; }
.tab__n { font-size: var(--fs-xs); font-weight: 500; opacity: 0.8; }

.count { margin: var(--s2) 0 var(--s3); font-size: var(--fs-xs); color: var(--muted); }

/* Grid */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s5) var(--s4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { min-width: 0; }
.card__btn { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; border-radius: var(--r2); }
.card__media { position: relative; aspect-ratio: 8 / 5; border-radius: var(--r2); overflow: hidden; background: var(--surface); box-shadow: var(--sh1); }
.card__media video, .card__media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.card__btn:hover .card__media { box-shadow: 0 0 0 2px var(--line), var(--sh1); }
.card__ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: var(--fs-xl); font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.card__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); padding: var(--s2) var(--s1) 0; }
.card__name { font-size: var(--fs-s); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card__cat { font-size: var(--fs-xs); color: var(--muted); flex: none; }
.empty { color: var(--muted); padding: var(--s7) 0; text-align: center; }

/* About + footer */
.about { margin: var(--s7) 0 0; padding: var(--s6) 0; border-top: 1px solid var(--line); max-width: 720px; }
.about__title { margin: 0 0 var(--s2); font-size: var(--fs-l); }
.about__text { margin: 0; color: var(--muted); }
.foot { border-top: 1px solid var(--line); margin-top: var(--s6); }
.foot__in { max-width: var(--maxw); margin: 0 auto; padding: var(--s5) var(--pad) var(--s6); display: flex; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.foot__col { display: flex; flex-direction: column; gap: var(--s1); }
.foot__brand { font-weight: 700; letter-spacing: 0.08em; color: var(--navy); }
.foot__link { color: var(--muted); font-size: var(--fs-s); min-height: 44px; display: inline-flex; align-items: center; }
.foot__copy { color: var(--muted); font-size: var(--fs-xs); }

/* Panel */
.backdrop { position: fixed; inset: 0; z-index: 40; background: var(--backdrop); opacity: 0; transition: opacity 200ms ease; }
.backdrop.open { opacity: 1; }
.panel {
  position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100vw;
  background: var(--bg); box-shadow: var(--sh2); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 220ms cubic-bezier(.2,.7,.2,1);
  outline: none;
}
.panel.open { transform: none; }
.panel__grip { display: none; }
.panel__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) var(--s3) var(--s2) var(--s5); }
.panel__body { overflow-y: auto; padding: 0 var(--s5) var(--s6); overscroll-behavior: contain; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: var(--r-pill); display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--surface); }
.icon-btn svg { width: 22px; height: 22px; }
.panel__media { aspect-ratio: 8 / 5; border-radius: var(--r2); overflow: hidden; background: var(--surface); position: relative; }
.panel__media video, .panel__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.panel__name { margin: var(--s4) 0 var(--s2); font-size: var(--fs-l); line-height: 1.3; }
.panel__desc { margin: 0 0 var(--s4); color: var(--muted); font-size: var(--fs-s); line-height: 1.6; }
.chip { display: inline-flex; align-items: center; font-size: var(--fs-xs); font-weight: 600; padding: var(--s1) var(--s3); border-radius: var(--r-pill); background: var(--surface); color: var(--ink); }
.chip--cat { background: var(--surface); color: var(--navy); }
.meta { margin: 0 0 var(--s5); display: grid; grid-template-columns: 56px 1fr; gap: var(--s3) var(--s3); align-items: start; }
.meta dt { font-size: var(--fs-xs); color: var(--muted); padding-top: var(--s1); }
.meta dd { margin: 0; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s1); }
.actions { display: grid; gap: var(--s2); }
.btn { min-height: 48px; border-radius: var(--r2); display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); font-size: var(--fs-m); font-weight: 600; text-decoration: none; cursor: pointer; border: 0; padding: 0 var(--s4); }
.btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: #164ad6; }
.btn--ghost { background: var(--surface); color: var(--ink); }
.btn--ghost:hover { background: #e9edf3; }
.btn--done { background: #e6f0ff; color: #0b3fb8; }
.cmd { margin-top: var(--s3); }
.cmd__code { display: block; font: 500 var(--fs-xs)/1.55 var(--mono); background: var(--surface); color: var(--ink); padding: var(--s3); border-radius: var(--r1); overflow-wrap: anywhere; user-select: all; }

/* Tablet */
@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top__mail { display: none; }
}
/* Phone */
@media (max-width: 600px) {
  :root { --pad: 16px; --fs-xl: 26px; }
  .grid { grid-template-columns: 1fr; gap: var(--s5); }
  .logo__sub { display: none; }
  .top__link:not(.top__mail) { padding: 0 var(--s1); }
  .intro { padding-top: var(--s5); }
  .panel {
    top: auto; left: 0; right: 0; width: 100%; max-height: 88vh; max-height: 88dvh;
    border-radius: var(--r2) var(--r2) 0 0; transform: translateY(100%);
  }
  .panel.open { transform: none; }
  .panel__grip { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: var(--s2) auto 0; }
  .panel__head { padding-left: var(--s4); }
  .panel__body { padding: 0 var(--s4) calc(var(--s5) + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
  .top__link:not(.top__mail) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .backdrop, .panel { transition: none; }
}
