:root {
  color-scheme: dark;
  --ink: #f2efe6;
  --muted: #9a9c96;
  --panel: #151613;
  --panel-strong: #1b1d19;
  --line: #2a2d27;
  --field: #10110f;
  --green: #a8c9a1;
  --green-strong: #8fbf86;
  --amber: #d4b06a;
  --red: #c77878;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: #0d0e0c;
  color: var(--ink);
  font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, opacity 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.screen {
  min-height: 100vh;
}

.screen-login {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 420px);
}

.login-panel,
.status-panel,
.actions-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 52px var(--shadow);
}

.login-panel {
  padding: 28px;
}

.brand-row,
.status-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-name,
.eyebrow,
.label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.signal-dot,
.status-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

h1 {
  margin: 18px 0 22px;
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 12px;
}

label {
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.12);
}

.login-form button,
.primary-button {
  border-radius: 6px;
  background: var(--green);
  color: #0b100a;
  font-weight: 800;
}

.console-shell {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 6px 0 0;
}

.ghost-button,
.secondary-button,
.danger-button {
  border-radius: 6px;
  color: var(--ink);
  background: var(--panel-strong);
  border-color: var(--line);
}

.secondary-button {
  border-color: rgba(143, 179, 199, 0.4);
}

.danger-button {
  border-color: rgba(248, 113, 113, 0.45);
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.status-panel,
.actions-panel {
  padding: 18px;
}

.status-header strong {
  display: block;
  margin-top: 3px;
  font-size: 26px;
}

.status-light.idle {
  background: var(--muted);
  box-shadow: none;
}

.status-light.starting,
.status-light.stopping {
  background: var(--amber);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.status-light.running {
  background: var(--green-strong);
}

.status-light.error {
  background: var(--red);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 0;
}

.metrics div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: #11120f;
}

dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

dd {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.actions-panel {
  display: grid;
  gap: 10px;
}

.message {
  min-height: 20px;
  margin: 4px 0 0;
  color: var(--amber);
  font-size: 12px;
  line-height: 1.45;
}

.hidden {
  display: none;
}

/* ── ChatGPT session panel ── */

.chatgpt-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 52px var(--shadow);
  overflow: hidden;
}

.chatgpt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.chatgpt-header h2 {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.chatgpt-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.chatgpt-badge--none {
  color: var(--muted);
  border-color: var(--line);
}

.chatgpt-badge--active {
  color: var(--green-strong);
  border-color: rgba(143, 191, 134, 0.4);
  background: rgba(143, 191, 134, 0.08);
}

.chatgpt-badge--expired {
  color: var(--red);
  border-color: rgba(199, 120, 120, 0.4);
}

.chatgpt-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 0;
}

.chatgpt-import {
  padding: 18px;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.chatgpt-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.chatgpt-label code {
  color: var(--ink);
  background: var(--field);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--line);
}

.chatgpt-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  padding: 12px 14px;
  resize: vertical;
  font: inherit;
  font-size: 11px;
  line-height: 1.5;
  outline: none;
}

.chatgpt-textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.12);
}

.chatgpt-actions {
  display: flex;
  gap: 10px;
}

.chatgpt-actions button {
  flex: 1;
}

.chatgpt-info {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chatgpt-meta {
  display: grid;
  gap: 12px;
  margin: 0;
}

.chatgpt-meta div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #11120f;
}

.chatgpt-meta dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.chatgpt-meta dd {
  margin: 5px 0 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.chatgpt-hint {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 820px) {
  .chatgpt-body {
    grid-template-columns: 1fr;
  }

  .chatgpt-import {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .console-shell {
    padding: 18px;
  }

  .topbar,
  .control-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  .metrics {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 36px;
  }
}

/* ── Launch / new-session card ── */

.screen-launch {
  display: flex;
  justify-content: center;
  padding: 40px 16px 80px;
}

.launch-wrap {
  width: min(100%, 580px);
}

.launch-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.launch-header h1 {
  margin: 6px 0 0;
  font-size: 32px;
}

.launch-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 18px 52px var(--shadow);
  padding: 28px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 24px;
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 7px;
}

.field-textarea,
.field-select {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 12px 14px;
  font: inherit;
  font-size: 12px;
  outline: none;
}

.field-textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.5;
}

.field-textarea:focus,
.field-select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.1);
}

.field-select option {
  background: var(--panel);
}

.field-hint {
  margin: 7px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

.field-hint code {
  color: var(--ink);
  background: var(--field);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--line);
}

.launch-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 6px;
}

.btn-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: #0b100a;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.launch-status {
  min-height: 18px;
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.launch-status--info  { color: var(--muted); }
.launch-status--ok    { color: var(--green); }
.launch-status--error { color: var(--red); }

.launch-info {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 16px;
  background: var(--field);
  display: grid;
  gap: 10px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
}

.info-key {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.info-val {
  text-align: right;
  overflow-wrap: anywhere;
}

.info-val.state-running  { color: var(--green-strong); }
.info-val.state-starting,
.info-val.state-stopping { color: var(--amber); }
.info-val.state-error    { color: var(--red); }
.info-val.state-idle     { color: var(--muted); }

.info-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.info-actions button {
  flex: 1;
  min-height: 38px;
  font-size: 13px;
  border-radius: 6px;
}
