:root {
  --bg: #101114;
  --panel: #181a1f;
  --panel-2: #20242b;
  --line: #323842;
  --text: #f4f6f8;
  --muted: #a7b0bd;
  --green: #1ed760;
  --cyan: #46c7e8;
  --rose: #ff657a;
  --amber: #f7b955;
  --violet: #a98bff;
  --shadow: 0 14px 40px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}

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

button {
  border: 1px solid transparent;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

button:hover { border-color: #53606f; }
button:active { transform: translateY(1px); }

.app {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) minmax(280px, 330px);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
}

.app-header {
  grid-column: 1 / -1;
  background: var(--panel);
  z-index: 20;
}

aside {
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

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

header {
  position: relative;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 760;
}

.sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel-scroll {
  padding: 16px 18px 18px;
  overflow: auto;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #111318;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 11px;
  outline: none;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(30, 215, 96, .12);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 20px;
}

.primary {
  background: var(--green);
  color: #071007;
  font-weight: 800;
}

.danger {
  background: #2c171d;
  color: #ffc8d0;
}

.icon-btn, .pill-btn {
  min-height: 38px;
  border-radius: 6px;
  padding: 8px 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.settings-menu {
  position: relative;
  flex: 0 0 auto;
}

.settings-menu summary {
  width: 38px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  list-style: none;
}

.settings-menu summary::-webkit-details-marker {
  display: none;
}

.settings-menu summary:hover {
  border-color: #53606f;
}

.settings-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  width: min(290px, calc(100vw - 28px));
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(24, 26, 31, .98);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.settings-panel .field {
  margin-bottom: 12px;
}

.settings-panel .actions {
  margin: 0 0 12px;
}

.login-gate {
  padding: 4px 0 16px;
}

.login-gate h2 {
  margin: 0 0 8px;
  font-size: 17px;
  letter-spacing: 0;
}

.login-gate .pill-btn {
  width: 100%;
  justify-content: center;
  margin-top: 12px;
}

.graph-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(70, 199, 232, .08), transparent 34%),
    linear-gradient(180deg, #121419, #0d0e11);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}

.toolset {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.status {
  max-width: min(560px, 56vw);
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(17, 19, 24, .82);
  border-radius: 6px;
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: auto;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.list {
  display: grid;
  gap: 8px;
}

.item {
  border: 1px solid var(--line);
  background: #13161b;
  border-radius: 6px;
  padding: 10px;
}

.item strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.selected {
  border-color: var(--green);
  background: rgba(30, 215, 96, .08);
}

.small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: #111318;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 14px;
}

.tab {
  min-height: 32px;
  border-radius: 4px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.tab.active {
  color: var(--text);
  background: var(--panel-2);
}

.hidden { display: none; }

.kbd {
  border: 1px solid var(--line);
  border-bottom-color: #4a5260;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--muted);
  background: #121419;
  font-size: 11px;
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .app {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .app-header {
    order: -2;
  }
  .graph-wrap {
    order: -1;
  }
  aside, .right {
    border: 0;
    border-bottom: 1px solid var(--line);
  }
  .graph-wrap {
    height: 68vh;
    min-height: 520px;
  }
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .status {
    max-width: none;
  }
}

@media (max-width: 640px) {
  body {
    min-height: 100svh;
  }

  .app {
    min-height: 100svh;
  }

  .app-header {
    position: sticky;
    top: 0;
  }

  aside {
    min-height: auto;
  }

  header {
    padding: 14px 14px 12px;
  }

  h1 {
    font-size: 18px;
  }

  .sub {
    font-size: 12px;
  }

  .panel-scroll {
    padding: 14px;
  }

  input, select, textarea {
    font-size: 16px;
    padding: 10px;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .actions {
    gap: 7px;
  }

  .pill-btn {
    flex: 1 1 140px;
    justify-content: center;
    min-height: 40px;
    padding: 9px 10px;
  }

  .graph-wrap {
    height: 62svh;
    min-height: 380px;
  }

  .toolbar {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 8px;
  }

  .toolset {
    gap: 6px;
  }

  .icon-btn {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    justify-content: center;
    padding: 7px;
  }

  .status {
    max-height: 82px;
    overflow: auto;
    padding: 8px 10px;
    font-size: 12px;
  }

}

@media (max-width: 420px) {
  .graph-wrap {
    height: 58svh;
    min-height: 340px;
  }

  .status {
    max-height: 70px;
  }

}
