/* DRM prototype base styles */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-body)/1.7 var(--font-sans);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--soul); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: .04em; font-weight: 700; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
p { margin: 0 0 var(--s4); }
.en-display { font-family: var(--font-display); letter-spacing: .08em; }
.muted { color: var(--text-2); }
.small { font-size: var(--fs-small); }
code, pre, kbd, samp { font-family: var(--font-mono); }
.mono { font-family: var(--font-mono); font-size: var(--fs-mono); }
.nowrap { white-space: nowrap; }
.mod-name { white-space: pre; font-family: var(--font-mono); letter-spacing: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--soul); outline-offset: 2px; }

.container { width: 100%; max-width: calc(var(--content-max) + var(--page-pad) * 2); margin: 0 auto; padding: 0 var(--page-pad); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(14, 12, 18, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .container { display: flex; align-items: center; gap: var(--s5); height: 64px; }
.brand { display: flex; align-items: center; gap: var(--s3); color: var(--text); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 36px; flex-shrink: 0; }
.brand-word { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .18em; white-space: nowrap; }
.brand-short { display: none; font-family: var(--font-display); font-weight: 700; letter-spacing: .18em; }
.nav { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.nav a, .nav button.linklike {
  color: var(--text); padding: 10px 12px; min-height: 44px; display: inline-flex; align-items: center;
  position: relative; white-space: nowrap; font-size: 15px;
}
.nav a:hover { text-decoration: none; color: var(--soul); }
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 6px; height: 2px; background: var(--soul);
}
.lang-toggle { display: inline-flex; border: 1px solid var(--line); margin-left: var(--s2); }
.lang-toggle button {
  background: none; border: 0; color: var(--text-2); font: inherit; font-size: 14px;
  min-width: 44px; min-height: 36px; cursor: pointer;
}
.lang-toggle button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.user-chip { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text-2); font-size: 14px; padding: 0 var(--s2); white-space: nowrap; }
.user-chip .who { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
button.user-chip { background: none; border: 1px solid transparent; font: inherit; font-size: 14px; min-height: 40px; cursor: pointer; }
button.user-chip:hover, button.user-chip[aria-expanded="true"] { border-color: var(--line); color: var(--text); }
.user-chip .caret { font-size: 10px; opacity: .7; }
.avatar { flex-shrink: 0; width: 28px; height: 28px; border: 1px solid var(--brass); border-radius: 50%; overflow: hidden; display: inline-grid; place-items: center; color: var(--brass); font-family: var(--font-display); font-size: 13px; background: var(--surface-2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-menu { position: relative; }
.user-menu .user-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 180px; padding: 6px; z-index: 50; display: flex; flex-direction: column; background: var(--surface); }
.user-menu .user-pop[hidden] { display: none; }
.nav .user-pop a { padding: 10px 12px; min-height: 40px; color: var(--text-2); font-size: 14px; white-space: nowrap; }
.nav .user-pop a:hover, .nav .user-pop a:focus-visible, .nav .user-pop a[aria-current="page"] { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav .user-pop a[aria-current="page"]::after { content: none; }
.nav .user-pop a[data-logout] { border-top: 1px solid var(--line); margin-top: 4px; }
.menu-btn { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: var(--text); width: 44px; height: 44px; cursor: pointer; }
.mobile-menu { display: none; }

@media (max-width: 1023px) {
  .brand-word { display: none; }
  .brand-short { display: inline; }
}
@media (max-width: 767px) {
  .nav { display: none; }
  .menu-btn { display: inline-grid; place-items: center; }
  .site-header .lang-toggle { margin-left: 0; }
  .mobile-menu[data-open="true"] {
    display: block; border-top: 1px solid var(--line); background: var(--surface);
  }
  .mobile-menu a, .mobile-menu .user-chip { display: flex; min-height: 48px; align-items: center; padding: 0 var(--page-pad); color: var(--text); border-bottom: 1px solid var(--line); }
}

/* ---------- notice bar ---------- */
.notice-bar { background: rgba(232, 176, 74, .12); border-bottom: 1px solid rgba(232, 176, 74, .4); color: var(--text); font-size: 14px; }
.notice-bar .container { display: flex; align-items: center; gap: var(--s3); min-height: 44px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.notice-bar .icon { color: var(--warn); flex-shrink: 0; }
.notice-bar button { margin-left: auto; }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--surface-2); --btn-fg: var(--text); --btn-bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s5);
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-bd);
  font: inherit; font-weight: 700; font-size: 15px; letter-spacing: .04em; white-space: nowrap;
  cursor: pointer; text-decoration: none !important;
  clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer));
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { filter: brightness(.92); }
.btn-primary { --btn-bg: var(--soul); --btn-fg: var(--soul-ink); --btn-bd: var(--soul); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--soul); --btn-bd: var(--soul); }
.btn-ghost, .btn-danger { position: relative; }
.btn-ghost::before, .btn-danger::before { content: ""; position: absolute; top: 0; left: 0; width: calc(var(--chamfer) * 1.42); height: 1px; background: var(--btn-bd); transform-origin: 0 0; transform: translateY(var(--chamfer)) rotate(-45deg); }
.btn-ghost:not(.is-loading)::after, .btn-danger:not(.is-loading)::after { content: ""; position: absolute; bottom: 0; right: 0; width: calc(var(--chamfer) * 1.42); height: 1px; background: var(--btn-bd); transform-origin: 100% 100%; transform: translateY(calc(var(--chamfer) * -1)) rotate(-45deg); }
.btn-danger { --btn-bg: transparent; --btn-fg: var(--danger); --btn-bd: var(--danger); }
.btn-small { min-height: 36px; padding: 0 var(--s4); font-size: 14px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; filter: none; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.btn-block { width: 100%; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- framed panels (brass corners) ---------- */
.panel {
  position: relative; background: var(--surface);
  clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer));
}
.frame { position: relative; }
.frame::before, .frame::after {
  content: ""; position: absolute; width: 18px; height: 18px; pointer-events: none; z-index: 2;
  border-color: var(--brass); border-style: solid; opacity: .8;
}
.frame::before { top: 0; left: 0; border-width: 1px 0 0 1px; }
.frame::after { bottom: 0; right: 0; border-width: 0 1px 1px 0; }

