:root {
  --navy-900: #000b24;
  --navy-800: #001848;
  --blue-600: #1848a8;
  --blue-500: #2d6bd4;
  --blue-400: #4890e0;
  --blue-100: #d6e8fa;
  --blue-050: #eef5fd;
  --teal-600: #009e96;
  --ink-900: #0a0e1a;
  --ink-700: #2a3142;
  --ink-600: #4a5266;
  --ink-500: #6b7284;
  --ink-400: #8e94a3;
  --ink-300: #b4b9c4;
  --ink-200: #d6d9e0;
  --ink-100: #e8eaef;
  --ink-050: #f4f5f8;
  --white: #ffffff;
  --success: #1ba85c;
  --warning: #e8a317;
  --danger: #d94d4d;
  --bg-app: #f4f5f8;
  --shadow-sm: 0 2px 6px rgba(0, 24, 72, 0.08);
  --shadow-md: 0 6px 16px rgba(0, 24, 72, 0.1);
  --shadow-lg: 0 16px 40px rgba(0, 24, 72, 0.14);
  --font-sans: Inter, "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Yu Gothic UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg-app);
  color: var(--ink-900);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

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

button {
  border: 0;
}

a {
  color: var(--blue-600);
}

.is-hidden {
  display: none !important;
}

.app-frame {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-app);
}

.app-topbar {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--white);
  border-bottom: 1px solid var(--ink-100);
  z-index: 10;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.app-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1848a8, #48a8ff);
  display: grid;
  place-items: center;
  color: var(--white);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(24, 72, 168, 0.3);
}

.app-logo-name {
  color: var(--navy-800);
  font-size: 16px;
  font-weight: 700;
}

.app-crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--ink-100);
  color: var(--ink-600);
  font-size: 13px;
}

.app-crumb .sep,
.app-crumb .pencil {
  color: var(--ink-300);
}

.app-crumb .current {
  color: var(--ink-900);
  font-weight: 700;
}

.topbar-spacer,
.toolbar-spacer {
  flex: 1;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ink-050);
  color: var(--ink-500);
  font-size: 12px;
}

.topbar-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-500);
}

.topbar-status.dirty .dot {
  background: var(--warning);
}

.topbar-status.dirty span:last-child {
  color: #8a5a0f;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-900);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}

.topbar-btn:hover {
  background: var(--ink-050);
}

.topbar-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.topbar-btn.ghost {
  border-color: var(--ink-100);
  background: var(--white);
}

.topbar-btn.primary {
  background: var(--blue-600);
  color: var(--white);
  box-shadow: 0 1px 2px rgba(24, 72, 168, 0.2);
}

.topbar-btn.primary:hover {
  background: var(--blue-500);
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4890e0, #1848a8);
  color: var(--white);
  font-size: 13px;
  font-weight: 800;
}

.home-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 40px 40px 60px;
  overflow-y: auto;
}

.intro-card,
.sample-card {
  width: 100%;
  max-width: 720px;
  border: 1px solid var(--ink-100);
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow-md);
}

.intro-card {
  padding: 40px;
}

.sample-card {
  padding: 28px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--blue-600);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.intro-card h1 {
  margin: 0 0 8px;
  color: var(--ink-900);
  font-size: 24px;
  line-height: 1.25;
}

.intro-card p {
  margin: 0 0 20px;
  color: var(--ink-600);
  font-size: 13px;
  line-height: 1.6;
}

.form-textarea,
.form-input,
.form-select {
  width: 100%;
  border: 1px solid var(--ink-200);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink-900);
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-textarea {
  min-height: 140px;
  padding: 14px;
  resize: none;
  line-height: 1.6;
}

.form-input,
.form-select {
  height: 36px;
  padding: 7px 10px;
}

.form-textarea:focus,
.form-input:focus,
.form-select:focus,
.chat-input-text:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(72, 144, 224, 0.18);
}

.security-note {
  margin-top: 8px;
  color: var(--ink-500);
  font-size: 11px;
  line-height: 1.5;
}

.security-note summary {
  cursor: pointer;
  list-style: none;
}

.security-note summary span {
  color: var(--ink-600);
  text-decoration: underline;
}

.security-note div {
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--ink-100);
  border-radius: 6px;
  background: var(--bg-app);
}

