:root {
  color-scheme: dark;
  --bg: oklch(0.105 0.008 72);
  --panel: oklch(0.135 0.009 72);
  --panel-strong: oklch(0.17 0.01 72);
  --hover: oklch(0.205 0.012 72);
  --border: oklch(0.28 0.012 72);
  --border-strong: oklch(0.39 0.018 72);
  --text: oklch(0.94 0.008 78);
  --muted: oklch(0.72 0.014 78);
  --quiet: oklch(0.58 0.013 78);
  --accent: oklch(0.79 0.17 76);
  --accent-hover: oklch(0.84 0.15 76);
  --accent-ink: oklch(0.16 0.035 70);
  --success: oklch(0.78 0.16 145);
  --danger: oklch(0.7 0.19 28);
  --focus: oklch(0.84 0.14 76);
  --topbar: 3rem;
  --tabbar: 2.75rem;
  --softkeys: 0px;
  --radius: 0.55rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.terminal-app {
  display: flex;
  width: 100%;
  height: 100dvh;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  display: flex;
  min-height: var(--topbar);
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  padding: 0 0.75rem;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-mark,
.auth-mark {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
}

.brand-mark {
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid color-mix(in oklch, var(--accent) 45%, var(--border));
  border-radius: 0.4rem;
  background: color-mix(in oklch, var(--accent) 8%, var(--panel));
  font-size: 0.72rem;
}

.connection {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.connection-dot {
  width: 0.48rem;
  height: 0.48rem;
  border: 1px solid color-mix(in oklch, var(--success) 70%, black);
  border-radius: 50%;
  background: var(--success);
}

.connection.is-offline .connection-dot {
  border-color: color-mix(in oklch, var(--danger) 70%, black);
  background: var(--danger);
}

.toolbar {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
}

.icon-button,
.new-button {
  display: inline-flex;
  min-height: 2.1rem;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 0.42rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.73rem;
  font-weight: 600;
  transition:
    color 160ms var(--ease),
    border-color 160ms var(--ease),
    background-color 160ms var(--ease);
}

.icon-button {
  padding: 0 0.55rem;
}

.icon-button:hover,
.icon-button:active {
  border-color: var(--border);
  background: var(--hover);
  color: var(--text);
}

.icon-button svg,
.new-button svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.icon-button-quiet {
  width: 2.1rem;
  padding: 0;
  border-color: var(--border);
}

.tabbar {
  display: flex;
  min-height: var(--tabbar);
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--panel) 80%, var(--bg));
}

.tabs {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: stretch;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.tab {
  position: relative;
  display: flex;
  max-width: 14rem;
  min-width: 8.5rem;
  align-items: center;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
}

.tab::after {
  position: absolute;
  right: 0.55rem;
  bottom: -1px;
  left: 0.55rem;
  height: 2px;
  background: transparent;
  content: '';
}

.tab:hover {
  background: var(--hover);
  color: var(--text);
}

.tab[data-selected='true'] {
  background: var(--panel-strong);
  color: var(--text);
}

.tab[data-selected='true']::after {
  background: var(--accent);
}

.tab-select {
  display: flex;
  min-width: 0;
  height: 100%;
  flex: 1;
  align-items: center;
  gap: 0.45rem;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0 0.35rem 0 0.75rem;
  text-align: left;
}

.tab-kind {
  display: grid;
  width: 1.4rem;
  height: 1.4rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 0.35rem;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.58rem;
  font-weight: 700;
}

.tab-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-close {
  display: grid;
  width: 1.45rem;
  height: 1.45rem;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--quiet);
  cursor: pointer;
  opacity: 0;
}

.tab:hover .tab-close,
.tab:focus-within .tab-close,
.tab[data-selected='true'] .tab-close {
  opacity: 1;
}

.tab-close:hover {
  background: color-mix(in oklch, var(--danger) 16%, transparent);
  color: var(--danger);
}

.tab-close:disabled {
  background: transparent;
  color: var(--quiet);
  cursor: default;
  opacity: 0.35;
}

.new-button {
  min-width: 5.2rem;
  border-left: 1px solid var(--border);
  border-radius: 0;
  color: var(--accent);
  padding: 0 0.9rem;
}

.new-button:hover {
  background: color-mix(in oklch, var(--accent) 8%, var(--panel));
  color: var(--accent-hover);
}

.workspace {
  display: flex;
  min-height: 0;
  flex: 1;
  gap: 1px;
  background: var(--border);
}

.workspace.is-split .terminal-pane {
  flex-basis: 50%;
}

.terminal-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background: #11110f;
  box-shadow: inset 0 0 0 1px transparent;
}

