:root {
  --bg-1: #f5f0e8;
  --bg-2: #dce8ea;
  --surface: #ffffff;
  --text: #1f2530;
  --muted: #5f6a7a;
  --accent: #10625a;
  --accent-dark: #0a473f;
  --error: #9e1c1c;
  --border: #dbe1e7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(16, 98, 90, 0.15), transparent 35%),
    radial-gradient(circle at 90% 90%, rgba(217, 163, 73, 0.2), transparent 30%),
    linear-gradient(130deg, var(--bg-1), var(--bg-2));
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
}

.hidden {
  display: none;
}

.login-page .card {
  width: min(420px, 100%);
}

h1,
h2,
h3 {
  margin-top: 0;
  font-family: "Merriweather", Georgia, serif;
}

.subtitle {
  margin-top: -4px;
  color: var(--muted);
}

.error {
  color: var(--error);
  font-weight: 700;
}

label {
  margin-top: 10px;
  display: block;
  font-weight: 600;
}

input,
textarea,
select,
button {
  width: 100%;
  font: inherit;
  border-radius: 10px;
}

input,
textarea,
select {
  margin-top: 6px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  padding: 11px 12px;
  background: #fff;
}

textarea {
  resize: vertical;
}

button {
  margin-top: 6px;
  border: 0;
  padding: 11px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease-in-out;
}

button:hover {
  background: var(--accent-dark);
}

button.ghost {
  width: auto;
  min-width: 120px;
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--accent);
}

button.danger {
  background: #8f2020;
}

button.danger:hover {
  background: #6d1717;
}

.button-link {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
}

.ghost-link {
  border: 1px solid var(--accent);
  color: var(--accent-dark);
  background: transparent;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.compact-button {
  width: auto;
  min-width: 0;
  padding: 8px 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 24px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 0 24px 24px;
}

.graph-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1.2fr) minmax(320px, 0.9fr) minmax(320px, 0.9fr);
  gap: 18px;
  padding: 0 24px 24px;
  align-items: start;
}

.graph-panel,
.detail-panel,
.chat-panel {
  min-height: 680px;
}

.mobile-task-bar {
  display: none;
}

.graph-panel:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  margin: 0;
  padding: 14px;
}

.graph-panel:fullscreen .graph-canvas {
  height: calc(100vh - 220px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.panel-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.fullscreen-symbol {
  letter-spacing: 1px;
  font-weight: 700;
}

.graph-canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(16, 98, 90, 0.05), rgba(255, 255, 255, 0.9));
}

.node-quick-menu {
  position: absolute;
  z-index: 10;
  width: min(240px, calc(100% - 16px));
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.12);
}

.node-quick-menu .subtitle {
  margin: 0 0 8px;
}

.node-quick-menu button {
  margin-right: 8px;
  margin-bottom: 8px;
}

.graph-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.graph-node {
  cursor: grab;
}

.graph-node circle {
  fill: #f7fffd;
  stroke: var(--accent);
  stroke-width: 2;
  transition: fill 120ms ease-in-out, transform 120ms ease-in-out;
}

.graph-node text {
  font-size: 14px;
  fill: var(--text);
}

.graph-node:hover circle,
.graph-node.selected-node circle {
  fill: #dff3ef;
}

.graph-node.profile-node circle {
  fill: #fff8e8;
  stroke: #c78f2f;
}

.graph-node.profile-node:hover circle,
.graph-node.profile-node.selected-node circle {
  fill: #ffecc0;
}

.graph-node.subnode-node circle {
  fill: #eef2ff;
  stroke: #5060d2;
}

.graph-node.drag-origin circle {
  stroke: #1b2c8a;
  stroke-width: 3;
}

.graph-node.drop-target circle {
  stroke: #f28c18;
  stroke-width: 4;
}

.graph-node.subnode-node:hover circle,
.graph-node.subnode-node.selected-node circle {
  fill: #dbe3ff;
}

.graph-node.has-image circle {
  fill: #ffffff;
}

.graph-self-node circle {
  fill: #0f5a53;
  stroke: #083c36;
  stroke-width: 3;
}

.graph-self-node {
  cursor: pointer;
}

.graph-self-node:hover circle,
.graph-self-node:focus-visible circle {
  fill: #157066;
}

