/* Extracted from structflow_builder.html. Keep structflow_builder.html as the original single-file version. */
:root {
  --navy: #1e2761;
  --blue: #3a56c5;
  --accent: #4fc3f7;
  --green: #00a86b;
  --orange: #e85d00;
  --white: #ffffff;
  --bg: #f4f6fb;
  --bg2: #eaecf5;
  --border: rgba(58, 86, 197, 0.15);
  --border2: rgba(58, 86, 197, 0.3);
  --text: #1a1a2e;
  --muted: #6b7aa1;
  --code-bg: #1a1a2e;
  --code-fg: #e8f4f8;
  --success: #00a86b;
  --warn: #e85d00;
  --err: #c0392b;
  --card: #ffffff;
  --radius: 10px;
  --radius-lg: 16px;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 400;
  min-height: 100vh;
}
/* ── Layout ── */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--navy);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.main {
  padding: 2.5rem 2rem;
  max-width: 820px;
}

/* ── Sidebar ── */
.brand {
  margin-bottom: 2.5rem;
}
.brand-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}
.brand-name {
  font-family: "DM Sans", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
}
.brand-accent {
  color: var(--accent);
}

.step-nav {
  flex: 1;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.25rem;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.step-item.active {
  background: rgba(79, 195, 247, 0.15);
}
.step-item.done .step-num {
  background: var(--accent);
  color: var(--navy);
}
.step-item.active .step-num {
  background: var(--accent);
  color: var(--navy);
}
.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-weight: 500;
  font-family: "DM Mono", monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.step-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.15s;
}
.step-item.active .step-label {
  color: var(--white);
  font-weight: 500;
}
.step-item.done .step-label {
  color: rgba(255, 255, 255, 0.9);
}
.sidebar-footer {
  margin-top: auto;
  padding-top: 1.5rem;
}
.api-status {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 12px;
}
.api-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}
.api-dot.ok {
  background: var(--green);
}
.api-dot.ng {
  background: var(--err);
}
.api-dot.na {
  background: var(--muted);
}

/* ── Main ── */
.page {
  display: none;
}
.page.active {
  display: block;
}

.page-header {
  margin-bottom: 2rem;
}
.page-eyebrow {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--blue);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.page-title {
  font-family: "Noto Sans JP", "Syne", sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.5rem;
}
.page-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
}

/* ── Form controls ── */
.form-group {
  margin-bottom: 1.25rem;
}
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
  transition:
    border 0.15s,
    box-shadow 0.15s;
  outline: none;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(58, 86, 197, 0.1);
}
textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}
select {
  cursor: pointer;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1rem;
}
.chip {
  padding: 5px 13px;
  border-radius: 99px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border2);
  background: var(--white);
  color: var(--muted);
  transition: all 0.15s;
  font-family: "Noto Sans JP", sans-serif;
}
.chip:hover {
  border-color: var(--blue);
}
.chip.sel {
  border-color: var(--blue);
  background: #edf1fb;
  color: var(--blue);
  font-weight: 500;
}

.risk-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.risk-chip {
  flex: 1;
  min-width: 100px;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--white);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  font-family: "Noto Sans JP", sans-serif;
  color: var(--muted);
  transition: all 0.15s;
}
.risk-chip .risk-lbl {
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}
.risk-chip.sel[data-r="low"] {
  border-color: var(--green);
  background: #d4edda;
  color: #155724;
}
.risk-chip.sel[data-r="medium"] {
  border-color: #185fa5;
  background: #e6f1fb;
  color: #185fa5;
}
.risk-chip.sel[data-r="high"] {
  border-color: var(--orange);
  background: #fff3cd;
  color: #856404;
}
.risk-chip.sel[data-r="critical"] {
  border-color: var(--err);
  background: #ffe8e8;
  color: var(--err);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: "Noto Sans JP", sans-serif;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--blue);
  color: var(--white);
}
.btn-primary:hover {
  background: #2d46a8;
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border2);
}
.btn-ghost:hover {
  background: var(--bg2);
}
.btn-success {
  background: var(--green);
  color: var(--white);
}
.btn-success:hover {
  background: #008755;
}
.btn-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  gap: 1rem;
}

