[hidden] { display: none !important; }

:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --ink: #1d1f21;
  --ink-2: #5b6066;
  --line: #e2e2de;
  --accent: #1f5f4a;
  --accent-hover: #184c3b;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --warn: #8a5a00;
  --ok: #1f6f43;
  --focus: #2f7d63;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-card: 10px;
  --r-ctl: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121313;
    --surface: #1b1c1d;
    --surface-2: #232526;
    --ink: #e9e9e6;
    --ink-2: #a3a8ad;
    --line: #2e3133;
    --accent: #5cc29b;
    --accent-hover: #74d0ac;
    --on-accent: #0d1a15;
    --danger: #f2a29c;
    --warn: #e8b765;
    --ok: #7fd3a3;
    --focus: #74d0ac;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.6 var(--font);
  font-variant-numeric: tabular-nums;
}
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.site-header .inner { display: flex; align-items: center; gap: 24px; min-height: 56px; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.site-header nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.site-header nav a {
  color: var(--ink-2);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--r-ctl);
  font-size: 0.9375rem;
}
.site-header nav a:hover, .site-header nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }

.inner { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.wide .inner { max-width: 1120px; }
.admin-page .inner { max-width: 1440px; }
main.inner { padding-top: 40px; padding-bottom: 64px; }

h1 { font-size: 1.75rem; line-height: 1.3; margin: 0 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; line-height: 1.4; margin: 40px 0 12px; }
h3 { font-size: 1rem; margin: 24px 0 8px; }
p { margin: 0 0 12px; }
.lead { color: var(--ink-2); max-width: 62ch; margin-bottom: 32px; }
.muted { color: var(--ink-2); font-size: 0.875rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.card-title { margin-top: 0; }
#result:not(:empty) { margin-top: 16px; }
.actions.spaced { margin-top: 16px; }
.after-card { margin-top: 24px; }

form .field { margin-bottom: 20px; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { display: block; color: var(--ink-2); font-size: 0.875rem; margin-top: 6px; }
input[type="text"], input[type="password"], input[type="search"], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 10px 12px;
  min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
input[aria-invalid="true"] { border-color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 96px;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.btn.small { min-height: 36px; min-width: 0; padding: 0 12px; font-size: 0.875rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .pool-input { flex: 0 1 14rem; width: 14rem; }

.alert { border-radius: var(--r-ctl); padding: 12px 14px; margin: 0 0 16px; background: var(--surface-2); }
.alert.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.alert:empty { display: none; }

.chip {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.chip.pending { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
.chip.approved { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.chip.rejected, .chip.revoked { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }

.code-row { display: flex; gap: 8px; align-items: stretch; margin: 8px 0 4px; }
pre, code { font-family: var(--mono); font-size: 0.875rem; }
.code-row pre, pre.block {
  flex: 1;
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--r-ctl);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
pre code { background: none; padding: 0; }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps > li { counter-increment: step; position: relative; padding-left: 40px; margin-bottom: 28px; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.875rem;
  display: grid;
  place-items: center;
}
.steps h3 { margin-top: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button {
  font: inherit;
  background: none;
  border: 0;
  padding: 10px 12px;
  min-height: 44px;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: var(--r-ctl) var(--r-ctl) 0 0;
}
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; background: var(--surface-2); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dl.facts dt { color: var(--ink-2); }
dl.facts dd { margin: 0; word-break: break-all; }

table.users { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
table.users th, table.users td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 0.9375rem; }
table.users th { color: var(--ink-2); font-weight: 600; font-size: 0.8125rem; background: var(--surface-2); }
table.users tr:last-child td { border-bottom: 0; }
table.users .num { text-align: right; white-space: nowrap; }
table.users th, table.users .chip, table.users td[data-label="등급"] { white-space: nowrap; }
#users { overflow-x: auto; }
table.users select { min-width: 7rem; max-width: 11rem; }
table.users td[data-label="허용 모델"] select { margin-top: 6px; }
.claim .code-row pre { font-size: 0.8125rem; }
.purpose { color: var(--ink-2); max-width: 32ch; }

dialog {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--ink);
  padding: 24px;
  width: min(560px, calc(100vw - 32px));
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.inline-check { display: flex; gap: 8px; align-items: center; min-height: 36px; margin: 8px 0; }
.inline-check input { width: 18px; height: 18px; accent-color: var(--accent); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.inline-form .field { margin-bottom: 0; }
.page-head .lead { margin-bottom: 24px; }
.page-head .lead code { font-size: 0.875rem; }
.gate { max-width: 640px; }
.inline-form.single { grid-template-columns: 1fr auto; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px 18px; min-width: 0; }
.stat-label { margin: 0 0 6px; font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }
.stat-value { margin: 0; font-size: 1.75rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
.stat-value.small { font-size: 1.25rem; padding: 4px 0 3px; }
.stat-sub { margin: 4px 0 0; color: var(--ink-2); font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer { margin-bottom: 16px; }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.viewer-head .card-title { margin: 0; }
.viewer-bar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: end; margin-bottom: 12px; }
.viewer-bar .tabs { margin-bottom: 0; border-bottom: 0; }
.search { display: flex; gap: 8px; }
.search input { width: 16rem; }
.graph-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
.graph-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); min-height: 300px; }
.graph-box { overflow: hidden; }
.constellation { display: block; width: 100%; height: min(72vh, 680px); background: #09090b; cursor: grab; touch-action: none; }
.constellation:active { cursor: grabbing; }
.memory-table { max-height: min(72vh, 680px); overflow: auto; }
.memory-table table.users { border: 0; border-radius: 0; table-layout: fixed; }
.memory-table th:first-child { width: 52%; }
.memory-table td { overflow-wrap: anywhere; }
.link-button { all: unset; display: block; max-height: 4.5em; overflow: hidden; cursor: pointer; color: var(--ink); }
.link-button:hover { text-decoration: underline; }
.link-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { background: transparent; border: 0; color: var(--ink-2); padding: 6px 14px; font: inherit; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-right: auto; }
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-2); padding: 4px 10px; font: inherit; font-size: 0.8125rem; cursor: pointer; }
.chip-toggle[aria-pressed="true"] { color: var(--ink); background: var(--surface-2); }
.chip-toggle[aria-pressed="false"] .dot { opacity: 0.3; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.skill-cell { display: grid; gap: 6px; justify-items: start; }
.skill-group { border-top: 1px solid var(--line); padding: 8px 0; }
.skill-group summary { cursor: pointer; font-weight: 600; }
.skill-group summary label { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.skill-list { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.skill-list .muted { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-semantic { background: #0074d9; }
.link-temporal { background: #009296; }
.link-entity { background: #f59e0b; }
.link-causal { background: #8b5cf6; }
.detail { background: var(--surface-2); border-radius: var(--r-card); padding: 16px 18px; align-self: start; max-height: min(72vh, 680px); overflow: auto; }
.detail-title { margin: 0 0 12px; font-size: 0.9375rem; }
.detail dd { white-space: pre-wrap; }
dl.facts.stacked { grid-template-columns: 1fr; gap: 2px; }
dl.facts.stacked dt { font-size: 0.8125rem; }
dl.facts.stacked dd { margin-bottom: 10px; }
.recent-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.recent-item { all: unset; box-sizing: border-box; display: flex; gap: 16px; justify-content: space-between; align-items: baseline; width: 100%; padding: 10px 12px; border-radius: var(--r-ctl); cursor: pointer; }
.recent-item:hover { background: var(--surface-2); }
.recent-item:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.recent-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { flex: none; color: var(--ink-2); font-size: 0.8125rem; }

.site-footer { color: var(--ink-2); font-size: 0.875rem; padding: 24px 0 40px; border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .inline-form, .inline-form.single, .graph-layout { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 1.375rem; }
  .constellation { height: 56vh; }
  .detail { max-height: none; }
  .search input { width: 100%; }
  table.users thead { display: none; }
  table.users, table.users tbody, table.users tr, table.users td { display: block; width: 100%; }
  table.users tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.users td { border: 0; padding: 6px 12px; }
  table.users td[data-label]::before { content: attr(data-label); display: block; color: var(--ink-2); font-size: 0.8125rem; }
  table.users .num { text-align: left; }
  .code-row { flex-direction: column; }
  dl.facts { grid-template-columns: 1fr; gap: 2px; }
  dl.facts dd { margin-bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active { transform: none; }
}
