:root {
  --ink:            #0f1c2e;
  --ink-soft:       #4a5a70;
  --ink-faint:      #8494a8;
  --line:           #dfe5ed;
  --line-soft:      #edf1f6;
  --bg:             #f4f7fb;
  --surface:        #ffffff;
  --accent:         #0b64c8;
  --accent-deep:    #084a95;
  --accent-wash:    #e8f1fc;
  --good:           #128a5a;
  --warn:           #b26a00;
  --radius:         12px;
  --radius-sm:      8px;
  --shadow:         0 1px 2px rgba(15,28,46,.05), 0 8px 24px rgba(15,28,46,.06);
  --shadow-lift:    0 2px 6px rgba(15,28,46,.08), 0 16px 40px rgba(15,28,46,.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI",
               "Noto Sans JP", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- topbar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.corp {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  text-decoration: none;
  color: inherit;
}

.corp-mark {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  background: linear-gradient(140deg, #0f1c2e 0%, #26456e 100%);
  display: grid;
  place-items: center;
}

.corp-mark svg { width: 19px; height: 19px; display: block; }

.corp-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.012em;
  white-space: nowrap;
  color: var(--ink);
}

.corp-name span { color: var(--accent); }

.corp:hover .corp-name { color: var(--accent-deep); }

.brand-sep {
  width: 1px;
  height: 26px;
  flex: none;
  background: var(--line);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
  min-width: 0;
}

.brand-text strong {
  font-size: 15px;
  letter-spacing: .01em;
}

.brand-text em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: .02em;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.pill {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill[data-state="checking"] { background: #f0f3f7; color: var(--ink-faint); }
.pill[data-state="ok"]       { background: #e4f5ec; color: var(--good); }
.pill[data-state="ng"]       { background: #fdeeee; color: #c0392b; }

.pill-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
  font-weight: 500;
}

/* ---------------- layout ---------------- */

.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 85px;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ---------------- cards ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--ink-faint);
  text-transform: uppercase;
}

.lede {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--ink-soft);
}

.kv {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.kv > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  background: var(--surface);
  padding: 8px 11px;
}

.kv dt {
  font-size: 12px;
  color: var(--ink-faint);
  flex: none;
}

.kv dd {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.src-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.src-link::after {
  content: "↗";
  font-size: 11px;
}

.src-link:hover { text-decoration: underline; }

/* ---------------- categories ---------------- */

.cats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cats li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.cats li:hover { background: var(--accent-wash); }

.cat-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cat-id {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-wash);
  padding: 1px 5px;
  border-radius: 4px;
  flex: none;
  font-variant-numeric: tabular-nums;
}

.cat-count {
  font-size: 11.5px;
  color: var(--ink-faint);
  flex: none;
  font-variant-numeric: tabular-nums;
}

/* ---------------- flow ---------------- */

.flow {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: none;
}

.flow li {
  position: relative;
  padding: 0 0 14px 26px;
}

.flow li:last-child { padding-bottom: 0; }

.flow li::before {
  content: attr(data-step);
  position: absolute;
  left: 0;
  top: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.flow li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 22px;
  bottom: 2px;
  width: 1px;
  background: var(--line);
}

.flow-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
}

.flow-detail {
  display: block;
  font-size: 11.5px;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* ---------------- notes ---------------- */

.card-note {
  background: #fffdf7;
  border-color: #f0e4c8;
}

.card-note .card-title { color: var(--warn); }

.notes {
  margin: 0;
  padding-left: 17px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.notes li { margin-bottom: 5px; }
.notes li:last-child { margin-bottom: 0; }

/* ---------------- samples ---------------- */

.samples {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.samples-title {
  margin: 0 0 11px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--ink-faint);
  text-transform: uppercase;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.samples-hint {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-faint);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  font: inherit;
  font-size: 12.5px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chip:hover {
  background: var(--accent-wash);
  border-color: #b6d4f5;
}

.chip:active { transform: translateY(1px); }

.chip-cat {
  font-size: 10.5px;
  color: var(--ink-faint);
}

.chip.is-copied {
  background: #e4f5ec;
  border-color: #a9dcc4;
}

/* ---------------- chat ---------------- */

.chat-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcfe, #f5f8fc);
  font-size: 13px;
  font-weight: 600;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  flex: none;
  box-shadow: 0 0 0 3px rgba(18,138,90,.14);
}

.chat-head-sub {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-faint);
}

#botFrame {
  width: 100%;
  height: min(74vh, 720px);
  min-height: 480px;
  border: 0;
  display: block;
  background: #fff;
}

.chat-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  background: #fafbfd;
  font-size: 11.5px;
  color: var(--ink-faint);
}

.chat-foot a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.chat-foot a:hover { text-decoration: underline; }

.chat-foot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--ink-soft);
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 14px);
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  padding: 9px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(15,28,46,.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 50;
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript {
  max-width: 1320px;
  margin: 24px auto;
  padding: 14px 18px;
  background: #fdeeee;
  border: 1px solid #f3c9c9;
  border-radius: var(--radius);
}

/* ---------------- responsive ---------------- */

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .side {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
  #botFrame { height: 68vh; }
}

@media (max-width: 560px) {
  .topbar-inner { padding: 12px 16px; }
  .brand-text em { display: none; }
  .brand-text strong { font-size: 13px; }
  .corp-name { font-size: 13.5px; }
  .side { grid-template-columns: 1fr; }
  #botFrame { height: 72vh; min-height: 420px; }
}