.graph-self-node text {
  fill: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

.mini-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.mini-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fbfcfd;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-card strong {
  font-size: 24px;
}

.stack-form {
  display: flex;
  flex-direction: column;
}

.subsection {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button-row button {
  width: auto;
}

.empty-state {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fcfcfb;
}

.idea-focus {
  margin-bottom: 18px;
}

.idea-meta-line {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 98, 90, 0.12);
  color: var(--accent-dark);
  font-weight: 700;
}

.idea-source {
  color: var(--muted);
}

.link-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fcfcfd;
}

.subnode-tree-item {
  align-items: flex-start;
}

.subnode-depth-0 {
  padding-left: 0;
}

.subnode-depth-1 {
  padding-left: 16px;
}

.subnode-depth-2 {
  padding-left: 32px;
}

.subnode-depth-3 {
  padding-left: 48px;
}

.subnode-depth-4 {
  padding-left: 64px;
}

.subnode-depth-5 {
  padding-left: 80px;
}

.subnode-depth-6 {
  padding-left: 96px;
}

.subnode-depth-7 {
  padding-left: 112px;
}

.subnode-depth-8 {
  padding-left: 128px;
}

.subnode-tree-left {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.subnode-tree-toggle {
  width: auto;
  min-width: 28px;
  padding: 4px 8px;
  margin-top: 0;
  line-height: 1;
}

.chat-messages {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfcfd;
  padding: 14px;
  min-height: 240px;
  max-height: 360px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-message {
  border-radius: 12px;
  padding: 10px 12px;
}

.chat-message.user {
  background: rgba(16, 98, 90, 0.1);
}

.chat-message.assistant {
  background: rgba(217, 163, 73, 0.14);
}

.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.suggestion-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fbfcfd;
}

.situation-entries {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.situation-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.situation-group-title {
  margin: 4px 0;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}

.situation-entry-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fbfcfd;
}

.situation-entry-card p {
  margin: 0 0 8px;
}

.situation-entry-card p:last-child {
  margin-bottom: 0;
}

.research-sources-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.research-source-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fbfcfd;
}

.research-source-card p {
  margin: 0 0 8px;
}

.research-source-card p:last-child {
  margin-bottom: 0;
}

.research-source-card a {
  color: var(--accent-dark);
  word-break: break-word;
}

.checkbox-line {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
}

.checkbox-line input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.images-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.image-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fbfcfd;
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
}

.idea-image-preview {
  width: 140px;
  height: 110px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #fff;
}

.image-suggestion-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-suggestion-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.question-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fbfcfd;
}

.question-card-selected {
  border-color: var(--accent);
  background: rgba(16, 98, 90, 0.06);
}

.question-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.question-thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.question-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.idea-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.single-column {
  grid-template-columns: 1fr;
  max-width: 720px;
}

.narrow-card {
  width: min(420px, 100%);
}

.qr {
  width: 220px;
  height: 220px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.mono {
  font-family: "Courier New", Courier, monospace;
  background: #f4f6f8;
  padding: 8px 10px;
  border-radius: 8px;
  word-break: break-all;
}

.note {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 10px;
  background: #fdfefe;
}

.note p {
  white-space: pre-wrap;
}

.note small {
  color: var(--muted);
}

@media (max-width: 860px) {
  body {
    font-size: 16px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .graph-layout {
    grid-template-columns: 1fr;
    padding: 0 12px 18px;
    gap: 12px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
  }

  .graph-panel,
  .detail-panel,
  .chat-panel {
    min-height: auto;
  }

  .mobile-task-bar {
    position: sticky;
    top: 8px;
    z-index: 12;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(5px);
  }

  .mobile-task-link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(16, 98, 90, 0.1);
    border: 1px solid rgba(16, 98, 90, 0.28);
    color: var(--accent-dark);
    text-decoration: none;
    font-weight: 700;
  }

  input,
  textarea,
  select,
  button {
    font-size: 16px;
  }

  input,
  textarea,
  select {
    padding: 12px 12px;
  }

  button {
    min-height: 44px;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .panel-tools {
    width: 100%;
    justify-content: flex-end;
  }

  .graph-canvas {
    min-height: 300px;
  }

  .chat-messages {
    min-height: 180px;
    max-height: 300px;
  }

  .button-row {
    flex-direction: column;
  }

  .button-row button {
    width: 100%;
  }

  .mini-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .image-card {
    grid-template-columns: 1fr;
  }

  .question-thumbs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .idea-image-preview {
    width: 100%;
    height: auto;
    max-height: 220px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }
}
