:root {
  color-scheme: dark;
  --bg: #151515;
  --panel: #202020;
  --panel-2: #252525;
  --line: #383838;
  --line-strong: #4b4b4b;
  --text: #d6d6d6;
  --muted: #939393;
  --hot: #d7d7d7;
  --run: #6ac48a;
  --stop: #b7b7b7;
  --bad: #e07878;
  --button: #303030;
  --button-hover: #3a3a3a;
  --primary: #d0d0d0;
  --primary-text: #161616;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  letter-spacing: 0;
}

button,
select,
input,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  padding: 14px;
}

.topbar {
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px 12px;
}

h1 {
  color: var(--hot);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.2;
  margin: 0 0 7px;
}

.meta {
  color: var(--muted);
  display: flex;
  gap: 18px;
  white-space: nowrap;
}

.global-actions,
.row-actions {
  display: flex;
  gap: 6px;
}

button {
  background: var(--button);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--text);
  cursor: pointer;
  min-height: 30px;
  min-width: 58px;
  padding: 5px 10px;
}

button:hover {
  background: var(--button-hover);
}

button:disabled {
  color: #606060;
  cursor: not-allowed;
}

button.primary {
  background: var(--primary);
  color: var(--primary-text);
}

.route-grid {
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 8px;
}

.session-frame {
  background: var(--panel-2);
  border: 1px solid var(--line);
  min-width: 0;
}

.session-head {
  align-items: center;
  background: #1b1b1b;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-height: 48px;
  padding: 8px;
}

.session-identity {
  align-items: center;
  display: flex;
  flex: 1;
  gap: 8px;
  min-width: 0;
}

.session-heading {
  flex: 0 0 auto;
}

.session-memo-field {
  align-items: center;
  display: flex;
  flex: 1;
  gap: 5px;
  min-width: 0;
}

.session-memo-label {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 11px;
}

.session-memo {
  background: #111;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--text);
  min-height: 31px;
  flex: 1;
  min-width: 80px;
  padding: 5px 7px;
  width: 100%;
}

.session-memo:focus {
  border-color: #858585;
  outline: none;
}

.session-memo.is-saving {
  border-color: #a28a58;
}

.session-memo.save-error {
  border-color: var(--bad);
}

.session-title,
.channel-name {
  color: var(--hot);
  font-weight: 700;
}

.session-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

.session-source {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  padding: 6px 8px;
}

.session-source label {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.session-source select {
  background: #111;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--text);
  min-height: 30px;
  padding: 4px 7px;
}

.session-source select:disabled {
  color: var(--muted);
}

.source-detail {
  color: var(--muted);
  font-size: 11px;
}

.session-routes {
  display: grid;
  gap: 8px;
  padding: 8px;
}

.route-card {
  background: #202020;
  border: 1px solid var(--line);
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 8px;
}

.route-top,
.route-bottom {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-width: 0;
}

.source-name {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listener {
  background: #111;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--text);
  min-height: 31px;
  padding: 5px 7px;
  width: 100%;
}

.listener:focus {
  border-color: #858585;
  outline: none;
}

.state {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  text-transform: uppercase;
}

.dot {
  background: var(--stop);
  border-radius: 50%;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.running .dot {
  background: var(--run);
}

.error-text {
  color: var(--bad);
  margin-top: 5px;
}

.pid {
  color: var(--muted);
}

.status-line {
  border: 1px solid var(--line);
  border-top: 0;
  color: var(--muted);
  min-height: 34px;
  padding: 8px 10px;
}

.login-overlay {
  align-items: center;
  background: rgba(10, 10, 10, 0.86);
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 10;
}

.login-overlay[hidden] {
  display: none;
}

.login-box {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  display: grid;
  gap: 8px;
  padding: 14px;
  width: min(320px, calc(100vw - 28px));
}

.login-box label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.login-box input {
  background: #111;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--text);
  min-height: 34px;
  padding: 6px 8px;
}

@media (max-width: 760px) {
  .shell {
    padding: 8px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .global-actions {
    width: 100%;
  }

  .global-actions button {
    flex: 1;
  }

  .route-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .route-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .session-head {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .session-identity {
    flex-basis: 100%;
  }

  .session-head > .row-actions {
    justify-content: flex-end;
    width: 100%;
  }
}