/* ── QA rows ── */
.qa-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.qa-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  font-family: "DM Mono", monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.qa-row input {
  margin-bottom: 0;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.card-tight {
  padding: 0.9rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}
.field-name {
  font-family: "DM Mono", monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--blue);
}
.field-req {
  font-size: 10px;
  color: var(--err);
  margin-left: 6px;
  font-family: "Noto Sans JP", sans-serif;
}
.badge {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 99px;
  font-weight: 500;
  font-family: "DM Mono", monospace;
}
.b-search {
  background: #d4edda;
  color: #155724;
}
.b-filter {
  background: #e6f1fb;
  color: #185fa5;
}
.b-fact {
  background: #fff3cd;
  color: #856404;
}
.b-mgmt {
  background: var(--bg2);
  color: var(--muted);
}
.field-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.field-enum {
  margin-top: 0.35rem;
  font-size: 12px;
  font-family: "DM Mono", monospace;
  color: var(--blue);
  background: var(--bg);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
}

/* ── Metrics ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.metric {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  text-align: center;
}
.metric-val {
  font-size: 26px;
  font-weight: 700;
  font-family: "Syne", sans-serif;
  color: var(--blue);
}
.metric-lbl {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border2);
  margin-bottom: 1.25rem;
}
.tab {
  padding: 0.6rem 1.1rem;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: "Noto Sans JP", sans-serif;
  transition: all 0.15s;
}
.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 500;
}

/* ── Code block ── */
.code-wrap {
  background: var(--code-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--code-fg);
  white-space: pre;
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
  position: relative;
  line-height: 1.6;
}
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--code-fg);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: "Noto Sans JP", sans-serif;
  transition: background 0.15s;
}
.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Upload area ── */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--white);
}
.upload-zone:hover,
.upload-zone.drag {
  border-color: var(--blue);
  background: #edf1fb;
}
.upload-icon {
  font-size: 36px;
  margin-bottom: 0.75rem;
  color: var(--muted);
}
.upload-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: var(--navy);
}
.upload-sub {
  font-size: 13px;
  color: var(--muted);
}
input[type="file"] {
  display: none;
}

.file-list {
  margin-top: 1rem;
}
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  margin-bottom: 0.4rem;
  font-size: 13px;
}
.file-name {
  font-weight: 500;
  color: var(--navy);
  flex: 1;
}
.file-size {
  color: var(--muted);
  font-size: 12px;
  font-family: "DM Mono", monospace;
}
.file-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  transition: color 0.15s;
}
.file-del:hover {
  color: var(--err);
}

/* ── Progress / Execution ── */
.exec-log {
  background: var(--code-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-height: 320px;
  overflow-y: auto;
}
.log-line {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--code-fg);
  margin-bottom: 0.4rem;
  line-height: 1.5;
}
.log-ts {
  color: rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
  font-size: 11px;
}
.log-ok {
  color: var(--green);
}
.log-err {
  color: #f09595;
}
.log-run {
  color: var(--accent);
}
.log-info {
  color: rgba(255, 255, 255, 0.6);
}
.progress-bar-wrap {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  height: 4px;
  margin: 1rem 0;
}
.progress-bar {
  height: 4px;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.4s;
  width: 0;
}

