:root {
  --bg: #f5f8fb;
  --ink: #172033;
  --muted: #667085;
  --quiet: #98a2b3;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --panel-strong: #edf4f8;
  --line: #e6ebf2;
  --core: #176b87;
  --domain: #e26d5a;
  --concept: #4f7d5a;
  --life: #8b5fbf;
  --focus: rgba(23, 107, 135, .16);
  --shadow: 0 18px 44px rgba(23, 32, 51, .08);
  --shadow-soft: 0 10px 24px rgba(23, 32, 51, .06);
  --card-width: 160px;
  --card-height: 82px;
  --min-canvas-width: 740px;
  --min-canvas-height: 620px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfdff 230px, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

::selection {
  background: rgba(23, 107, 135, .18);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #d7e0e9;
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

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

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr) 330px;
  gap: 0;
}

.left-panel,
.right-panel {
  background: var(--panel);
  border-color: var(--line);
  padding: 24px;
  overflow: auto;
}

.left-panel {
  border-right: 1px solid var(--line);
  box-shadow: 1px 0 0 rgba(255, 255, 255, .9);
}

.right-panel {
  border-left: 1px solid var(--line);
  box-shadow: -1px 0 0 rgba(255, 255, 255, .9);
}

.brand {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #176b87, #2d9c8c);
  color: white;
  border-radius: 12px;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 1.16rem;
  letter-spacing: -.01em;
}

.brand p,
.detail-block p,
.control-group label,
.eyebrow,
.legend,
li {
  color: var(--muted);
}

.brand p {
  margin-top: 2px;
}

.control-group,
.detail-block {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-top: 22px;
}

.control-group h2,
.detail-block h2 {
  font-size: 1.08rem;
  letter-spacing: -.01em;
  margin-bottom: 14px;
}

.detail-block h3 {
  font-size: .94rem;
  margin-bottom: 10px;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-row h3 {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  margin: 15px 0 7px;
  text-transform: uppercase;
  color: #606b7c;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--core);
  background: white;
  box-shadow: 0 0 0 4px var(--focus);
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  min-height: 42px;
  font-weight: 800;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-button {
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(135deg, #176b87, #22a08f);
  color: white;
  box-shadow: var(--shadow-soft);
}

.secondary-button {
  width: 100%;
  margin-top: 10px;
  background: #f4f8fb;
  color: var(--ink);
  border: 1px solid var(--line);
}

.mini-button {
  min-height: 32px;
  padding: 0 11px;
  background: white;
  color: var(--core);
  border: 1px solid var(--line);
  font-size: .78rem;
}

.form-status {
  min-height: 20px;
  margin: 12px 0 -4px;
  color: #b54708;
  font-size: .84rem;
  font-weight: 700;
}

.map-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 36%, rgba(23, 107, 135, .09), transparent 32%),
    linear-gradient(180deg, #ffffff 0%, #f7fafd 100%);
}

.map-toolbar {
  min-height: 104px;
  padding: 22px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(10px);
}

.map-toolbar h2 {
  font-size: 1.55rem;
  letter-spacing: -.025em;
}

.eyebrow {
  font-size: .74rem;
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: .1em;
  margin-bottom: 5px;
  color: var(--quiet);
}

.toolbar-meta {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 16px;
  font-size: .8rem;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  display: inline-block;
}

.map-stats {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: .78rem;
}

.map-stats span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.dot.core { background: var(--core); }
.dot.domain { background: var(--domain); }
.dot.concept { background: var(--concept); }
.dot.life { background: var(--life); }

.map-shell {
  position: relative;
  flex: 1;
  min-height: var(--min-canvas-height);
  overflow: auto;
  background-image:
    linear-gradient(rgba(23, 32, 51, .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 51, .03) 1px, transparent 1px);
  background-size: 36px 36px;
}

#connectionCanvas,
.mindmap {
  position: absolute;
  top: 0;
  left: 0;
}

.mindmap {
  min-width: var(--min-canvas-width);
  min-height: var(--min-canvas-height);
  width: auto;
  height: auto;
}

.collection {
  position: absolute;
  border: 2px dashed rgba(23, 107, 135, .3);
  border-radius: 24px;
  background: rgba(23, 107, 135, .03);
  padding: 20px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all .2s ease;
}

.collection:hover {
  border-color: rgba(23, 107, 135, .6);
  background: rgba(23, 107, 135, .06);
}

.collection-header {
  padding: 10px 14px;
  background: rgba(23, 107, 135, .08);
  border-radius: 12px;
  border: 1px solid rgba(23, 107, 135, .2);
  text-align: center;
}

.collection-title {
  font-weight: 700;
  color: var(--core);
  font-size: .9rem;
  margin: 0;
}

.collection-count {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 4px;
}

.node {
  position: absolute;
  width: var(--card-width);
  min-height: var(--card-height);
  transform: translate(-50%, -50%);
  border-radius: 18px;
  border: 1px solid rgba(23, 32, 51, .08);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
  padding: 13px;
  display: grid;
  align-content: center;
  gap: 5px;
  text-align: center;
  color: var(--concept);
  transition: transform .16s ease, opacity .16s ease, box-shadow .16s ease;
}

.node:hover,
.node.active {
  transform: translate(-50%, -50%) scale(1.04);
  box-shadow: 0 24px 54px rgba(23, 32, 51, .15);
  z-index: 5;
}

.node.active::after {
  content: "";
  position: absolute;
  inset: -7px;
  border: 2px solid rgba(23, 107, 135, .16);
  border-radius: 24px;
  pointer-events: none;
}

.node.hidden {
  opacity: .13;
}

.node.core {
  width: 190px;
  min-height: 102px;
  color: var(--core);
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(135deg, #176b87, #2d9c8c) border-box;
  border: 2px solid transparent;
}

.node.domain {
  color: var(--domain);
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(135deg, rgba(226, 109, 90, .95), rgba(226, 109, 90, .34)) border-box;
  border: 2px solid transparent;
}

.node.life {
  color: var(--life);
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(135deg, rgba(139, 95, 191, .95), rgba(139, 95, 191, .32)) border-box;
  border: 2px solid transparent;
}

.node.concept {
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(135deg, rgba(79, 125, 90, .9), rgba(79, 125, 90, .28)) border-box;
  border: 2px solid transparent;
}

.node-title {
  color: var(--ink);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -.01em;
}

.node-type {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: .06em;
}

.detail-block:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

#detailMeta {
  margin-top: 8px;
  line-height: 1.45;
}

#detailSituation {
  line-height: 1.55;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.scenario-list {
  display: grid;
  gap: 10px;
}

.scenario-card {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}

.scenario-card span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--panel-strong);
  color: var(--core);
  font-size: .82rem;
  font-weight: 900;
}