.terminal-pane.is-focused {
  box-shadow: inset 0 0 0 1px
    color-mix(in oklch, var(--accent) 58%, transparent);
}

.terminal-pane iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #11110f;
}

.pane-badge {
  position: absolute;
  z-index: 3;
  top: 0.42rem;
  right: 0.5rem;
  display: flex;
  max-width: calc(100% - 1rem);
  align-items: center;
  gap: 0.4rem;
  border: 1px solid color-mix(in oklch, var(--border) 85%, transparent);
  border-radius: 0.36rem;
  background: color-mix(in oklch, var(--panel) 92%, transparent);
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1;
  opacity: 0;
  padding: 0.34rem 0.48rem;
  pointer-events: none;
  transition: opacity 160ms var(--ease);
}

.workspace.is-split .pane-badge,
.terminal-pane:hover .pane-badge,
.terminal-pane:focus-within .pane-badge {
  opacity: 1;
}

.pane-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pane-badge button {
  display: grid;
  width: 1.2rem;
  height: 1.2rem;
  place-items: center;
  border: 0;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  pointer-events: auto;
}

.pane-badge button:hover {
  background: var(--hover);
  color: var(--text);
}

.loading-state {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: #11110f;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
}

.loading-state span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite alternate;
}

.soft-keys {
  display: none;
}

.dialog {
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  border: 1px solid var(--border-strong);
  border-radius: 0.8rem;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1.5rem 5rem rgb(0 0 0 / 45%);
  padding: 0;
}

.dialog::backdrop {
  background: rgb(0 0 0 / 65%);
}

.dialog-small {
  width: min(25rem, calc(100vw - 2rem));
}

.dialog-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
}

.dialog-shell header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-shell p {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.dialog-shell h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.015em;
}

.dialog-close {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.15rem;
}

.dialog-close:hover {
  background: var(--hover);
  color: var(--text);
}

.launch-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.launch-list > button {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0.75rem;
  text-align: left;
}

.launch-list > button:hover,
.launch-list > button:focus-visible {
  border-color: var(--border-strong);
  background: var(--hover);
  color: var(--text);
}

.launch-list strong,
.launch-list small {
  display: block;
}

.launch-list strong {
  color: var(--text);
  font-size: 0.82rem;
}

.launch-list small {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.launch-icon {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 0.48rem;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 700;
}

.dialog-shell label,
.auth-form label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.dialog-shell input,
.auth-form input {
  width: 100%;
  min-height: 2.65rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.48rem;
  background: var(--bg);
  color: var(--text);
  padding: 0 0.75rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.button {
  min-height: 2.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.48rem;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0 0.9rem;
}

.button:hover {
  background: var(--hover);
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.button-primary:hover {
  background: var(--accent-hover);
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
}

.shortcut-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--border);
  padding: 0.7rem 0;
}

.shortcut-list dt {
  color: var(--muted);
  font-size: 0.76rem;
}

.shortcut-list dd {
  margin: 0;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.68rem;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 1rem;
  bottom: 1rem;
  max-width: min(24rem, calc(100vw - 2rem));
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  background: var(--panel-strong);
  color: var(--text);
  font-size: 0.75rem;
  opacity: 0;
  padding: 0.65rem 0.8rem;
  pointer-events: none;
  transform: translateY(0.5rem);
  transition:
    opacity 180ms var(--ease),
    transform 180ms var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.auth-screen {
  display: flex;
  width: min(32rem, calc(100% - 2rem));
  height: 100dvh;
  margin: 0 auto;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 0;
}

.auth-mark {
  width: 3.2rem;
  height: 3.2rem;
  border: 1px solid color-mix(in oklch, var(--accent) 55%, var(--border));
  border-radius: 0.7rem;
  background: color-mix(in oklch, var(--accent) 8%, var(--panel));
  font-size: 1rem;
}

.auth-domain {
  margin: 1.4rem 0 0.45rem;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.7rem;
}

.auth-screen h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: -0.035em;
}

.auth-copy {
  max-width: 34ch;
  margin: 0.65rem 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.form-error {
  min-height: 1.2rem;
  margin: 0;
  color: var(--danger);
  font-size: 0.75rem;
}

.auth-footnote {
  margin: 1.3rem 0 0;
  color: var(--quiet);
  font-size: 0.68rem;
}

@keyframes pulse {
  from {
    opacity: 0.35;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
