:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1d2230;
  --text: #edf0f7;
  --muted: #9aa3b7;
  --line: #2a3142;
  --accent: #4f8cff;
  --danger: #ff5b6a;
  --ok: #35c88a;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

code,
pre {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

.login-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-card p {
  color: var(--muted);
  margin: 0 0 20px;
}

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

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.login-form input,
.composer textarea,
.ssh-password-form input {
  width: 100%;
  background: #0d1018;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
}

.alert {
  background: rgba(255, 91, 106, 0.12);
  border: 1px solid rgba(255, 91, 106, 0.4);
  color: #ffd5da;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 16px;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  overflow: hidden;
}

.chat-sidebar,
.context-panel {
  background: #11151f;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 14px;
}

.context-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.button,
button {
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  cursor: pointer;
}

.button.secondary {
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.button.danger {
  background: rgba(255, 91, 106, 0.14);
  color: #ffd5da;
  border: 1px solid rgba(255, 91, 106, 0.45);
}

.button.full {
  width: 100%;
}

.sidebar-title {
  color: var(--muted);
  font-size: 13px;
  margin: 18px 8px 8px;
}

.thread-list {
  display: grid;
  gap: 4px;
}

.thread-link {
  display: block;
  padding: 10px 10px;
  border-radius: var(--radius);
  color: var(--muted);
}

.thread-link.active,
.thread-link:hover {
  background: var(--panel-2);
  color: var(--text);
}

.sidebar-bottom {
  margin-top: 20px;
}

.chat-main {
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 23, 0.95);
}

.chat-header h1 {
  margin: 0;
  font-size: 20px;
}

.chat-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px;
}

.empty-state {
  max-width: 720px;
  margin: 10vh auto;
  text-align: center;
  color: var(--muted);
}

.message {
  display: grid;
  grid-template-columns: 72px minmax(0, 900px);
  gap: 12px;
  margin: 0 auto 22px;
  max-width: 1050px;
}

.message-user {
  grid-template-columns: 72px minmax(0, 760px);
  justify-content: end;
}

.message-label {
  color: var(--muted);
  font-size: 13px;
  padding-top: 12px;
}

.message-bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.message-user .message-bubble {
  background: #1f3a67;
  border-color: #31558d;
}

.message-system .message-bubble {
  background: #17241d;
  border-color: #2d6848;
}

.message-content {
  line-height: 1.58;
  white-space: normal;
  overflow: visible;
  max-height: none;
}

