:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #171a1d;
  --panel-2: #202428;
  --text: #f2f4f6;
  --muted: #a7b0b8;
  --line: #323941;
  --blue: #49a4ff;
  --green: #68d391;
  --yellow: #f6c453;
  --red: #ff6b6b;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) 1fr;
  height: 100vh;
}

.panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
  padding: 18px;
}

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

.mark {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--blue), var(--green));
}

h1, h2, p { margin: 0; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
p, label, #status { color: var(--muted); font-size: 13px; }

.mode-switch {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0 0 16px;
}

.mode-switch button {
  min-height: 34px;
  background: var(--panel-2);
  color: var(--muted);
}

.mode-switch button.active {
  color: #fff;
  border-color: #3275b4;
  background: #245a8f;
}

.hint {
  color: #7f8993;
  font-size: 11px;
}

.controls {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 5px;
}

select, button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  min-height: 36px;
  padding: 7px 10px;
  font: inherit;
}

select[multiple] {
  min-height: 118px;
  padding: 4px;
}

select[multiple] option {
  border-radius: 4px;
  padding: 6px 8px;
}

button {
  cursor: pointer;
  color: #fff;
  background: #245a8f;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 20px;
}

.summary div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--panel-2);
}

.summary strong {
  display: block;
  font-size: 22px;
}

.summary span {
  color: var(--muted);
  font-size: 12px;
}

.story ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.story li {
  border-left: 3px solid var(--blue);
  background: #14171a;
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
}

.story time {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 2px;
}

.story strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.story small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.canvas {
  position: relative;
  min-width: 0;
}

.toolbar {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #111416;
}

.toolbar button {
  width: auto;
  min-width: 68px;
}

#graph {
  height: calc(100vh - 44px);
  width: 100%;
}

.notice {
  position: absolute;
  left: 18px;
  top: 58px;
  z-index: 2;
  max-width: min(520px, calc(100% - 36px));
  border: 1px solid #5f4522;
  border-radius: 6px;
  background: rgba(49, 34, 18, .94);
  color: #ffd89a;
  padding: 10px 12px;
  font-size: 13px;
}

.details {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(440px, calc(100% - 36px));
  max-height: 44vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 26, 29, .96);
  padding: 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
}

.details h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.details dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 10px;
  margin: 0;
  font-size: 13px;
}

.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }

.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.profile-card img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #f2f4f6;
}

.profile-card p,
.profile-intro {
  color: var(--muted);
  line-height: 1.35;
}

.details h4 {
  margin: 14px 0 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.details ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

.details li {
  margin: 3px 0;
}

.details li span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .panel { max-height: 44vh; border-right: 0; border-bottom: 1px solid var(--line); }
  #graph { height: 56vh; }
}
