/* Dom — dark editorial design. Guardianity brand. */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,600;9..144,900&family=DM+Sans:wght@400;500&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:        #0c0c0c;
  --raised:    #141414;
  --panel:     #111111;
  --line:      #1e1e1e;
  --border:    #272727;
  --faint:     #484848;
  --subtle:    #666666;
  --muted:     #999999;
  --fg:        #cccccc;
  --fg-bright: #ebebeb;
  --fg-strong: #ffffff;
  --accent:    #c44b1b;
  --amber:     #e0a14a;
  --ok:        #5bbd8a;
  --bad:       #d9534f;

  --display: 'Fraunces', Georgia, serif;
  --sans:    'DM Sans', system-ui, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Grid pattern ── */
.grid-bg {
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* ── Typography ── */
.label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.label-accent {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}
.display {
  font-family: var(--display);
  color: var(--fg-strong);
  line-height: 0.88;
  letter-spacing: -0.01em;
}
.muted { color: var(--muted); font-size: 13px; }

/* ── Inputs ── */
input[type="text"],
input[type="password"],
input[type="email"],
textarea {
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--fg-strong);
  font-family: var(--sans);
  font-size: 14px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  border-radius: 0;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Buttons ── */
button {
  background: var(--accent);
  color: #fff;
  border: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 12px 22px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s;
}
button:hover:not(:disabled) { background: #d45c28; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 14px;
  font-size: 9px;
}
button.ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}
button.ghost.active {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

/* ── Animations ── */
@keyframes rise    { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pulse   { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes blink   { 0%, 100% { opacity: 1; } 50% { opacity: 0.15; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

.rise { animation: rise 0.3s ease; }

/* ── Live dot ── */
.dot-live {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 1.8s infinite;
  vertical-align: middle;
}

/* ── Auth gate ── */
.gate-wrap {
  min-height: 100vh;
  display: flex;
  position: relative;
}

.gate-brand {
  display: none;
  flex: 0 0 600px;
  background: var(--raised);
  border-right: 1px solid var(--border);
  flex-direction: column;
  justify-content: space-between;
  padding: 52px;
  position: relative;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .gate-brand { display: flex; }
}

.gate-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
}

/* ── Workspace ── */
.workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.ws-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.ws-logo {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 900;
  color: var(--fg-strong);
  letter-spacing: 0.06em;
}

.ghost-link {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 5px 11px;
  transition: color 0.15s, border-color 0.15s;
}
.ghost-link:hover { color: var(--accent); border-color: var(--accent); }

.ws-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* ── Chat column ── */
.chat-col {
  flex: 0 0 45%;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.col-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-thread::-webkit-scrollbar { width: 3px; }
.chat-thread::-webkit-scrollbar-thumb { background: var(--border); }

.msg {
  max-width: 82%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  animation: rise 0.25s ease;
}
.msg.master {
  background: var(--raised);
  border: 1px solid var(--border);
  margin-left: auto;
  color: var(--fg-bright);
}
.msg.dom {
  background: var(--panel);
  border-left: 3px solid var(--accent);
  color: var(--fg);
}
.msg.thinking {
  color: var(--subtle);
  font-style: italic;
  font-size: 13px;
  animation: blink 1.2s infinite;
  border-left: 3px solid var(--border);
}

.chat-input {
  flex-shrink: 0;
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.chat-input input {
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  padding: 14px 18px;
  font-size: 14px;
  flex: 1;
  border-radius: 0;
}
.chat-input input:focus { border-color: transparent; outline: none; }
.chat-input button {
  padding: 14px 20px;
  font-size: 16px;
  letter-spacing: 0;
  flex-shrink: 0;
  border-radius: 0;
}

/* ── Feed column ── */
.feed-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

/* ── Stats strip ── */
.stats-strip {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
}
.stat-cell {
  padding: 14px 20px;
  border-right: 1px solid var(--border);
}
.stat-cell:last-child { border-right: none; }
.stat-n {
  font-family: var(--display);
  font-size: 28px;
  color: var(--fg-strong);
  line-height: 1;
  margin-bottom: 4px;
}

/* ── Domain bars ── */
.domain-bars {
  flex-shrink: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 42px;
}
.domain-pill {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.domain-pill.has-data { border-color: var(--accent); color: var(--accent); }

/* ── Memory feed ── */
.mem-feed {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.mem-feed::-webkit-scrollbar { width: 3px; }
.mem-feed::-webkit-scrollbar-thumb { background: var(--border); }

.mem-card {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  animation: slide-in 0.3s ease;
  cursor: default;
}
.mem-card:hover { background: var(--raised); }
.mem-card .mem-domain {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.mem-card .mem-content {
  font-size: 12px;
  color: var(--fg);
  line-height: 1.5;
}

/* ── Feed search ── */
.feed-search {
  flex-shrink: 0;
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.feed-search input {
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  padding: 11px 16px;
  font-size: 13px;
  flex: 1;
  border-radius: 0;
}
.feed-search button {
  padding: 11px 18px;
  font-size: 9px;
  flex-shrink: 0;
  border-radius: 0;
}
.search-result {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  animation: rise 0.2s ease;
}
.search-result .sr-domain {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 3px;
}

/* ── Tab row ── */
.tab-row {
  flex-shrink: 0;
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 11px 0;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tab-btn:hover:not(:disabled) { color: var(--fg); background: transparent; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: transparent; }

/* ── Tab panes ── */
.tab-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── Documents feed ── */
.doc-feed {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.doc-feed::-webkit-scrollbar { width: 3px; }
.doc-feed::-webkit-scrollbar-thumb { background: var(--border); }

.doc-empty {
  padding: 32px 20px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--faint);
  text-transform: uppercase;
}

.doc-card {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  animation: slide-in 0.25s ease;
}
.doc-card:hover { background: var(--raised); }

.doc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.doc-badge {
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.2em;
  padding: 2px 7px;
  color: #fff;
  background: var(--faint);
  text-transform: uppercase;
  flex-shrink: 0;
}
.doc-dept {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-title {
  font-size: 13px;
  color: var(--fg-bright);
  margin-bottom: 7px;
  line-height: 1.4;
}
.doc-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--subtle);
}
.doc-open {
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.1em;
  font-size: 8px;
  font-family: var(--mono);
  margin-left: auto;
  transition: color 0.15s;
}
.doc-open:hover { color: var(--fg-bright); }

/* ── Files pane ── */
.drop-zone {
  margin: 20px;
  border: 1px dashed var(--border);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(196, 75, 27, 0.06);
}
.drop-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-prompt {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  pointer-events: none;
}
.drop-prompt span { color: var(--subtle); display: block; margin-top: 6px; font-size: 9px; }

.upload-progress {
  margin: 0 20px 10px;
}
.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--fg);
  animation: rise 0.2s ease;
}
.upload-item .up-name { flex: 1; color: var(--fg-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .up-size { color: var(--subtle); flex-shrink: 0; }
.upload-item .up-status { flex-shrink: 0; }
.upload-item .up-status.ok  { color: var(--ok); }
.upload-item .up-status.err { color: var(--bad); }

.uploads-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.uploads-header h3 {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: normal;
}

.uploads-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
}
.uploads-list::-webkit-scrollbar { width: 3px; }
.uploads-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--fg);
}
.uploads-list li:hover { background: var(--raised); }
.uploads-list .upl-name { flex: 1; color: var(--fg-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploads-list .upl-size { color: var(--subtle); flex-shrink: 0; }
.uploads-list .upl-empty { color: var(--faint); text-transform: uppercase; letter-spacing: 0.14em; }

/* ── System pane ── */
.sys-section {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
}
.sys-title {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}
.sys-grid { display: flex; flex-direction: column; gap: 4px; }
.sys-row {
  display: flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
}
.sys-key {
  color: var(--muted);
  width: 150px;
  flex-shrink: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 9px;
}
.sys-val { color: var(--fg-bright); flex: 1; }
.sys-val.ok  { color: var(--ok); }
.sys-val.bad { color: var(--bad); }
.sys-val.amber { color: var(--amber); }
.sys-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.sys-pill {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--border);
  color: var(--subtle);
}
.sys-pill.active { border-color: var(--ok); color: var(--ok); }
.sys-sense-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
}
.sys-sense-row:last-child { border-bottom: none; }
.sys-sense-kind { color: var(--accent); width: 110px; flex-shrink: 0; font-size: 9px; }
.sys-sense-caps { color: var(--subtle); font-size: 8px; letter-spacing: 0.1em; }

/* ── Error / info banners ── */
.status-bad  { color: var(--bad); }
.status-ok   { color: var(--ok); }
.status-warn { color: var(--amber); }

/* ── Scrollbar global ── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); }
