<!doctype html>
<html lang="ko">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- 테마 초기화: 스타일 적용 전에 data-theme 설정해 FOUC 방지
       (저장된 선택 → 없으면 OS 선호) -->
  <script>
    (function () {
      try {
        var t = localStorage.getItem("theme");
        if (t !== "dark" && t !== "light") {
          t = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
        }
        document.documentElement.setAttribute("data-theme", t);
      } catch (e) {}
    })();
  </script>
  <title>{% block title %}Pulp 패치 관리 콘솔{% endblock %}</title>
  <link rel="icon" href="/static/favicon.svg" type="image/svg+xml">
  <!-- 정적 자산은 폐쇄망 대비 local 동봉 (CDN 의존 금지, 스펙 §9) -->
  <link rel="stylesheet" href="/static/pico.min.css">
  <link rel="stylesheet" href="/static/app.css">
  <script src="/static/htmx.min.js" defer></script>
</head>
<body>
  <nav class="app-nav">
    <div class="container">
      <p class="brand"><span class="accent">Pulp</span> 패치 관리 콘솔</p>
      <button class="theme-toggle" type="button" onclick="toggleTheme()"
              aria-label="라이트/다크 전환" title="라이트/다크 전환">
        <svg class="icon moon" viewBox="0 0 24 24" width="18" height="18" fill="none"
             stroke="currentColor" stroke-width="1.8" stroke-linecap="round"
             stroke-linejoin="round" aria-hidden="true">
          <path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>
        </svg>
        <svg class="icon sun" viewBox="0 0 24 24" width="18" height="18" fill="none"
             stroke="currentColor" stroke-width="1.8" stroke-linecap="round"
             stroke-linejoin="round" aria-hidden="true">
          <circle cx="12" cy="12" r="4"/>
          <path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/>
        </svg>
      </button>
    </div>
  </nav>
  <main class="container">
    {% block content %}{% endblock %}
  </main>
  <script>
    function toggleTheme() {
      var next =
        document.documentElement.getAttribute("data-theme") === "dark"
          ? "light"
          : "dark";
      document.documentElement.setAttribute("data-theme", next);
      try { localStorage.setItem("theme", next); } catch (e) {}
    }
  </script>
</body>
</html>
