:root {
  color-scheme: dark;
  --tm-bg: #1e1e1e;
  --tm-side: #181818;
  --tm-panel: #1b1b1b;
  --tm-panel-2: #252526;
  --tm-line: #2b2b2b;
  --tm-line-soft: rgba(255, 255, 255, 0.075);
  --tm-text: #d4d4d4;
  --tm-muted: #8b949e;
  --tm-blue: #3794ff;
  --tm-blue-deep: #0e639c;
  --tm-cyan: #22d3ee;
  --tm-green: #73c991;
  --tm-yellow: #cca700;
  --tm-red: #f14c4c;
  --tm-ink: #06111f;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--tm-bg);
  color: var(--tm-text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
}

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

button {
  min-height: 32px;
  border: 1px solid var(--tm-line);
  border-radius: 4px;
  background: #242424;
  color: var(--tm-text);
  padding: 0 10px;
}

button:hover {
  border-color: rgba(55, 148, 255, 0.65);
  background: #2a2d2e;
}

button:disabled {
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--tm-line);
  border-radius: 4px;
  background: #242424;
  color: var(--tm-text);
  outline: none;
}

input,
select {
  min-height: 34px;
  padding: 0 9px;
}

textarea {
  min-height: 110px;
  resize: vertical;
  padding: 9px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(55, 148, 255, 0.72);
  box-shadow: 0 0 0 1px rgba(55, 148, 255, 0.18);
}

label span {
  display: block;
  margin: 0 0 5px;
  color: var(--tm-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-size: 14px;
  line-height: 1.2;
}

p {
  margin-top: 4px;
  color: var(--tm-muted);
  font-size: 12px;
}

pre {
  margin: 0;
}

.tm-workbench {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  background: var(--tm-bg);
}

.tm-rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 0;
  background: var(--tm-side);
  border-right: 1px solid var(--tm-line);
  z-index: 8;
}

.tm-rail-brand {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-bottom: 9px;
  border-radius: 4px;
  background: var(--tm-blue-deep);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.tm-rail-item {
  width: 34px;
  height: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--tm-muted);
  font-size: 12px;
  font-weight: 800;
}

.tm-rail-item:hover,
.tm-rail-item.is-active {
  background: #2a2d2e;
  color: var(--tm-text);
}

.tm-rail-item.is-active {
  border-left-color: var(--tm-blue);
}

.tm-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tm-commandbar {
  position: sticky;
  top: 0;
  z-index: 7;
  min-height: 42px;
  display: grid;
  grid-template-columns: auto minmax(120px, 220px) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 5px 10px;
  border-bottom: 1px solid var(--tm-line);
  background: #1b1b1b;
}

.tm-product-switcher {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  padding: 1px;
  border: 1px solid var(--tm-line);
  background: #151515;
}

.tm-product-tab {
  width: 26px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--tm-muted);
  font-size: 11px;
  font-weight: 900;
}

.tm-product-tab.is-active {
  border-color: rgba(55, 148, 255, 0.55);
  background: #2a2d2e;
  color: var(--tm-blue);
}

.tm-breadcrumb {
  min-width: 0;
  display: flex;
  gap: 6px;
  color: var(--tm-muted);
  font-size: 12px;
}

