* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background: #071018;
  color: #e8f1f6;
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif;
  font-size: 14px;
}
button, input { font: inherit; }
button { color: inherit; }
.app-shell { height: 100%; display: grid; grid-template-rows: 64px 1fr; }
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; border-bottom: 1px solid #213342; background: #0a151f;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  color: #041016; background: #72e2d1; border-radius: 9px; font-weight: 800;
}
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand span:last-child { color: #7f96a7; font-size: 11px; }
.header-actions { display: flex; gap: 8px; }
button {
  border: 1px solid #314655; background: #10212d; border-radius: 7px;
  padding: 8px 10px; cursor: pointer;
}
button:hover { border-color: #5e7d90; background: #162b39; }
button:focus-visible, input:focus-visible { outline: 2px solid #72e2d1; outline-offset: 2px; }
.workspace { min-height: 0; display: grid; grid-template-columns: 250px minmax(540px, 1fr) 300px; }
.project-panel, .detail-panel { min-width: 0; background: #0a151f; overflow: auto; }
.project-panel { border-right: 1px solid #213342; }
.detail-panel { border-left: 1px solid #213342; }
.panel-heading {
  height: 45px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; color: #6f8798; border-bottom: 1px solid #1a2a36;
  font-size: 10px; letter-spacing: .14em;
}
.panel-heading strong { color: #72e2d1; }
.project-list { padding: 8px; display: grid; gap: 5px; }
.project-button {
  width: 100%; padding: 11px; text-align: left; display: grid; gap: 6px;
  background: transparent; border: 1px solid transparent;
}
.project-button:hover { background: #10212d; }
.project-button.active { background: #112b35; border-color: #2b716c; }
.project-button strong { font-size: 12px; font-weight: 600; }
.project-button span { color: #8299a9; font-size: 10px; line-height: 1.45; }
.project-stats { display: flex; gap: 8px; color: #5f788a; font-size: 10px; }
.source-boundary { margin: 8px 12px 16px; padding: 12px; border: 1px solid #203743; border-radius: 8px; }
.source-boundary strong { color: #72e2d1; font-size: 10px; letter-spacing: .14em; }
.source-boundary p { color: #718899; font-size: 11px; line-height: 1.55; margin: 7px 0 0; }
.main-stage { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto auto auto 1fr; background: #071018; }
.toolbar {
  min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 7px 12px;
  border-bottom: 1px solid #1a2a36; background: #0b1721;
}
.view-tabs { display: flex; gap: 3px; }
.view-tabs button { padding: 7px 9px; background: transparent; border-color: transparent; font-size: 11px; }
.view-tabs button.active { color: #72e2d1; background: #112a32; border-color: #295d5b; }
.view-tabs button:disabled { color: #435866; cursor: default; opacity: .55; }
.search-box { margin-left: auto; display: flex; align-items: center; gap: 7px; color: #708899; font-size: 10px; }
.search-box input {
  width: 190px; color: #e7f0f5; background: #071018; border: 1px solid #2b3e4c;
  border-radius: 7px; padding: 7px 9px;
}
.accent-button { color: #061218; background: #72e2d1; border-color: #72e2d1; font-weight: 700; font-size: 11px; }
.accent-button:hover { color: #061218; background: #8aebdd; }
.project-summary {
  min-height: 76px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 14px; border-bottom: 1px solid #172731;
}
.project-summary h1 { margin: 0 0 4px; font-size: 17px; font-weight: 650; }
.project-summary p { margin: 0; color: #7891a1; font-size: 11px; }
.summary-metrics { display: flex; margin: 0; gap: 16px; }
.summary-metrics div { display: grid; gap: 2px; text-align: right; }
.summary-metrics dt { color: #6d8494; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.summary-metrics dd { margin: 0; color: #d7e7ee; font-size: 13px; font-variant-numeric: tabular-nums; }
.analysis-boundary {
  min-height: 27px; padding: 6px 14px; color: #9fadc0; background: #101827;
  border-bottom: 1px solid #273148; font-size: 10px;
}
.canvas-wrap { min-height: 0; position: relative; }
.canvas {
  position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab;
  background-color: #060d13;
  background-image: radial-gradient(circle, #1d3a49 1px, transparent 1px);
  background-size: 24px 24px;
}
.canvas.dragging { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.lane-layer, .edge-layer, .node-layer { position: absolute; inset: 0; }
.lane { position: absolute; left: 30px; border: 1px solid #183547; background: rgba(10, 31, 43, .62); border-radius: 12px; }
.lane:nth-child(even) { background: rgba(12, 39, 51, .72); }
.lane-label { position: absolute; left: 18px; top: 14px; color: #5e8ba1; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.phase-label { position: absolute; top: 18px; color: #537485; font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.node {
  position: absolute; width: 230px; min-height: 78px; padding: 10px 11px;
  border: 1px solid #3c5969; border-left-width: 4px; border-radius: 9px;
  background: #10202b; box-shadow: 0 8px 22px rgba(0, 0, 0, .24); cursor: grab;
  user-select: none; touch-action: none; will-change: left, top;
}
.node::after {
  content: ''; position: absolute; right: 8px; top: 7px; width: 10px; height: 10px;
  background: radial-gradient(circle, #6f8d9b 1px, transparent 1.5px) 0 0 / 5px 5px;
  opacity: .72;
}
.node:hover { border-color: #83a4b5; z-index: 5; }
.node.dragging { cursor: grabbing; z-index: 12; opacity: .94; box-shadow: 0 16px 34px rgba(0, 0, 0, .46); }
.node.selected { outline: 2px solid #f4cb64; outline-offset: 2px; z-index: 6; }
.node.neighbor { box-shadow: 0 0 0 1px #72e2d1, 0 8px 22px rgba(0, 0, 0, .24); }
.node.simulation-past { box-shadow: inset 0 0 0 1px rgba(114, 226, 209, .3); }
.node.simulation-current {
  outline: 3px solid #ffffff; outline-offset: 4px; z-index: 9;
  box-shadow: 0 0 0 8px rgba(114, 226, 209, .2), 0 10px 28px rgba(0, 0, 0, .4);
}
.node-kind { display: block; color: #7c93a1; font-size: 8px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 5px; }
.node strong { display: block; overflow: hidden; color: #e9f2f6; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.node p { margin: 5px 0 0; overflow: hidden; color: #8299a7; font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.node-meta { display: flex; gap: 8px; margin-top: 6px; color: #5f7a89; font-size: 8px; }
.node-event { border-left-color: #ed7e9d; }
.node-component { border-left-color: #55c8e6; }
.node-function { border-left-color: #65d5b5; }
.node-api { border-left-color: #bd9bf4; }
.node-table { border-left-color: #f2bd55; }
.node-state { border-left-color: #f08b55; }
.node-auth, .node-config { border-left-color: #9f8fe7; }
.node-external { border-left-color: #a0b7c2; }
.node-file { border-left-color: #64879a; }
.node-port {
  position: absolute; width: 8px; height: 8px; margin-top: -4px; border: 1px solid #071018;
  z-index: 8;
}
.input-port { left: -7px; border-radius: 50%; background: #63b7ff; }
.output-port { right: -7px; border-radius: 2px; background: #ff9b64; }
.view-blocks .node { min-height: 96px; border-radius: 6px 14px 14px 6px; background: #10282c; }
.edge-segment { position: absolute; background: #426173; opacity: .72; pointer-events: none; }
.edge-segment.horizontal { height: 1px; }
.edge-segment.vertical { width: 1px; }
.edge-segment.selected { background: #f4cb64; opacity: 1; z-index: 2; }
.edge-segment.simulation-past { opacity: .92; }
.edge-segment.horizontal.simulation-current { height: 3px !important; opacity: 1; z-index: 4; box-shadow: 0 0 8px currentColor; }
.edge-segment.vertical.simulation-current { width: 3px !important; opacity: 1; z-index: 4; box-shadow: 0 0 8px currentColor; }
.edge-segment.trigger-edge, .edge-arrow.trigger-edge { background: #ed7e9d; }
.edge-segment.logic-edge, .edge-arrow.logic-edge { background: #65d5b5; }
.edge-segment.interface-edge, .edge-arrow.interface-edge { background: #bd9bf4; }
.edge-segment.data-edge, .edge-arrow.data-edge { background: #f2bd55; }
.edge-arrow {
  position: absolute; width: 0; height: 0; border-top: 4px solid transparent;
  border-bottom: 4px solid transparent; border-left: 7px solid #426173;
  background: transparent !important; pointer-events: none;
}
.edge-arrow.trigger-edge { border-left-color: #ed7e9d; }
.edge-arrow.logic-edge { border-left-color: #65d5b5; }
.edge-arrow.interface-edge { border-left-color: #bd9bf4; }
.edge-arrow.data-edge { border-left-color: #f2bd55; }
.edge-arrow.selected { border-left-color: #f4cb64; z-index: 3; }
.edge-arrow.simulation-current { filter: drop-shadow(0 0 4px #fff); transform: scale(1.45); z-index: 5; }
.edge-label {
  position: absolute; max-width: 90px; overflow: hidden; color: #6f8796; background: #071018;
  padding: 1px 4px; border-radius: 3px; font-size: 8px; white-space: nowrap; text-overflow: ellipsis;
  pointer-events: none;
}
.canvas-controls {
  position: absolute; left: 12px; bottom: 12px; display: flex; gap: 4px; padding: 5px;
  border: 1px solid #294150; border-radius: 9px; background: rgba(8, 20, 29, .92);
}
.canvas-controls button { min-width: 34px; padding: 6px 8px; font-size: 11px; }
.canvas-controls #zoom-label { min-width: 50px; color: #77909f; }
.simulation-bar {
  position: absolute; z-index: 20; left: 12px; right: 12px; top: 12px;
  min-height: 52px; display: flex; align-items: center; gap: 6px; padding: 7px 9px;
  border: 1px solid #355264; border-radius: 10px; background: rgba(7, 18, 27, .95);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .3); cursor: default;
}
.simulation-title { min-width: 114px; display: grid; gap: 2px; }
.simulation-title span { color: #72e2d1; font-size: 8px; letter-spacing: .12em; }
.simulation-title strong { font-size: 11px; }
.simulation-bar button { padding: 6px 8px; font-size: 10px; }
.simulation-bar button:disabled { color: #526977; cursor: default; opacity: .6; }
.simulation-speed { display: flex; align-items: center; gap: 4px; color: #6f8796; font-size: 9px; }
.simulation-speed select {
  color: #dbe9ee; background: #0c1c27; border: 1px solid #314655; border-radius: 6px;
  padding: 5px; font-size: 10px;
}
.port-legend { display: flex; gap: 7px; color: #78909f; font-size: 8px; }
.port-legend span { display: flex; align-items: center; gap: 4px; }
.port-legend i { width: 7px; height: 7px; display: inline-block; border: 1px solid #071018; }
.port-legend .input-key { border-radius: 50%; background: #63b7ff; }
.port-legend .output-key { border-radius: 2px; background: #ff9b64; }
.simulation-status {
  min-width: 0; margin-left: auto; overflow: hidden; color: #d9e7ec; font-size: 10px;
  white-space: nowrap; text-overflow: ellipsis;
}
.canvas-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #718898; pointer-events: none; }
.detail-panel { padding-bottom: 20px; }
.detail-empty { padding: 20px 16px; color: #79909f; }
.detail-empty strong { color: #b5c8d1; font-size: 12px; }
.detail-empty p { font-size: 11px; line-height: 1.6; }
#detail-content { padding: 15px; }
.detail-kind { color: #72e2d1; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.detail-panel h2 { margin: 8px 0 5px; font-size: 18px; overflow-wrap: anywhere; }
.detail-location { color: #78909f; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.5; overflow-wrap: anywhere; }
.detail-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 14px 0; background: #203442; border: 1px solid #203442; }
.detail-metrics div { padding: 8px; background: #0d1b25; }
.detail-metrics dt { color: #6d8392; font-size: 9px; }
.detail-metrics dd { margin: 3px 0 0; color: #d8e7ed; font-size: 11px; overflow-wrap: anywhere; }
.trace-section { margin-top: 18px; }
.trace-section h3 { margin: 0 0 8px; color: #748b99; font-size: 10px; font-weight: 600; }
.trace-list { display: grid; gap: 5px; }
.trace-button { width: 100%; display: grid; grid-template-columns: 66px 1fr; gap: 8px; text-align: left; padding: 8px; background: #0e1d27; }
.trace-button span:first-child { color: #72e2d1; font-size: 9px; }
.trace-button span:last-child { overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.trace-none { color: #607887; font-size: 10px; }
.toast {
  position: fixed; right: 16px; bottom: 16px; transform: translateY(16px); opacity: 0;
  padding: 10px 13px; color: #081117; background: #72e2d1; border-radius: 7px;
  font-size: 11px; font-weight: 700; pointer-events: none; transition: .18s ease;
}
.toast.visible { transform: translateY(0); opacity: 1; }
.settings-overlay {
  position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 24px;
  background: rgba(1, 7, 12, .82); backdrop-filter: blur(8px);
}
.settings-dialog {
  width: min(1080px, 96vw); max-height: 92vh; overflow: hidden; display: grid; grid-template-rows: auto 1fr;
  border: 1px solid #345064; border-radius: 14px; background: #09141d; box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}
.settings-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 18px 20px;
  border-bottom: 1px solid #213442; background: #0c1923;
}
.settings-header span { color: #72e2d1; font-size: 9px; letter-spacing: .14em; }
.settings-header h2 { margin: 4px 0 3px; font-size: 22px; }
.settings-header p { margin: 0; color: #8097a6; font-size: 11px; }
.settings-form { min-height: 0; display: grid; grid-template-rows: 1fr auto; }
.settings-grid { min-height: 0; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; }
.settings-card { min-width: 0; display: grid; align-content: start; gap: 9px; padding: 13px; border: 1px solid #223947; border-radius: 10px; background: #0d1b25; }
.settings-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.settings-card header span { color: #607e8f; font-size: 8px; letter-spacing: .13em; }
.settings-card h3 { margin: 3px 0 0; font-size: 14px; }
.status-badge { padding: 4px 6px; color: #78909e; border: 1px solid #2a4250; border-radius: 5px; font-size: 8px; letter-spacing: .08em; }
.status-badge[data-state="active"], .status-badge[data-state="connected"] { color: #071018; background: #72e2d1; border-color: #72e2d1; }
.status-badge[data-state="configured"] { color: #9ecfff; border-color: #3e7a9e; }
.settings-card label { min-width: 0; display: grid; gap: 4px; color: #78909f; font-size: 9px; }
.settings-card input[type="text"], .settings-card input[type="url"], .settings-card input[type="password"],
.settings-card input[type="number"], .settings-card select {
  width: 100%; min-width: 0; color: #e3edf1; background: #07131c; border: 1px solid #2b4250;
  border-radius: 6px; padding: 7px 8px; font-size: 10px;
}
.settings-card input[type="checkbox"] { accent-color: #72e2d1; }
.toggle-row { display: flex !important; grid-template-columns: auto 1fr; flex-direction: row; align-items: center; gap: 7px !important; }
.toggle-row.compact { align-self: end; min-height: 31px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inline-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-checks label { display: flex; flex-direction: row; align-items: center; gap: 4px; }
.settings-card code { overflow: hidden; color: #6d8797; font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.settings-card p { margin: 0; color: #6f8796; font-size: 9px; line-height: 1.5; }
.settings-card .security-note { color: #c8a86c; }
.settings-footer {
  display: flex; align-items: center; gap: 7px; padding: 11px 14px; border-top: 1px solid #223744; background: #0b1821;
}
#settings-feedback { margin-right: auto; color: #7f97a6; font-size: 10px; }
#settings-feedback.error { color: #ff9a9a; }
body.settings-open { overflow: hidden; }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 220px 1fr; }
  .detail-panel { display: none; }
  .summary-metrics div:nth-child(n+5) { display: none; }
}
@media (max-width: 760px) {
  .app-header { padding: 0 10px; }
  .brand span:last-child, .header-actions #share-button { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .project-panel { display: none; }
  .toolbar { flex-wrap: wrap; }
  .search-box { order: 3; width: 100%; margin-left: 0; }
  .search-box input { width: 100%; }
  .project-summary { align-items: flex-start; flex-direction: column; }
  .summary-metrics { width: 100%; justify-content: space-between; }
  .simulation-title, .simulation-speed, .port-legend { display: none; }
  .simulation-status { max-width: 38vw; }
  .settings-overlay { padding: 8px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-footer { flex-wrap: wrap; }
  #settings-feedback { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