.copy-button {
  margin-top: 12px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 10px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message-assistant:hover .copy-button {
  opacity: 1;
}

.technical-details {
  margin-top: 12px;
  color: var(--muted);
}

.technical-details pre {
  white-space: pre-wrap;
  background: #0b0d13;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  overflow-x: auto;
}

.message-content p {
  margin: 0 0 10px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul,
.message-content ol {
  margin: 8px 0 10px 22px;
  padding: 0;
}

.message-content pre {
  background: #0b0d13;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
}

.message-content code {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  padding: 1px 5px;
}

.message-content pre code {
  background: transparent;
  border: 0;
  padding: 0;
}

.live-technical-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.task-events {
  display: grid;
  gap: 8px;
}

.task-event {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b0d13;
  padding: 10px;
}

.task-event-head {
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.task-event-message {
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.45;
}

.task-event-data {
  max-height: 280px;
  margin: 8px 0 0;
  font-size: 12px;
}

.task-event-data-details {
  margin-top: 8px;
}

.task-event-data-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}

.task-event-ok,
.task-event-completed {
  border-color: rgba(53, 200, 138, 0.45);
}

.task-event-running {
  border-color: rgba(79, 140, 255, 0.48);
}

.task-event-warning {
  border-color: rgba(240, 195, 106, 0.58);
}

.task-event-failed {
  border-color: rgba(255, 91, 106, 0.55);
}

.task-artifacts {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.artifact-title {
  color: var(--text);
  font-weight: 600;
}

.artifact-row {
  display: grid;
  grid-template-columns: minmax(82px, auto) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: #0b0d13;
}

.artifact-kind {
  color: var(--muted);
  font-size: 12px;
}

.artifact-row code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-artifact-path {
  padding: 6px 8px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.legacy-technical {
  margin-top: 12px;
}

.ssh-password-form {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.ssh-password-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.composer {
  flex: 0 0 auto;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
  background: rgba(15, 17, 23, 0.98);
}

.composer-textarea {
  min-height: 46px;
  max-height: 220px;
  resize: none;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.attach-button {
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
}

.attach-button input {
  display: none;
}

.composer-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.panel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.panel-card h2 {
  font-size: 15px;
  margin: 0 0 12px;
}

.panel-card p {
  color: var(--muted);
  line-height: 1.45;
}

.status-step {
  padding: 8px 0;
  color: var(--muted);
}

.status-step.done {
  color: var(--ok);
}

.status-step.pending {
  color: #f0c36a;
}

.task-status {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 16, 24, 0.62);
  padding: 12px;
}

.task-status-title,
.task-mini-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.task-line {
  margin: 5px 0;
  line-height: 1.45;
}

.muted {
  color: var(--muted);
}

.task-progress {
  height: 6px;
  background: #0b0d13;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}

.task-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-mini {
  margin-top: 0;
}

.task-mini-finished,
.task-mini-old {
  opacity: 0.82;
}

.task-history {
  margin-top: 12px;
}

.compact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.compact-actions form {
  margin: 0;
}

.compact-actions button {
  padding: 7px 9px;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .context-panel {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    display: block;
    overflow: visible;
  }

  .chat-sidebar {
    max-height: 220px;
  }

  .chat-main {
    height: auto;
    min-height: calc(100vh - 220px);
  }

  .messages {
    overflow: visible;
    padding: 16px;
  }

  .message,
  .message-user {
    grid-template-columns: 1fr;
  }

  .message-label {
    padding-top: 0;
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .ssh-password-form {
    grid-template-columns: 1fr;
  }
}


.chat-confirm-actions {
  margin-top: 14px;
  border: 1px solid rgba(96, 165, 250, 0.45);
  background: rgba(37, 99, 235, 0.10);
  border-radius: 12px;
  padding: 12px;
}

.chat-confirm-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.chat-confirm-summary {
  display: grid;
  gap: 10px;
}

.summary-block {
  display: grid;
  gap: 5px;
}

.summary-heading {
  color: var(--text);
  font-weight: 600;
}

.summary-block ul {
  margin: 0 0 0 20px;
  padding: 0;
  color: var(--muted);
}

.summary-warning {
  border: 1px solid rgba(240, 195, 106, 0.58);
  border-radius: var(--radius);
  color: #f0c36a;
  padding: 8px;
  background: rgba(240, 195, 106, 0.08);
}

.summary-scope-badge {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.summary-scope-ok {
  border-color: rgba(53, 200, 138, 0.45);
  color: #b9f4d9;
  background: rgba(53, 200, 138, 0.08);
}

.summary-scope-warning,
.scope-warning {
  border-color: rgba(240, 195, 106, 0.58);
  color: #f0c36a;
}

.diff-checks {
  white-space: pre-line;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
}

.diff-checks-ok {
  border-color: rgba(53, 200, 138, 0.45);
  color: #b9f4d9;
}

.diff-checks-blocked {
  border-color: rgba(255, 91, 106, 0.55);
  color: #ffd5da;
}

.chat-confirm-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  align-items: flex-start;
}

.chat-confirm-buttons form {
  margin: 0;
}

.chat-confirm-note {
  color: var(--muted);
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.35;
}

.user-diff-viewer {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.14);
  padding: 9px 11px;
}

.user-diff-viewer summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.user-diff-content {
  max-height: 360px;
  margin: 10px 0 0;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-x: auto;
}

.active-task-feed {
  max-width: 1050px;
  margin: 0 auto 22px;
}

.task-card {
  border: 1px solid rgba(79, 140, 255, 0.42);
  background: rgba(79, 140, 255, 0.07);
  border-radius: var(--radius);
  padding: 14px;
}

.task-card-terminal {
  border-color: rgba(53, 200, 138, 0.35);
  background: rgba(53, 200, 138, 0.06);
}

.task-card-blocked {
  border-color: rgba(240, 195, 106, 0.5);
  background: rgba(240, 195, 106, 0.07);
}

.task-card + .task-card {
  margin-top: 14px;
}

.task-card-title {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.task-card-heading {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 8px;
}

.task-card-note {
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.45;
}

.compact-summary-list {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--text);
}

.code-copy-wrap {
  position: relative;
}

.code-copy-wrap .copy-code-button {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(0,0,0,.3);
  color: var(--muted);
  font-size: 12px;
  padding: 5px 8px;
}

.code-copy-wrap pre {
  padding-top: 40px;
}

.compact-task-body .task-line {
  font-size: 13px;
}

.compact-task-body .task-progress {
  display: none;
}

.task-mini-details {
  margin-top: 6px;
}

.task-mini-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}


.task-live-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.task-live-form {
  margin: 0;
}

.task-live-actions button {
  border: 1px solid var(--border, #2a3444);
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
}

.task-live-primary {
  background: #4f8cff;
  color: #ffffff;
}

.task-live-secondary {
  background: #1c2330;
  color: #e5e7eb;
}


.web-mode-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  color: var(--muted, #a7a7a7);
  background: rgba(255,255,255,.04);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.web-mode-control select {
  border: 0;
  border-radius: 999px;
  padding: 5px 24px 5px 8px;
  color: var(--text, #fff);
  background: rgba(124,156,255,.16);
  font: inherit;
  outline: none;
}

.web-mode-control:focus-within {
  border-color: rgba(124,156,255,.55);
  box-shadow: 0 0 0 2px rgba(124,156,255,.14);
}

.header-quick-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 999px;
  color: var(--text, #fff);
  text-decoration: none;
  background: rgba(255,255,255,.05);
}

.header-quick-link:hover {
  border-color: rgba(124,156,255,.55);
  background: rgba(124,156,255,.12);
}

.web-confirm-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(124,156,255,.25);
  border-radius: 12px;
  background: rgba(124,156,255,.08);
}

.web-confirm-title {
  font-weight: 700;
  color: var(--text, #fff);
}

.web-confirm-text {
  margin-top: 4px;
  color: var(--muted, #a7a7a7);
  font-size: 14px;
}

.web-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.attachment-selected {
  color: var(--muted, #a7a7a7);
  font-size: 13px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.attachment-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.04);
}

.attachment-name {
  color: var(--text, #fff);
  font-weight: 600;
}

.attachment-meta {
  margin-top: 3px;
  color: var(--muted, #a7a7a7);
  font-size: 12px;
}

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

@media (max-width: 760px) {
  .web-mode-control {
    width: 100%;
    justify-content: center;
  }

  .attachment-card {
    align-items: flex-start;
    flex-direction: column;
  }
}

.alert-ok {
  background: rgba(53, 200, 138, 0.12);
  border: 1px solid rgba(53, 200, 138, 0.45);
  color: #d7ffe9;
}

.nloto-shell {
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
  color: var(--text);
}

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

.nloto-header h1 {
  margin: 0;
  font-size: 24px;
}

.nloto-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.nloto-links {
  display: flex;
  gap: 8px;
}

.nloto-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.nloto-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.nloto-card h2 {
  margin-top: 0;
}

.nloto-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.nloto-actions form {
  margin: 0;
}

.nloto-import-form {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.nloto-import-form input[type="text"] {
  width: 100%;
}


.nloto-analyze-form {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.nloto-analyze-form select,
.nloto-analyze-form input[type="number"] {
  width: 100%;
}

.nloto-check {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.nloto-metrics,
.nloto-warnings {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.nloto-table-wrap {
  overflow-x: auto;
}

.nloto-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.nloto-table th,
.nloto-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
}

.nloto-table th {
  color: var(--muted);
  font-weight: 600;
}

.nloto-report {
  white-space: pre-wrap;
  background: #0d1018;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  max-height: 520px;
  overflow: auto;
}

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

  .nloto-header {
    flex-direction: column;
    align-items: flex-start;
  }
}


.memory-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

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

.memory-header h1 {
  margin: 0 0 6px;
}

.memory-header p {
  margin: 0;
  color: var(--muted, #8a93a6);
}

.memory-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.memory-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 16px;
  margin-bottom: 16px;
}

.memory-card {
  background: var(--panel, #111827);
  border: 1px solid var(--border, rgba(255,255,255,.12));
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
}

.memory-card h2 {
  margin: 0 0 14px;
}

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

.memory-form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.memory-form textarea,
.memory-form select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(255,255,255,.14));
  background: var(--input, rgba(255,255,255,.06));
  color: inherit;
  padding: 10px 12px;
}

.memory-help,
.memory-help-list {
  color: var(--muted, #8a93a6);
  font-size: 0.95rem;
}

.memory-help-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.memory-list {
  display: grid;
  gap: 12px;
}

.memory-item {
  border: 1px solid var(--border, rgba(255,255,255,.12));
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,.035);
}

.memory-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.memory-item-head span {
  margin-left: 8px;
  color: var(--muted, #8a93a6);
}

.memory-item pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: inherit;
  line-height: 1.45;
}

.button.small {
  padding: 6px 10px;
  font-size: 0.88rem;
}

.notice.success {
  border: 1px solid rgba(74, 222, 128, .35);
  background: rgba(74, 222, 128, .12);
}

.notice.error {
  border: 1px solid rgba(248, 113, 113, .35);
  background: rgba(248, 113, 113, .12);
}

@media (max-width: 820px) {
  .memory-header,
  .memory-grid {
    grid-template-columns: 1fr;
    display: grid;
  }
}