/* section heading with sigil */
.sec-title { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s5); }
.sec-title .sigil { width: 18px; height: 18px; color: var(--brass); flex-shrink: 0; }
.sec-title .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 2px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; border: 1px solid currentColor; line-height: 1.6;
}
.badge-pending { color: var(--warn); }
.badge-ok { color: var(--soul); }
.badge-bad { color: var(--danger); }
.badge-muted { color: var(--text-2); }
.badge-brass { color: var(--brass); }
.badge .dot { width: 6px; height: 6px; background: currentColor; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: var(--s5); }
.field label { font-size: 14px; font-weight: 700; }
.field .hint { font-size: var(--fs-small); color: var(--text-2); }
.field .error { font-size: var(--fs-small); color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 0;
  font: inherit; font-size: 15px;
}
textarea.input { min-height: 120px; resize: vertical; font-family: var(--font-mono); font-size: 14px; }
.input::placeholder { color: #968E82; }
.input:focus { outline: 2px solid var(--soul); outline-offset: 0; border-color: transparent; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.check { display: flex; gap: var(--s3); align-items: flex-start; min-height: 44px; font-size: 14px; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--soul); flex-shrink: 0; }

/* ---------- code ---------- */
.code {
  position: relative; background: var(--surface-2); border-left: 2px solid var(--brass);
  margin: var(--s3) 0 var(--s4);
}
.code pre { margin: 0; padding: var(--s4) var(--s4); padding-right: 96px; overflow-x: auto; font-family: var(--font-mono); font-size: var(--fs-mono); line-height: 1.6; color: var(--text); white-space: pre; }
.code .tools { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 6px 6px 0; }
.code .lang-tag { font-size: 11px; color: var(--text-2); font-family: var(--font-mono); }
.code pre { padding: var(--s1) var(--s4) var(--s4); }

/* ---------- scene banners ---------- */
.scene-banner { position: relative; height: 200px; overflow: hidden; border-bottom: 1px solid var(--line); background: var(--void); }
.scene-banner img, .scene-banner picture { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scene-banner[data-scene="sanctum"] img { object-position: 50% 38%; }
.scene-banner[data-scene="amber-hall"] img { object-position: 50% 40%; }
.scene-banner[data-scene="violet-plaza"] img { object-position: 50% 30%; }
.scene-banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14,12,18,0) 30%, rgba(14,12,18,.75) 78%, var(--bg)); }
.scene-banner .container { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: var(--s5); }
.scene-banner .kicker { font-family: var(--font-display); letter-spacing: .2em; font-size: 12px; color: var(--brass); }
@media (max-width: 639px) { .scene-banner { height: 140px; } }

.page-body { padding-top: var(--s7); padding-bottom: var(--s8); }
@media (max-width: 639px) { .page-body { padding-top: var(--s5); padding-bottom: var(--s7); } }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); color: var(--text-2); font-size: 14px; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); align-items: center; padding-top: var(--s5); padding-bottom: var(--s5); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--s4); margin-left: auto; }
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--soul); }

/* ---------- empty / misc ---------- */
.empty { padding: var(--s7) var(--s5); text-align: center; border: 1px dashed var(--line); }
.empty p { color: var(--text-2); margin-bottom: var(--s3); }
.callout { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); background: rgba(232,176,74,.08); border: 1px solid rgba(232,176,74,.35); font-size: 14px; margin-bottom: var(--s5); }
.callout .icon { color: var(--warn); flex-shrink: 0; margin-top: 3px; }
.callout.is-error { background: rgba(255,107,91,.08); border-color: rgba(255,107,91,.4); }
.callout.is-error .icon { color: var(--danger); }
.callout.is-info { background: rgba(95,227,208,.06); border-color: rgba(95,227,208,.3); }
.callout.is-info .icon { color: var(--soul); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--soul); color: var(--text); padding: 10px 16px; font-size: 14px; z-index: 100; }

.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 2.4s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--s4); margin: 0; font-size: 14px; }
dl.kv dt { color: var(--text-2); white-space: nowrap; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.tbd { color: var(--warn); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; transition: none !important; }
}
