:root {
  color-scheme: light;
  --canvas: 210 24% 97%;
  --surface: 0 0% 100%;
  --surface-subtle: 210 24% 95%;
  --ink: 215 38% 15%;
  --muted: 215 13% 43%;
  --line: 214 21% 86%;
  --nav: 215 38% 14%;
  --nav-muted: 214 15% 68%;
  --accent: 202 83% 35%;
  --accent-soft: 201 67% 93%;
  --danger: 3 67% 43%;
  --danger-soft: 4 65% 95%;
  --success: 158 54% 31%;
  --warning: 35 85% 38%;
  --focus: 202 90% 43%;
  --radius: 8px;
  --sidebar-width: 248px;
  --z-sidebar: 20;
  --z-scrim: 10;
  --z-toast: 80;
  font-family: "IBM Plex Sans", "Noto Sans KR", "Helvetica Neue", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: hsl(var(--canvas));
}

body {
  margin: 0;
  min-height: 100vh;
  color: hsl(var(--ink));
  background: hsl(var(--canvas));
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: translateY(1px);
}

:focus-visible {
  outline: 3px solid hsl(var(--focus) / 0.42);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

p,
dd,
li {
  text-wrap: pretty;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: white;
  background: hsl(var(--nav));
  border-radius: var(--radius);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

[hidden] {
  display: none !important;
}

.state-screen {
  width: min(100% - 40px, 520px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-content: center;
  justify-items: start;
  padding: 64px 0;
}

.state-screen h1 {
  margin-bottom: 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 8vw, 3.25rem);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.035em;
}

.state-mark,
.brand-mark {
  display: inline-grid;
  place-items: center;
  color: white;
  background: hsl(var(--accent));
  font-weight: 750;
  letter-spacing: -0.04em;
}

.state-mark {
  width: 56px;
  height: 56px;
  margin-bottom: 32px;
  border-radius: 14px;
  box-shadow: 0 12px 32px hsl(var(--accent) / 0.18);
}

.state-mark.danger {
  background: hsl(var(--danger));
}

.state-copy {
  max-width: 52ch;
  margin-bottom: 28px;
  color: hsl(var(--muted));
  font-size: 1.05rem;
  line-height: 1.7;
}

.fine-print {
  margin-top: 20px;
  color: hsl(var(--muted));
  font-size: 0.875rem;
}

.eyebrow {
  margin-bottom: 8px;
  color: hsl(var(--muted));
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.muted {
  color: hsl(var(--muted));
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  z-index: var(--z-sidebar);
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 24px 16px 16px;
  color: white;
  background: hsl(var(--nav));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 9px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

.brand small {
  margin-top: 2px;
  color: hsl(var(--nav-muted));
  font-size: 0.75rem;
}

.primary-nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  color: hsl(var(--nav-muted));
  border-radius: 7px;
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 600;
}

.nav-link:hover,
.nav-link[aria-current="page"] {
  color: white;
  background: hsl(214 31% 22%);
}

.nav-icon {
  width: 20px;
  color: currentColor;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 24px;
}

.session-summary {
  margin: 0 8px 12px;
  color: hsl(var(--nav-muted));
  font-size: 0.75rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.session-summary strong {
  display: block;
  color: white;
  font-size: 0.8125rem;
}

.workspace {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  min-height: 96px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px clamp(20px, 4vw, 48px);
  background: hsl(var(--surface));
  border-bottom: 1px solid hsl(var(--line));
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
}

.topbar .eyebrow {
  margin-bottom: 4px;
}

.environment-badge {
  margin-left: auto;
  padding: 6px 9px;
  color: hsl(var(--muted));
  background: hsl(var(--surface-subtle));
  border-radius: 6px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.75rem;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: none;
  place-items: center;
  color: hsl(var(--ink));
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

#main-content {
  width: min(100%, 1440px);
  padding: 32px clamp(20px, 4vw, 48px) 64px;
}

.page-intro {
  max-width: 72ch;
  margin-bottom: 28px;
  color: hsl(var(--muted));
  line-height: 1.65;
}

.section {
  margin-bottom: 32px;
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--line));
  border-radius: 10px;
  box-shadow: 0 1px 2px hsl(var(--ink) / 0.025);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid hsl(var(--line));
}

.section-header h2,
.section-header h3 {
  margin: 0;
  font-size: 1rem;
}

.section-body {
  padding: 24px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: hsl(var(--line));
  border: 1px solid hsl(var(--line));
  border-radius: 10px;
}

.metric {
  min-height: 132px;
  padding: 24px;
  background: hsl(var(--surface));
}

.metric-label {
  margin-bottom: 16px;
  color: hsl(var(--muted));
  font-size: 0.825rem;
  font-weight: 650;
}

.metric-value {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-variant-numeric: tabular-nums;
}

.metric-note {
  color: hsl(var(--muted));
  font-size: 0.8rem;
}

.module-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.module-link {
  min-height: 96px;
  padding: 20px 24px;
  color: hsl(var(--ink));
  border-right: 1px solid hsl(var(--line));
  border-bottom: 1px solid hsl(var(--line));
  text-decoration: none;
}

.module-link:nth-child(2n) {
  border-right: 0;
}

.module-link strong,
.module-link span {
  display: block;
}

.module-link span {
  margin-top: 8px;
  color: hsl(var(--muted));
  font-size: 0.825rem;
  line-height: 1.5;
}

.module-link:hover strong {
  color: hsl(var(--accent));
}

.domain-group-tabs,
.domain-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.domain-group-tabs {
  margin-bottom: 16px;
}

.domain-tab,
.domain-view-tab {
  min-height: 38px;
  padding: 0 13px;
  color: hsl(var(--muted));
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--line));
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
}