.sample-label,
.chat-suggestions-label {
  margin-top: 12px;
  color: var(--ink-500);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill-row,
.chat-suggestions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chat-suggestions-row {
  margin-bottom: 10px;
}

.chat-suggestion-pill {
  border: 1px solid var(--ink-100);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink-600);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.chat-suggestion-pill:hover {
  border-color: var(--blue-400);
  background: var(--blue-050);
  color: var(--blue-600);
}

.home-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.sample-card h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.sample-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--ink-100);
  border-radius: 10px;
  background: var(--white);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.sample-item:hover {
  background: var(--blue-050);
  border-color: #c3d7f2;
}

.sample-item strong {
  font-size: 14px;
}

.sample-item span {
  color: var(--ink-600);
  font-size: 12px;
  line-height: 1.5;
}

.home-footer {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--ink-100);
  color: var(--ink-600);
  font-size: 12px;
}

.app-main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.chat-panel {
  width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--ink-100);
  background: var(--white);
  transition: width 0.18s ease;
}

.chat-panel.collapsed {
  width: 44px;
  align-items: center;
}

.chat-panel.collapsed .chat-body,
.chat-panel.collapsed .chat-suggestions,
.chat-panel.collapsed .chat-input-wrap {
  display: none;
}

.chat-panel.collapsed .chat-header {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 12px 0;
  border-bottom: 0;
}

.chat-panel.collapsed .chat-header-row > div {
  display: none;
}

.chat-header {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--ink-100);
}

.chat-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-collapse-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--ink-100);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink-600);
  cursor: pointer;
  font-size: 18px;
}

.chat-header-title {
  font-size: 14px;
  font-weight: 800;
}

.chat-header-sub {
  margin-top: 3px;
  color: var(--ink-600);
  font-size: 12px;
}

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 16px 18px;
}

.chat-msg-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg-row.user {
  align-items: flex-end;
}

.chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-500);
  font-size: 11px;
  font-weight: 600;
}

.chat-msg-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1848a8, #48a8ff);
  color: var(--white);
  font-size: 9px;
  font-weight: 800;
}

.chat-msg-row.user .chat-msg-avatar {
  background: linear-gradient(135deg, #e8a317, #c68413);
}

.chat-msg-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink-900);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat-msg-row.ai .chat-msg-bubble {
  border: 1px solid #dce7f7;
  border-top-left-radius: 4px;
  background: var(--blue-050);
}

.chat-msg-row.user .chat-msg-bubble {
  border: 1px solid var(--ink-200);
  border-top-right-radius: 4px;
  background: var(--white);
}

.chat-suggestions {
  padding: 10px 18px 0;
  border-top: 1px solid var(--ink-100);
  background: var(--bg-app);
}

.chat-input-wrap {
  flex-shrink: 0;
  padding: 10px 18px 14px;
  border-top: 1px solid var(--ink-100);
  background: var(--bg-app);
}

.chat-input-text {
  width: 100%;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--ink-100);
  border-radius: 10px;
  resize: none;
  color: var(--ink-900);
  font-size: 13px;
  line-height: 1.5;
}

.chat-input-toolbar {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}

.chat-send-btn {
  min-width: 64px;
  padding: 5px 12px;
  border-radius: 6px;
  background: var(--blue-600);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.chat-send-btn:disabled {
  background: var(--ink-300);
  cursor: default;
}

.canvas-side {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.canvas-toolbar {
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--ink-100);
  background: var(--white);
  font-size: 12px;
}

.canvas-toolbar-info {
  color: var(--ink-500);
}

.canvas-toolbar-info b {
  color: var(--ink-900);
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--ink-100);
}

.toolbar-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-600);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.toolbar-tab:hover,
.toolbar-tab.active {
  background: var(--blue-050);
  color: var(--blue-600);
}

.canvas {
  flex: 1;
  position: relative;
  overflow: auto;
  background-color: #f4f6fa;
  background-image: radial-gradient(circle, #d4dae5 1px, transparent 0);
  background-size: 18px 18px;
}

.canvas-inner {
  position: relative;
  width: 1700px;
  min-height: 720px;
  padding: 24px;
  transform-origin: 0 0;
}

.connector-svg {
  position: absolute;
  inset: 0;
  width: 1700px;
  height: 720px;
  pointer-events: none;
  z-index: 1;
}

.connector-svg path {
  fill: none;
  stroke: #6b7284;
  stroke-width: 1.7;
}

.canvas-legend {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 6;
  padding: 8px 10px;
  border: 1px solid var(--ink-100);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  font-size: 11px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid;
}

.legend-swatch.human {
  background: #fff3d6;
  border-color: var(--warning);
}

.legend-swatch.claude {
  background: var(--blue-100);
  border-color: var(--blue-500);
}

.legend-swatch.tool {
  background: #ccedeb;
  border-color: var(--teal-600);
}

.start-node,
.end-node {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--ink-700);
  color: var(--white);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 6px rgba(0, 11, 36, 0.2);
}

