@font-face {
  font-family: "Glass TTY VT220";
  src: url("/fonts/Glass_TTY_VT220.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f5f3ef;
  --surface: #fffefa;
  --surface-2: #f8fafc;
  --text: #1c2320;
  --muted: #66736d;
  --line: #d7ddd8;
  --accent: #145a46;
  --accent-2: #276b9f;
  --accent-soft: #dceee8;
  --warn: #8a5a18;
  --warn-soft: #f4e8ce;
  --danger: #9b2f31;
  --danger-soft: #f6dddd;
  --shadow: 0 14px 34px rgba(23, 31, 28, 0.08);
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent-2);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.app-header,
.main-nav,
.capture-grid,
.view-root {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.app-header {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 14px;
}

.brand-block,
.header-actions,
.account-panel,
.controls,
.field-row,
.card-top,
.meta-row,
.main-nav,
.audio-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 2px;
  font-size: 24px;
  line-height: 1.1;
}

.brand-block p,
.view-head p,
.preview-text,
.meta-row,
.audio-head span,
.empty-state,
.token-field span {
  color: var(--muted);
}

.header-actions {
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
  display: none;
}

.account-panel {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.token-field.compact input {
  width: 96px;
}

.advanced-token {
  opacity: 0.72;
}

.status-stack {
  display: grid;
  gap: 6px;
}

.status-pill,
.privacy-pill,
.chip,
.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  width: max-content;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-pill.secondary {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-pill.error,
.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
}

.main-nav {
  flex-wrap: wrap;
  padding: 8px 0 18px;
}

.nav-item,
.primary-button,
.ghost-button,
.danger-button,
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.nav-item.active,
.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.nav-item.subdued {
  color: var(--muted);
}

.ghost-button:hover,
.nav-item:hover,
.upload-button:hover {
  border-color: var(--accent);
}

.capture-band,
.view-band {
  padding: 0 0 22px;
}

body:not(.capture-mode) .capture-band {
  display: none;
}

.home-actions,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

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

.home-action {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
}

.home-action.primary {
  border-color: var(--accent);
}

.home-action.private {
  border-color: var(--danger);
}

.home-action span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.home-action strong {
  font-size: 24px;
}

.edit-panel {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.edit-panel summary {
  cursor: pointer;
  font-weight: 800;
}

.edit-panel textarea {
  margin-top: 8px;
}

.task-check {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
}

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

.capture-fields,
.audio-panel,
.capture-card,
.object-card,
.object-detail,
.empty-state,
.search-panel,
.metric,
.task-lane,
.timeline-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.capture-fields,
.audio-panel,
.object-detail,
.search-panel {
  padding: 18px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span {
  font-size: 13px;
  font-weight: 700;
}

.field-row {
  align-items: end;
  flex-wrap: wrap;
}

.field-row .field {
  flex: 1 1 170px;
}

.check-field {
  display: flex;
  min-height: 40px;
  align-items: center;
  flex: 0 0 auto;
}

input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

.token-field {
  display: grid;
  gap: 5px;
  min-width: 150px;
}

.token-field input {
  min-height: 36px;
}

.controls {
  flex-wrap: wrap;
  margin-top: 14px;
}

.upload-button {
  position: relative;
  overflow: hidden;
}

.upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

button:disabled {
  opacity: 0.48;
  cursor: default;
}

.audio-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.audio-head {
  justify-content: space-between;
}

.audio-head h2 {
  margin: 0;
  font-size: 18px;
}

audio {
  width: 100%;
}

.view-root {
  display: grid;
  gap: 16px;
}

.view-head {
  display: flex;
  gap: 14px;
  align-items: end;
  justify-content: space-between;
  padding-top: 2px;
}

.view-head h2 {
  margin-bottom: 4px;
  font-size: 28px;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 16px;
}

.section-title {
  margin: 0 0 10px;
  font-size: 16px;
}

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

.card-list.compact {
  gap: 10px;
}

.capture-card,
.object-card,
.empty-state,
.timeline-item {
  padding: 15px;
}

.private-card {
  border-color: #cbbd95;
}

.card-top {
  justify-content: space-between;
  align-items: flex-start;
}

.card-top h3 {
  margin: 5px 0 0;
  font-size: 18px;
  line-height: 1.25;
}

.eyebrow {
  min-height: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0;
}

.privacy-pill {
  background: var(--surface-2);
  color: var(--muted);
}

.preview-text {
  margin: 12px 0;
  line-height: 1.5;
}

.meta-row {
  justify-content: space-between;
  font-size: 13px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.chip {
  background: var(--accent-soft);
  color: var(--accent);
}

.extract-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.mini-list {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.mini-list h4 {
  margin-bottom: 7px;
  font-size: 13px;
}

.mini-list ul {
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.review-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.object-links,
.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.metric {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.metric strong {
  font-size: 26px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.task-lane {
  padding: 12px;
  box-shadow: none;
}

.task-lane h3 {
  margin-bottom: 10px;
  text-transform: capitalize;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  font-size: 13px;
}

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

.timeline-item {
  display: grid;
  gap: 5px;
  box-shadow: none;
}

.timeline-item span {
  color: var(--muted);
  font-size: 13px;
}

.timeline-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.search-panel {
  display: grid;
  gap: 12px;
  box-shadow: none;
}

.search-results {
  display: grid;
  gap: 12px;
}

.object-detail {
  display: grid;
  gap: 14px;
}

.detail-body {
  white-space: pre-wrap;
  line-height: 1.6;
}

.json-preview {
  max-height: 420px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  color: #f5f7fa;
  font-size: 13px;
  line-height: 1.5;
}

.loading,
.empty-state {
  display: grid;
  min-height: 140px;
  place-items: center;
  text-align: center;
}

.empty-state p {
  margin: 0;
}

.focus-order-panel,
.watch-panel,
.architecture-panel,
.structure-card,
.mindmap-terminal,
.terminal-screen {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.focus-order-panel,
.watch-panel,
.structure-card,
.mindmap-terminal {
  padding: 16px;
}

.panel-label {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.focus-order-grid,
.structure-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.focus-step {
  display: grid;
  gap: 7px;
  min-height: 96px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.focus-step span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.focus-step strong {
  line-height: 1.35;
}

.watch-list {
  display: grid;
  gap: 8px;
}

.watch-list p {
  margin: 0;
  padding-left: 12px;
  border-left: 3px solid var(--warn);
  color: var(--muted);
  line-height: 1.45;
}

.architecture-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
}

.architecture-panel article {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.architecture-panel article:last-child {
  border-right: 0;
}

.architecture-panel span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.architecture-panel p,
.structure-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.structure-card {
  box-shadow: none;
}

.structure-card h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.structure-list {
  display: grid;
  gap: 8px;
}

.structure-list div,
.map-row,
.map-index button {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.structure-list span,
.map-row span {
  color: var(--muted);
}

.terminal-head h2,
.terminal-head p {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.mindmap-terminal {
  background: #020604;
  color: #a8ffbd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.terminal-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, 0.4fr);
  gap: 12px;
  margin-bottom: 14px;
}

.mindmap-terminal .field span,
.terminal-chip {
  color: #7dff9f;
}

.mindmap-terminal input,
.mindmap-terminal select {
  border-color: #164f2c;
  background: #000;
  color: #d6ffe1;
}

.mindmap-layout {
  display: grid;
  grid-template-columns: minmax(210px, 0.32fr) minmax(0, 1fr);
  gap: 14px;
}

.map-index {
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 12px;
  border: 1px solid #164f2c;
  border-radius: 8px;
  background: #000;
}

.map-index h3 {
  margin: 12px 0 0;
  color: #d6ffe1;
  font-size: 13px;
  text-transform: uppercase;
}

.map-index p {
  color: #77c990;
}

.map-index button {
  min-height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #a8ffbd;
  text-align: left;
}

.map-index-block {
  display: grid;
  gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid #164f2c;
}

.map-index-block strong {
  color: #d6ffe1;
  font-size: 28px;
}

.map-index-block span,
.map-node span {
  color: #77c990;
  font-size: 12px;
  text-transform: uppercase;
}

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

.map-node {
  display: grid;
  gap: 10px;
  min-height: 160px;
  padding: 14px;
  border: 1px solid #1d6a38;
  border-radius: 8px;
  background: #031108;
  cursor: pointer;
}

.map-node:hover {
  border-color: #7dff9f;
}

.map-node h3 {
  margin: 5px 0 0;
  color: #e2ffe9;
  font-size: 18px;
  line-height: 1.25;
}

.map-node p {
  margin: 0;
  color: #a8ffbd;
  line-height: 1.45;
}

.terminal-chip {
  border: 1px solid #1d6a38;
  background: #06190c;
}

body.terminal-mode {
  background: #000;
}

body.terminal-mode .app-header,
body.terminal-mode .capture-band {
  display: none;
}

body.terminal-mode .main-nav {
  width: 100%;
  padding: 10px;
  background: #000;
}

body.terminal-mode .nav-item {
  border-color: #006622;
  background: #000;
  color: #00b33c;
  font-family: "Glass TTY VT220", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

body.terminal-mode .nav-item.active {
  background: #001f0a;
  color: #00b33c;
}

body.terminal-mode .view-root {
  width: 100%;
}

.terminal-screen {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: calc(100vh - 72px);
  border: 0;
  border-radius: 0;
  background: #000;
  color: #00b33c;
  font-family: "Glass TTY VT220", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  text-shadow: 0 0 4px rgba(0, 179, 60, 0.82), 0 0 14px rgba(0, 179, 60, 0.38);
}

.terminal-output {
  overflow: auto;
  padding: clamp(16px, 3vw, 36px);
  line-height: 1.18;
  font-size: 16px;
}

.terminal-output pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
}

#terminalBoot {
  display: grid;
  gap: 3px;
  margin-bottom: 18px;
  color: #00b33c;
  font-size: 16px;
  font-weight: 400;
}

.terminal-line {
  display: grid;
  gap: 3px;
  margin: 0 0 10px;
}

.terminal-line span {
  color: #00b33c;
  font-size: 12px;
  font-weight: 400;
}

.terminal-line.user pre {
  color: #00b33c;
}

.terminal-line.assistant pre {
  color: #00b33c;
}

.terminal-input-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px clamp(16px, 3vw, 36px) 14px;
  border-top: 1px solid #006622;
  background: #000;
}

.terminal-input-row span {
  color: #00b33c;
  font-size: 18px;
  font-weight: 400;
}

.terminal-input-row input {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #00b33c;
  caret-color: #00b33c;
  outline: 0;
  font: inherit;
}

.terminal-cursor {
  display: block;
  width: 10px;
  height: 18px;
  background: #00b33c;
  box-shadow: 0 0 7px rgba(0, 179, 60, 0.9), 0 0 18px rgba(0, 179, 60, 0.42);
  animation: terminal-cursor 0.86s steps(1, end) infinite;
}

.terminal-input-row button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #006622;
  border-radius: 0;
  background: #000;
  color: #00b33c;
  font: inherit;
  font-weight: 400;
}

@keyframes terminal-cursor {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0.12;
  }
}

@media (max-width: 900px) {
  .app-header,
  .header-actions,
  .home-actions,
  .settings-grid,
  .capture-grid,
  .section-grid,
  .extract-grid,
  .task-board,
  .metric-row,
  .focus-order-grid,
  .structure-grid,
  .architecture-panel,
  .terminal-toolbar,
  .mindmap-layout,
  .map-nodes {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .architecture-panel article {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .architecture-panel article:last-child {
    border-bottom: 0;
  }

  .app-header,
  .brand-block {
    align-items: flex-start;
  }

  .field-row {
    align-items: stretch;
  }

  .nav-item {
    flex: 1 1 105px;
  }
}
