:root {
  --ink: #17223a;
  --muted: #617087;
  --surface: #ffffff;
  --canvas: #f3f6fa;
  --line: #d9e1ec;
  --line-strong: #aab8ca;
  --brand: #174f83;
  --brand-dark: #103b63;
  --brand-soft: #e8f2fb;
  --accent: #a65308;
  --success: #177348;
  --success-soft: #e5f5ed;
  --danger: #a92c32;
  --danger-soft: #fcebec;
  --warning-soft: #fff4dd;
  --shadow: 0 8px 30px rgba(35, 55, 80, 0.08);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
}

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

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

:focus-visible {
  outline: 3px solid #f2a43c;
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 8px 14px;
  color: #fff;
  background: #000;
  border-radius: 5px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: none;
}

.site-header {
  color: #fff;
  background: linear-gradient(125deg, #0e355b, #17669b 68%, #188179);
}

.header-inner {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 38px;
}

.eyebrow,
.step-label {
  margin: 0 0 2px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.25;
}

.header-description {
  max-width: 820px;
  margin: 10px 0 0;
  color: #edf7ff;
}

.page-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 24px auto 60px;
}

.panel {
  margin-bottom: 18px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 17px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.35;
}

.step-label {
  color: var(--brand);
}

.connection-panel {
  padding-block: 18px;
}

.state-badge,
.tag,
.requirement,
.optional {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.state-badge {
  padding: 4px 10px;
  color: var(--muted);
  background: #edf1f6;
}

.state-badge[data-state="connected"] {
  color: var(--success);
  background: var(--success-soft);
}

.state-badge[data-state="error"] {
  color: var(--danger);
  background: var(--danger-soft);
}

.api-key-row,
.search-form {
  display: grid;
  gap: 14px;
}

.api-key-row {
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
}

.search-form {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
}

.search-form .field {
  grid-column: span 2;
}

.search-form .field-wide {
  grid-column: span 3;
}

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.88rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 8px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.field input:hover,
.field select:hover {
  border-color: var(--brand);
}

.field-help,
.muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.field-help {
  margin: 4px 0 0;
}

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

.button {
  min-height: 40px;
  padding: 7px 14px;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 8px;
}

.button.primary {
  color: #fff;
  background: var(--brand);
}

.button.primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

.button.secondary {
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-color: #b7d3eb;
}

.button.quiet {
  color: var(--ink);
  background: #fff;
  border-color: var(--line-strong);
}

.button.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #efbdc0;
}

.button.small {
  min-height: 34px;
  padding: 4px 9px;
  font-size: 0.8rem;
}

.button[aria-pressed="true"] {
  color: #fff;
  background: var(--success);
  border-color: var(--success);
}

.search-actions {
  grid-column: span 3;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.side-column {
  min-width: 0;
}

.result-heading {
  align-items: center;
}

.result-count {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.item-list,
.selection-list,
.children-list,
.breadcrumbs ol {
  padding: 0;
  list-style: none;
}

.item-list {
  margin: 0;
}

.result-card {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.result-card[data-selected="true"] {
  border-color: #61a780;
  box-shadow: inset 4px 0 0 var(--success);
}

.item-meta,
.item-actions,
.selection-actions,
.children-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.item-meta {
  justify-content: space-between;
  margin-bottom: 7px;
}

.tag {
  padding: 2px 8px;
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.item-code {
  color: #394b62;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.item-statement {
  margin: 7px 0 12px;
  line-height: 1.7;
}

.item-actions {
  margin-top: 12px;
}

.empty-state {
  margin: 8px 0;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background: #f7f9fc;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}

.empty-state.compact {
  padding: 16px;
  font-size: 0.88rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding-top: 8px;
}

.breadcrumbs {
  margin-bottom: 14px;
  overflow-x: auto;
}

.breadcrumbs ol {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: max-content;
  margin: 0;
}

.breadcrumbs li:not(:last-child)::after {
  content: "›";
  margin-left: 6px;
  color: var(--muted);
}

.breadcrumb-button {
  padding: 2px 4px;
  color: var(--brand);
  background: transparent;
  border: 0;
  text-decoration: underline;
}

.context-current {
  padding: 14px;
  background: #f7fafc;
  border-left: 4px solid var(--brand);
  border-radius: 7px;
}

.context-current .item-statement {
  margin-bottom: 8px;
}

.children-heading {
  justify-content: space-between;
  margin-top: 18px;
}

.children-heading h3,
.selection-group h3,
.cli-block h3 {
  margin: 0;
  font-size: 0.96rem;
}

.children-list {
  margin: 8px 0 0;
}

.child-item {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.child-link {
  width: 100%;
  padding: 0;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
}

.child-link:hover {
  color: var(--brand);
  text-decoration: underline;
}

.selection-group + .selection-group {
  margin-top: 20px;
}

.selection-group h3 {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-bottom: 8px;
}

.requirement,
.optional {
  padding: 1px 7px;
}

.requirement {
  color: var(--accent);
  background: var(--warning-soft);
}

.optional {
  color: var(--muted);
  background: #edf1f6;
}

.selection-slot,
.selection-entry {
  padding: 11px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.selection-list {
  margin: 0;
}

.selection-entry + .selection-entry {
  margin-top: 8px;
}

.selection-title {
  margin: 0 0 6px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.selection-actions {
  justify-content: flex-end;
}

.json-output {
  display: block;
  width: 100%;
  padding: 14px;
  color: #152139;
  background: #f8fafc;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  resize: vertical;
}

.cli-block {
  margin-top: 20px;
}

pre {
  margin: 8px 0 0;
  padding: 14px;
  overflow-x: auto;
  color: #ecf5ff;
  background: #17263a;
  border-radius: 9px;
}

pre code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.82rem;
}

.global-status {
  position: sticky;
  z-index: 20;
  bottom: 14px;
  width: fit-content;
  max-width: min(720px, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: 0;
  color: #fff;
  background: #28394e;
  border-radius: 9px;
  box-shadow: var(--shadow);
}

.global-status:not(:empty) {
  padding: 9px 14px;
}

.global-status[data-kind="error"] {
  background: var(--danger);
}

.global-status[data-kind="success"] {
  background: var(--success);
}

.noscript-message {
  margin: 20px;
  padding: 15px;
  color: var(--danger);
  background: var(--danger-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .work-grid {
    grid-template-columns: 1fr;
  }

  .search-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-form .field,
  .search-form .field-wide {
    grid-column: span 1;
  }

  .search-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 650px) {
  .header-inner,
  .page-shell {
    width: min(100% - 24px, 1280px);
  }

  .header-inner {
    padding-block: 25px 28px;
  }

  .page-shell {
    margin-top: 12px;
  }

  .panel {
    padding: 16px;
    border-radius: 11px;
  }

  .api-key-row,
  .search-form {
    grid-template-columns: 1fr;
  }

  .search-form .field,
  .search-form .field-wide,
  .search-actions {
    grid-column: 1;
  }

  .api-key-actions,
  .search-actions {
    width: 100%;
  }

  .api-key-actions .button,
  .search-actions .button {
    flex: 1;
  }

  .section-heading {
    flex-wrap: wrap;
  }

  .output-panel .section-heading .button {
    width: 100%;
  }

  .pagination {
    justify-content: space-between;
    gap: 6px;
  }
}