.start-node {
  left: 40px;
  top: 68px;
}

.end-node {
  left: 1420px;
  top: 260px;
}

.node {
  position: absolute;
  z-index: 4;
  width: 200px;
  padding: 10px 12px;
  border: 1px solid var(--ink-200);
  border-radius: 10px;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0, 24, 72, 0.06), 0 4px 12px rgba(0, 24, 72, 0.04);
  cursor: pointer;
  user-select: none;
}

.node:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 24, 72, 0.08), 0 12px 24px rgba(0, 24, 72, 0.1);
}

.node.selected {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(72, 144, 224, 0.22), 0 12px 24px rgba(0, 24, 72, 0.1);
}

.node.human {
  border-color: #e8c77e;
  background: #fffaec;
}

.node.claude {
  border-color: #b6cdec;
  background: #f2f7fe;
}

.node.tool {
  border-color: #a6d9d5;
  background: #ebf8f7;
}

.node-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}

.node-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
}

.node.human .node-icon {
  background: #ffeab8;
  color: #8a5a0f;
}

.node.claude .node-icon {
  background: var(--blue-100);
  color: var(--blue-600);
}

.node.tool .node-icon {
  background: #ccedeb;
  color: #00766f;
}

.node-kind-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.node-tool-name {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--ink-050);
  color: var(--ink-600);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.node-title {
  margin-bottom: 3px;
  color: var(--ink-900);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.node-meta {
  color: var(--ink-600);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
}

.canvas-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 8;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--ink-100);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.canvas-ctrl-btn {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-600);
  cursor: pointer;
  font-size: 16px;
}

.canvas-ctrl-btn:hover {
  background: var(--ink-050);
  color: var(--ink-900);
}

.canvas-zoom {
  display: inline-flex;
  align-items: center;
  min-width: 48px;
  justify-content: center;
  color: var(--ink-900);
  font-size: 12px;
  font-weight: 800;
}

.detail-panel {
  height: 238px;
  flex-shrink: 0;
  border-top: 1px solid var(--ink-100);
  background: var(--white);
}

.detail-header {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--ink-100);
}

.detail-title {
  font-size: 14px;
  font-weight: 800;
}

.detail-sub {
  margin-top: 2px;
  color: var(--ink-500);
  font-size: 11px;
}

.detail-delete {
  padding: 5px 10px;
  border: 1px solid #f0c0c0;
  border-radius: 6px;
  background: #fff5f5;
  color: #b53a3a;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.detail-delete:disabled {
  opacity: 0.4;
  cursor: default;
}

.detail-body {
  height: 188px;
  padding: 14px 18px 16px;
}

.detail-form {
  display: grid;
  grid-template-columns: 240px 360px 1fr;
  gap: 12px;
  height: 100%;
}

.form-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.form-field-label {
  color: var(--ink-900);
  font-size: 11px;
  font-weight: 800;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
}

.detail-textarea-wrap .form-textarea {
  min-height: 0;
  height: 100%;
  padding: 10px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.45);
}

.prompt-modal {
  width: 100%;
  max-width: 820px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ink-100);
  border-radius: 12px;
  background: var(--white);
  box-shadow: var(--shadow-lg);
}

.prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ink-100);
}

.prompt-header h2 {
  margin: 0;
  font-size: 16px;
}

.prompt-close {
  padding: 4px 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-600);
  cursor: pointer;
  font-size: 18px;
}

.prompt-help {
  margin: 10px 20px 0;
  color: var(--ink-600);
  font-size: 12px;
  line-height: 1.6;
}

.prompt-body {
  min-height: 320px;
  margin: 12px 20px;
  padding: 14px 16px;
  overflow: auto;
  resize: none;
  border: 1px solid var(--ink-100);
  border-radius: 8px;
  background: var(--ink-050);
  color: var(--ink-900);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
}

.prompt-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--ink-100);
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app-topbar {
    gap: 8px;
    padding: 0 10px;
  }

  .app-logo-name,
  .app-crumb,
  .topbar-status,
  #undoBtn,
  #redoBtn {
    display: none;
  }

  .home-view {
    padding: 24px 14px 40px;
  }

  .intro-card,
  .sample-card {
    border-radius: 12px;
  }

  .intro-card {
    padding: 22px;
  }
}
