:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-strong: #f0f2f5;
  --line: #d9dee7;
  --text: #1e2329;
  --muted: #626b78;
  --green: #16774c;
  --green-bg: #e4f4ec;
  --amber: #9a6500;
  --amber-bg: #fff1d2;
  --blue: #1f5da8;
  --blue-bg: #e8f1ff;
  --red: #a83333;
  --red-bg: #ffe7e7;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  font-size: 14px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar-meta {
  margin-left: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.topnav {
  display: flex;
  gap: 8px;
}

.nav-tab {
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.nav-tab.selected {
  color: var(--blue);
  border-color: var(--blue);
  background: var(--blue-bg);
}

.layout {
  display: grid;
  gap: 18px;
  padding: 22px 32px 40px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  text-align: left;
  min-height: 84px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
}

.metric:hover {
  border-color: #aeb8c7;
}

.metric.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(31, 93, 168, 0.16);
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
}

.metric.pass strong {
  color: var(--green);
}

.metric.gap strong {
  color: var(--amber);
}

.metric.ready strong {
  color: var(--blue);
}

.metric.decision strong {
  color: var(--red);
}

.toolbar,
.completed-section,
.table-section,
.api-doc-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toolbar {
  display: grid;
  grid-template-columns: 200px 160px 160px minmax(240px, 1fr);
  gap: 12px;
  padding: 14px;
}

.toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toolbar input,
.toolbar select,
.toolbar textarea {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.api-toolbar {
  grid-template-columns: minmax(170px, 1fr) 110px 140px 140px 120px 140px minmax(220px, 1.3fr) 110px;
  align-items: end;
}

.docs-toolbar {
  grid-template-columns: minmax(260px, 1fr);
}

.primary-action {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

.primary-action:hover {
  background: #174b89;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 0;
}

.section-title p {
  margin-bottom: 0;
  color: var(--muted);
}

.history-title {
  align-items: center;
}

.collapse-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.collapse-button:hover {
  border-color: #aeb8c7;
  color: var(--text);
  background: var(--surface-strong);
}

.collapse-chevron {
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.16s ease;
}

.collapse-button.collapsed .collapse-chevron {
  transform: translateX(-1px) rotate(-45deg);
}

.completed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.completed-card {
  display: grid;
  grid-template-columns: minmax(220px, 42%) 1fr;
  overflow: hidden;
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.completed-card:hover {
  border-color: #aeb8c7;
}

.card-media {
  height: 100%;
  margin: 0;
  border-right: 1px solid var(--line);
  background: var(--surface-strong);
}

.card-media img,
.card-media iframe {
  display: block;
  width: 100%;
  height: 210px;
  object-fit: cover;
  border: 0;
}

.card-media figcaption,
.artifact-preview figcaption {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.completed-body {
  padding: 16px;
}

.completed-body p {
  color: var(--muted);
  line-height: 1.55;
}

.card-head,
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.card-meta {
  justify-content: flex-start;
  margin-top: 16px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.card-meta span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
}

.status,
.risk {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status.pass {
  color: var(--green);
  background: var(--green-bg);
}

.status.gap {
  color: var(--amber);
  background: var(--amber-bg);
}

.status.ready {
  color: var(--blue);
  background: var(--blue-bg);
}

.status.decision {
  color: var(--red);
  background: var(--red-bg);
}

.status.partial {
  color: var(--amber);
  background: var(--amber-bg);
}

.status.issue {
  color: var(--red);
  background: var(--red-bg);
}

.status.reviewed {
  color: var(--green);
  background: var(--green-bg);
}

.status.waived {
  color: var(--blue);
  background: var(--blue-bg);
}

.status.muted,
.risk {
  color: var(--muted);
  background: var(--surface-strong);
}

.active-work {
  display: inline-flex;
  width: fit-content;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-bg);
  font-size: 12px;
  font-weight: 700;
}

.risk.high,
.risk.critical {
  color: var(--red);
  background: var(--red-bg);
}

.risk.medium {
  color: var(--amber);
  background: var(--amber-bg);
}

.risk.unknown {
  color: var(--muted);
  background: var(--surface-strong);
}

.risk.low {
  color: var(--green);
  background: var(--green-bg);
}

.table-wrap {
  overflow: auto;
  padding: 14px 18px 18px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.api-table {
  min-width: 1240px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

td span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

tr {
  cursor: pointer;
}

.unimplemented-item {
  opacity: 0.5;
}

tr:hover {
  background: #fafbfc;
}

.slice-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

.method-badge {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  min-height: 24px;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 6px;
  color: #fff;
  background: #2f3947;
  font-size: 12px;
  font-weight: 800;
}

.api-path {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-bg);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.source-badge.managed {
  color: var(--green);
  background: var(--green-bg);
}

.api-doc-list {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.api-doc-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.api-doc-card:hover {
  border-color: #aeb8c7;
}

.api-doc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.api-doc-head p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.api-doc-head h2 {
  line-height: 1.35;
}

.api-doc-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.api-doc-path {
  padding: 10px 12px;
  border-radius: 6px;
  overflow-wrap: anywhere;
  color: var(--text);
  background: var(--surface-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.api-doc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.api-doc-block {
  display: grid;
  gap: 8px;
}

.api-doc-block h3 {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.api-doc-block pre {
  min-height: 88px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #fbfcfd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.api-doc-meta {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.api-doc-meta div {
  min-width: 0;
}

.api-doc-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.api-doc-meta dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.detail-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(720px, 94vw);
  overflow: auto;
  padding: 24px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(23, 31, 42, 0.18);
  transform: translateX(100%);
  transition: transform 160ms ease;
  z-index: 20;
}

.detail-panel[aria-hidden="false"] {
  transform: translateX(0);
}

.panel-actions {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-bottom: 12px;
  background: var(--surface);
  z-index: 2;
}

.panel-close,
.panel-download {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.panel-download {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.panel-download:disabled {
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface-strong);
  cursor: not-allowed;
}

.detail-heading {
  display: grid;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.detail-list div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-list dd {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.detail-copy {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  line-height: 1.6;
}

.api-form {
  display: grid;
  gap: 14px;
}

.api-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.api-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.api-form input,
.api-form select,
.api-form textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.api-form textarea {
  min-height: 86px;
  resize: vertical;
}

.api-form .wide {
  grid-column: 1 / -1;
}

.form-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.active-sessions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.active-sessions div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.active-sessions span {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 12px;
}

.artifact-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.artifact-preview {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.selectable-artifact {
  cursor: pointer;
}

.selectable-artifact:hover {
  border-color: #aeb8c7;
}

.selected-artifact {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(31, 93, 168, 0.16);
}

.artifact-preview img,
.artifact-preview iframe {
  display: block;
  width: 100%;
  height: 360px;
  object-fit: contain;
  border: 0;
  background: var(--surface-strong);
}

.file-preview {
  display: block;
  padding: 16px;
  color: var(--blue);
  text-decoration: none;
}

.empty-media,
.empty-text {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  background: var(--surface-strong);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--red);
  z-index: 40;
}

.toast.success {
  background: var(--green);
}

@media (max-width: 1100px) {
  .toolbar,
  .api-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .topbar-meta {
    margin-left: 0;
  }

  .layout {
    padding: 18px;
  }

  .metrics,
  .toolbar,
  .api-toolbar {
    grid-template-columns: 1fr;
  }

  .completed-card {
    grid-template-columns: 1fr;
  }

  .card-media {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .api-form-grid {
    grid-template-columns: 1fr;
  }

  .api-doc-head {
    flex-direction: column;
  }

  .api-doc-status {
    justify-content: flex-start;
  }

  .api-doc-grid,
  .api-doc-meta {
    grid-template-columns: 1fr;
  }
}