.tm-breadcrumb strong {
  min-width: 0;
  color: var(--tm-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-command-input {
  height: 30px;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 1px solid var(--tm-line);
  background: #242424;
}

.tm-command-input span {
  margin: 0;
}

.tm-command-input input {
  min-height: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
}

.tm-command-actions,
.tm-action-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.tm-icon-command {
  min-width: 44px;
  height: 30px;
  min-height: 30px;
  padding: 0 8px;
}

.tm-primary {
  border-color: rgba(55, 148, 255, 0.75);
  background: var(--tm-blue);
  color: var(--tm-ink);
  font-weight: 800;
}

.tm-primary:hover {
  background: #5aa7ff;
  color: var(--tm-ink);
}

.tm-toast {
  position: fixed;
  left: 58px;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  max-width: 760px;
  padding: 10px 12px;
  border: 1px solid rgba(55, 148, 255, 0.55);
  border-radius: 6px;
  background: #151515;
  color: var(--tm-text);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
}

.tm-content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.tm-hero {
  min-height: 96px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--tm-line);
}

.tm-kicker,
.tm-panel-head p,
.tm-status-label {
  color: var(--tm-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tm-live-pill,
.tm-chip,
.tm-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--tm-line);
  border-radius: 999px;
  background: #242424;
  color: var(--tm-muted);
  font-size: 12px;
}

.tm-live-pill.ok,
.tm-status-pill.ok {
  border-color: rgba(115, 201, 145, 0.45);
  color: var(--tm-green);
}

.tm-live-pill.bad,
.tm-status-pill.bad {
  border-color: rgba(241, 76, 76, 0.48);
  color: var(--tm-red);
}

.tm-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.tm-status-card,
.tm-panel {
  border: 1px solid var(--tm-line);
  border-radius: 8px;
  background: var(--tm-panel);
}

.tm-status-card {
  min-height: 112px;
  padding: 12px;
}

.tm-status-card strong {
  display: block;
  margin-top: 9px;
  font-size: 18px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.tm-status-card small {
  display: block;
  margin-top: 8px;
  color: var(--tm-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tm-tab {
  display: none;
}

.tm-tab.is-active {
  display: block;
}

.tm-two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 12px;
}

.tm-panel {
  min-width: 0;
  padding: 12px;
  margin-bottom: 12px;
}

.tm-panel-main {
  min-height: 360px;
}

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

.tm-panel-head.compact {
  margin-top: 16px;
}

.tm-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.tm-action-row {
  margin-top: 10px;
}

.tm-action-row > input,
.tm-action-row > button {
  flex: 1 1 auto;
}

.tm-list,
.tm-mini-list,
.tm-signal-list,
.tm-chip-list {
  display: grid;
  gap: 8px;
}

.tm-list.compact {
  margin-top: 10px;
}

.tm-item,
.tm-signal,
.tm-process,
.tm-file-entry {
  border: 1px solid var(--tm-line-soft);
  border-radius: 6px;
  background: #202020;
  padding: 10px;
}

.tm-item:hover,
.tm-file-entry:hover {
  border-color: rgba(55, 148, 255, 0.45);
  background: #252526;
}

.tm-item strong,
.tm-process strong,
.tm-file-entry strong,
.tm-signal strong {
  display: block;
  color: var(--tm-text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tm-item small,
.tm-process small,
.tm-file-entry small,
.tm-signal small {
  display: block;
  margin-top: 4px;
  color: var(--tm-muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.tm-item-row,
.tm-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tm-file-entry {
  width: 100%;
  text-align: left;
}

.tm-file-entry.is-dir strong {
  color: var(--tm-blue);
}

.tm-chip-list {
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}

.tm-chip {
  min-width: 0;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-preview {
  min-height: 300px;
  max-height: 58dvh;
  overflow: auto;
  border: 1px solid var(--tm-line);
  border-radius: 6px;
  background: #111;
  color: #d4d4d4;
  padding: 12px;
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tone-ok,
.ok {
  color: var(--tm-green);
}

.tone-bad,
.bad {
  color: var(--tm-red);
}

.tone-warn,
.warn {
  color: var(--tm-yellow);
}

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

::-webkit-scrollbar-thumb {
  background: #3f3f46;
}

::-webkit-scrollbar-track {
  background: #1e1e1e;
}

@media (max-width: 980px) {
  .tm-commandbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .tm-command-input {
    grid-column: 1 / -1;
    order: 4;
  }

  .tm-status-grid,
  .tm-two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .tm-workbench {
    grid-template-columns: 1fr;
    padding-bottom: 98px;
  }

  .tm-rail {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100svw;
    max-width: 100svw;
    height: 98px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, 31px);
    align-items: center;
    gap: 0;
    padding: 3px 0;
    overflow: hidden;
    border-right: 0;
    border-top: 1px solid var(--tm-line);
  }

  .tm-rail-brand {
    display: none;
  }

  .tm-rail-item {
    flex: 1 1 0;
    width: 100%;
    height: 31px;
    min-height: 31px;
    min-width: 0;
    border-left: 0;
    border-bottom: 2px solid transparent;
  }

  .tm-rail-item.is-active {
    border-bottom-color: var(--tm-blue);
  }

  .tm-content {
    padding: 12px;
  }

  .tm-commandbar,
  .tm-status-grid,
  .tm-two-col,
  .tm-form-grid {
    grid-template-columns: 1fr;
  }

  .tm-commandbar {
    gap: 7px;
  }

  .tm-product-switcher,
  .tm-breadcrumb,
  .tm-command-actions {
    justify-self: stretch;
  }

  .tm-command-actions,
  .tm-action-row,
  .tm-hero,
  .tm-panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .tm-hero {
    min-height: 128px;
  }

  .tm-toast {
    left: 12px;
    right: 12px;
    bottom: 110px;
  }
}