.scenario-card p {
  color: var(--ink);
  line-height: 1.45;
  font-size: .92rem;
}

.detail-block ul {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px 14px 32px;
}

ul {
  padding-left: 19px;
  margin: 0;
}

li + li {
  margin-top: 9px;
}

.detail-block li::marker {
  color: var(--core);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

/* Edit Modal Styles */
.edit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 51, .4);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.edit-modal {
  background: white;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(23, 32, 51, .2);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.edit-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--line);
}

.edit-modal-header h3 {
  font-size: 1.2rem;
  margin: 0;
  color: var(--ink);
}

.close-modal {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .16s ease;
}

.close-modal:hover {
  background: var(--panel-strong);
  color: var(--ink);
}

.edit-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.edit-modal-body label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  margin: 16px 0 8px;
  text-transform: uppercase;
  color: #606b7c;
}

.edit-modal-body input,
.edit-modal-body select,
.edit-modal-body textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
  font: inherit;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.edit-modal-body input:focus,
.edit-modal-body select:focus,
.edit-modal-body textarea:focus {
  border-color: var(--core);
  background: white;
  box-shadow: 0 0 0 4px var(--focus);
}

.edit-modal-body input:disabled {
  background: var(--panel-strong);
  cursor: not-allowed;
  opacity: .6;
}

.edit-modal-body textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.modal-action-area {
  margin-top: 14px;
  margin-bottom: 12px;
}

.modal-action-area label {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  margin: 0 0 6px;
  text-transform: uppercase;
  color: #606b7c;
}

.compact-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 8px 12px;
  font-size: .8rem;
  outline: none;
  transition: border-color .16s ease;
}

.compact-select:focus {
  border-color: var(--core);
  background: white;
}

.modal-button-footer {
  display: grid;
  grid-template-columns: 60px 1fr 60px;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.connections-list {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-top: 8px;
  max-height: 120px;
  overflow-y: auto;
}

.connection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  gap: 6px;
}

.connection-item:not(:last-child) {
  border-bottom: 1px solid var(--line);
}

.connection-item strong {
  color: var(--ink);
  font-size: .75rem;
}

.connection-item span {
  color: var(--ink);
  flex: 1;
  font-size: .75rem;
}

.remove-connection {
  padding: 2px 6px;
  background: #fee2e2;
  color: #b54708;
  border: none;
  border-radius: 4px;
  font-size: .6rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
}

.remove-connection:hover {
  background: #fecaca;
}

.edit-modal-footer {
  padding: 12px 24px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-delete,
.btn-cancel,
.btn-save {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 6px 10px;
  font-size: .7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
}

.btn-delete {
  background: #fee2e2;
  color: #b54708;
  border-color: #fecaca;
}

.btn-delete:hover {
  background: #fecaca;
}

.btn-cancel {
  background: var(--panel-soft);
  color: var(--muted);
}

.btn-cancel:hover {
  background: var(--panel-strong);
  color: var(--ink);
}

.btn-save {
  background: var(--core);
  color: white;
  border-color: var(--core);
}

.btn-save:hover {
  opacity: .85;
  transform: translateY(-1px);
}

@media (max-width: 760px) {
  .workspace {
    display: block;
  }

  .map-toolbar {
    align-items: flex-start;
    gap: 18px;
    flex-direction: column;
  }

  .toolbar-meta {
    justify-items: start;
    width: 100%;
  }

  .legend {
    border-radius: 18px;
    justify-content: flex-start;
  }

  .map-shell {
    min-height: 680px;
    overflow: auto;
  }

  .left-panel,
  .right-panel {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .edit-modal {
    max-width: 95vw;
  }
}