.analysis-loader {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 10px 28px rgba(30, 39, 97, 0.08);
}
.analysis-loader-ring {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(58, 86, 197, 0.14);
  border-top-color: var(--accent);
  border-right-color: var(--blue);
  flex-shrink: 0;
  animation: analysisSpin 0.9s linear infinite;
}
.analysis-loader-title {
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.analysis-loader-sub {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}
.analysis-loader-dots::after {
  content: "";
  animation: analysisDots 1.2s steps(4, end) infinite;
}
.dashboard-progress {
  display: none;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-top: 1rem;
  box-shadow: 0 10px 28px rgba(30, 39, 97, 0.08);
}
.dashboard-progress-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.dashboard-progress-ring {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(58, 86, 197, 0.14);
  border-top-color: var(--green);
  border-right-color: var(--accent);
  flex-shrink: 0;
  animation: analysisSpin 0.9s linear infinite;
}
.dashboard-progress-title {
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
}
.dashboard-progress-message {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}
@keyframes analysisSpin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes analysisDots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.result-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.result-key {
  font-size: 12px;
  font-family: "DM Mono", monospace;
  color: var(--blue);
  margin-bottom: 0.25rem;
}
.result-val {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

/* ── Alerts ── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 1rem;
  display: none;
  line-height: 1.5;
}
.alert.show {
  display: block;
}
.alert-err {
  background: #ffe8e8;
  color: var(--err);
  border: 1px solid rgba(192, 57, 43, 0.2);
}
.alert-info {
  background: #e6f1fb;
  color: #185fa5;
  border: 1px solid rgba(24, 95, 165, 0.2);
}
.alert-ok {
  background: #d4edda;
  color: #155724;
  border: 1px solid rgba(0, 168, 107, 0.2);
}

/* ── Settings modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.open {
  display: flex;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 480px;
  max-width: 90vw;
}
.modal-title {
  font-family: "Syne", sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--navy);
}
.modal-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Rationale box ── */
.rationale {
  background: #edf1fb;
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 13px;
  color: #2d46a8;
  line-height: 1.65;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 1rem;
  }
  .main {
    padding: 1.25rem;
  }
  .metrics {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 99px;
}

/* ── Tooltip ── */
.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.tooltip-wrap .tooltip-box {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  line-height: 1.7;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  z-index: 100;
}
.tooltip-wrap .tooltip-box::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--navy);
}
.tooltip-wrap:hover .tooltip-box {
  display: block;
}
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  font-size: 10px;
  font-weight: 700;
  cursor: default;
  margin-left: 0.35rem;
  color: #fff;
  flex-shrink: 0;
}

/* ── Use Case Cards ── */
.uc-card:hover {
  border-color: var(--blue) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(58, 86, 197, 0.12);
}
.uc-card {
  transition: all 0.2s;
}

/* ── purple variable ── */
:root {
  --purple: #7b2d8b;
}

.btn-disabled,
.btn:disabled,
button:disabled {
  pointer-events: none;
  opacity: 0.5;
  cursor: not-allowed;
}
.lang-toggle {
  display: inline-flex;
  gap: 0;
  margin-top: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  overflow: hidden;
}
.lang-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: none;
  padding: 0.3rem 0.7rem;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.lang-btn:hover {
  color: #fff;
}
.lang-btn.active {
  background: var(--blue, #1a4fff);
  color: #fff;
}
/* English UI: prefer DM Sans for body & headings (keep mono for code) */
/* EN mode: DM Sans body-wide, tighter sizing */
body.lang-en {
  font-family: "DM Sans", "Noto Sans JP", sans-serif;
  font-size: 13px;
  letter-spacing: -0.01em;
}
body.lang-en input,
body.lang-en textarea,
body.lang-en select,
body.lang-en button {
  font-family: "DM Sans", "Noto Sans JP", sans-serif;
  letter-spacing: -0.01em;
}
body.lang-en .page-title {
  font-size: 24px;
}
body.lang-en .step-label {
  font-size: 12px;
}
body.lang-en .btn {
  font-size: 13px;
}
body.lang-en .page-sub {
  font-size: 13px;
}
/* Logo: always DM Sans (set separately) */
.brand-name,
.brand-name * {
  font-family: "DM Sans", sans-serif;
}