.domain-tab[aria-pressed="true"],
.domain-view-tab[aria-selected="true"] {
  color: white;
  background: hsl(var(--accent));
  border-color: hsl(var(--accent));
}

.domain-view-header {
  align-items: flex-end;
}

.domain-view-header .eyebrow {
  margin-bottom: 5px;
}

.table-action:disabled {
  color: hsl(var(--muted));
  cursor: not-allowed;
  opacity: 0.65;
}

.toolbar,
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}

.field {
  grid-column: span 4;
}

.field.wide {
  grid-column: span 8;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: hsl(var(--ink));
  font-size: 0.8125rem;
  font-weight: 650;
}

.field small {
  display: block;
  margin-top: 6px;
  color: hsl(var(--muted));
  line-height: 1.45;
}

.control {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  color: hsl(var(--ink));
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--line));
  border-radius: 7px;
}

textarea.control {
  min-height: 100px;
  resize: vertical;
}

.control:focus {
  border-color: hsl(var(--focus));
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 100ms, border-color 100ms, color 100ms;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button.primary {
  color: white;
  background: hsl(var(--accent));
}

.button.primary:hover {
  background: hsl(202 83% 29%);
}

.button.secondary {
  color: hsl(var(--ink));
  background: hsl(var(--surface));
  border-color: hsl(var(--line));
}

.button.secondary:hover {
  background: hsl(var(--surface-subtle));
}

.button.quiet {
  color: hsl(var(--nav-muted));
  background: transparent;
  border-color: hsl(214 24% 27%);
}

.button.danger-button {
  color: white;
  background: hsl(var(--danger));
}

.button.full {
  width: 100%;
}

.button.compact {
  min-height: 36px;
  padding-inline: 11px;
  font-size: 0.8rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  padding: 13px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid hsl(var(--line));
}

th {
  color: hsl(var(--muted));
  background: hsl(var(--surface-subtle));
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

td {
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: hsl(var(--canvas));
}

.table-action {
  color: hsl(var(--accent));
  background: transparent;
  border: 0;
  font-weight: 650;
  cursor: pointer;
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  color: hsl(var(--muted));
  background: hsl(var(--surface-subtle));
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.status::before {
  width: 6px;
  height: 6px;
  content: "";
  background: currentColor;
  border-radius: 50%;
}

.status.success {
  color: hsl(var(--success));
  background: hsl(157 48% 94%);
}

.status.warning {
  color: hsl(var(--warning));
  background: hsl(36 80% 94%);
}

.status.danger {
  color: hsl(var(--danger));
  background: hsl(var(--danger-soft));
}

.state-panel {
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 32px;
  color: hsl(var(--muted));
  text-align: center;
}

.state-panel.error {
  color: hsl(var(--danger));
  background: hsl(var(--danger-soft));
}

.spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto 12px;
  border: 2px solid hsl(var(--line));
  border-top-color: hsl(var(--accent));
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid hsl(var(--line));
}

.pagination span {
  margin-right: auto;
  color: hsl(var(--muted));
  font-size: 0.8rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid hsl(var(--line));
  border-left: 1px solid hsl(var(--line));
}

.detail-grid > div {
  min-width: 0;
  padding: 16px;
  border-right: 1px solid hsl(var(--line));
  border-bottom: 1px solid hsl(var(--line));
}

.detail-grid dt {
  margin-bottom: 7px;
  color: hsl(var(--muted));
  font-size: 0.75rem;
  font-weight: 650;
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.detail-grid .span-2 {
  grid-column: 1 / -1;
}

.inline-alert {
  margin-bottom: 20px;
  padding: 12px 14px;
  color: hsl(var(--warning));
  background: hsl(36 80% 94%);
  border-left: 3px solid currentColor;
  font-size: 0.85rem;
  line-height: 1.55;
}

.inline-alert.danger {
  color: hsl(var(--danger));
  background: hsl(var(--danger-soft));
}

.json-view {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  color: hsl(210 30% 90%);
  background: hsl(var(--nav));
  border-radius: 7px;
  font: 0.75rem/1.6 "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast-region {
  position: fixed;
  z-index: var(--z-toast);
  right: 20px;
  bottom: 20px;
  width: min(360px, calc(100vw - 40px));
  display: grid;
  gap: 8px;
}

.toast {
  padding: 14px 16px;
  color: white;
  background: hsl(var(--nav));
  border-radius: 8px;
  box-shadow: 0 12px 36px hsl(var(--ink) / 0.22);
  font-size: 0.875rem;
  line-height: 1.5;
}

.toast.error {
  background: hsl(var(--danger));
}

.dialog {
  width: min(520px, calc(100% - 32px));
  padding: 0;
  color: hsl(var(--ink));
  background: hsl(var(--surface));
  border: 0;
  border-radius: 12px;
  box-shadow: 0 24px 80px hsl(var(--ink) / 0.25);
}

.dialog::backdrop {
  background: hsl(var(--nav) / 0.68);
}

.dialog form {
  padding: 28px;
}

.dialog h2 {
  font-size: 1.35rem;
}

.dialog p:not(.eyebrow) {
  color: hsl(var(--muted));
  line-height: 1.6;
}

.confirm-details {
  margin: 20px 0;
  border-top: 1px solid hsl(var(--line));
}

.confirm-details > div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid hsl(var(--line));
}

.confirm-details dt {
  color: hsl(var(--muted));
  font-size: 0.8rem;
}

.confirm-details dd {
  margin: 0;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.domain-detail-dialog {
  width: min(900px, calc(100% - 32px));
  max-height: min(820px, calc(100% - 32px));
}

.domain-detail-shell {
  padding: 28px;
}

.domain-detail-heading,
.domain-json-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.domain-detail-heading {
  margin-bottom: 20px;
}

.domain-detail-heading h2,
.domain-json-heading h3 {
  margin: 0;
}

.domain-detail-close {
  display: grid;
  font-size: 1.5rem;
}

.domain-json-heading {
  margin: 24px 0 10px;
}

.domain-json-heading h3 {
  font-size: 0.9rem;
}

.domain-json-heading span {
  color: hsl(var(--muted));
  font-size: 0.75rem;
}

.domain-json-view {
  max-height: 360px;
}

.sidebar-scrim {
  position: fixed;
  z-index: var(--z-scrim);
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: hsl(var(--nav) / 0.55);
  border: 0;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms cubic-bezier(0.23, 1, 0.32, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .workspace {
    margin-left: 0;
  }

  .icon-button {
    display: grid;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 80px;
    padding: 14px 16px;
  }

  .topbar h1 {
    font-size: 1.25rem;
  }

  .environment-badge {
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #main-content {
    padding: 24px 16px 48px;
  }

  .section-header,
  .section-body {
    padding: 16px;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .domain-view-tabs {
    width: 100%;
  }

  .domain-detail-shell {
    padding: 20px;
  }

  .module-list,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .module-link {
    border-right: 0;
  }

  .detail-grid .span-2 {
    grid-column: auto;
  }

  .field,
  .field.wide {
    grid-column: 1 / -1;
  }

  .toolbar .button {
    grid-column: 1 / -1;
  }

  .confirm-details > div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
