:root {
  color-scheme: dark;
  --bg: #0d1114;
  --panel: #151b20;
  --panel-strong: #1e272e;
  --line: #303a43;
  --text: #e9edf0;
  --muted: #92a0ab;
  --accent: #62b6cb;
  --ok: #7ccf95;
  --danger: #ef6b73;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  min-height: 720px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--accent);
  color: #071216;
  cursor: pointer;
  font-weight: 700;
  padding: 0 12px;
}

button.secondary {
  background: var(--panel-strong);
  color: var(--text);
}

button.danger {
  background: transparent;
  color: var(--danger);
}

button.active {
  border-color: var(--accent);
  background: var(--panel-strong);
  color: var(--text);
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b1014;
  color: var(--text);
  padding: 7px 10px;
}

textarea {
  min-height: 82px;
  resize: vertical;
  font-family: Menlo, Monaco, "Courier New", monospace;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.locked-screen {
  display: grid;
  height: 100vh;
  place-items: center;
  padding: 24px;
}

.unlock-panel {
  display: grid;
  gap: 22px;
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 24px;
}

.unlock-panel h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.unlock-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.unlock-form {
  display: grid;
  gap: 14px;
}

#lockedConfigButton {
  width: max-content;
}

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

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: #11171c;
  padding: 10px 14px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 180px;
}

.brand span {
  color: var(--ok);
  font-size: 12px;
}

.global-search {
  flex: 1;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.sidebar,
.command-panel {
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.resource-list,
.command-list {
  display: grid;
  align-content: start;
  gap: 8px;
  height: calc(100% - 48px);
  overflow: auto;
}

.resource-card,
.command-card,
.bookmark-card {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161b;
  color: var(--text);
  padding: 11px;
  text-align: left;
}

.resource-card:hover,
.command-card:hover,
.bookmark-card:hover {
  border-color: var(--accent);
}

.card-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.card-meta,
.card-note {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.view-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: #0f1519;
  padding: 8px 12px;
}

.terminal-view,
.navigation-view {
  min-height: 0;
  min-width: 0;
}

.terminal-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.terminal-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  padding: 6px 10px 0;
}

.terminal-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--panel);
  color: var(--text);
}

.tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-close {
  color: var(--muted);
  font-weight: 800;
}

.terminal-pane {
  position: relative;
  min-height: 0;
  background: #05080a;
  overflow: hidden;
}

.terminal-pane.has-session > .empty-state {
  display: none;
}

.session-pane {
  position: absolute;
  inset: 0;
  display: none;
  min-width: 0;
  min-height: 0;
}

.session-pane.active {
  display: grid;
}

.ssh-pane {
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 12px;
}

.xterm-host {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.xterm-host .xterm {
  height: 100%;
}

.browser-pane {
  grid-template-rows: auto minmax(0, 1fr);
}

.terminal-output {
  height: 100%;
  overflow: auto;
  margin: 0;
  color: #d9e6ea;
  font-family: Menlo, Monaco, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.terminal-command-form {
  display: block;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.terminal-command-input {
  font-family: Menlo, Monaco, "Courier New", monospace;
}

.browser-toolbar {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr) auto auto;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: #0f1519;
  padding: 8px;
}

.browser-toolbar button {
  min-height: 32px;
}

.browser-url {
  min-height: 32px;
}

.browser-webview {
  display: block;
  width: 100%;
  height: 100%;
  background: #ffffff;
}

.empty-state {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--muted);
}

.navigation-view {
  overflow: auto;
  padding: 16px;
}

.bookmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.bookmark-actions,
.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.bookmark-actions button,
.card-actions button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.command-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border-left: 1px solid var(--line);
  padding-bottom: 12px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.panel-header h2 {
  margin: 0;
  font-size: 17px;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

#commandSearchInput {
  width: calc(100% - 24px);
  margin: 12px;
}

.command-list {
  height: auto;
  padding: 0 12px;
}

.command-text {
  color: var(--text);
  font-family: Menlo, Monaco, "Courier New", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

dialog {
  width: min(680px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

dialog form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-actions {
  grid-template-columns: auto 1fr auto auto;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.config-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.config-test-result {
  min-height: 46px;
  max-height: 140px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b1014;
  color: var(--muted);
  font-family: Menlo, Monaco, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 9px;
  white-space: pre-wrap;
}
