/* DataForge Twin — mobile-first, read-only consumption UI (dark, matches DataForge's feel) */
:root {
  --bg: #161b26; --panel: #1f2634; --panel2: #242c3d; --border: #303a4e;
  --text: #dde3ee; --muted: #8b97ab; --accent: #6ea8fe; --good: #3fb27f; --warn: #f0b64e;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* top bar */
#topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border-bottom: 1px solid var(--border); padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top)); }
#topbar .brand { font-weight: 700; white-space: nowrap; }
#topbar .brand em { color: var(--accent); font-style: normal; }
#topbar .ro { font: 600 10px/1 var(--mono); letter-spacing: .06em; color: var(--warn);
  border: 1px solid #5a4720; background: #3d2f14; border-radius: 99px; padding: 3px 8px; }
#topbar .spacer { flex: 1; }
#freshness { font: 11px var(--mono); color: var(--muted); white-space: nowrap; }
#logout-btn { background: none; border: none; color: var(--muted); font-size: 12px; }

/* search */
#searchwrap { padding: 12px 14px 0; max-width: 900px; margin: 0 auto; }
#search { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; font-size: 15px; }
#search::placeholder { color: var(--muted); }
#search-results { max-width: 900px; margin: 8px auto 0; padding: 0 14px; }
.hit { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 8px; color: var(--text); }
.hit .k { font: 600 10px var(--mono); color: var(--accent); text-transform: uppercase; letter-spacing: .05em; margin-right: 8px; }
.hit .sn { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* main */
main { max-width: 900px; margin: 0 auto; padding: 14px 14px calc(30px + env(safe-area-inset-bottom)); }
.empty { color: var(--muted); text-align: center; padding: 46px 20px; }

/* project cards (home) */
.proj { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px; color: var(--text); }
.proj:active { background: var(--panel2); }
.proj b { font-size: 16px; }
.proj .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; font-family: var(--mono); }

/* project page */
.crumb { font-size: 13px; margin-bottom: 10px; display: inline-block; }
h1.pname { font-size: 21px; margin: 2px 0 10px; letter-spacing: -.01em; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs button { background: none; border: none; color: var(--muted); padding: 9px 12px; font-size: 14px;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* markdown */
.md { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
  overflow-wrap: break-word; }
.md h1 { font-size: 19px; margin: 4px 0 10px; } .md h2 { font-size: 16px; margin: 16px 0 6px; }
.md h3 { font-size: 14.5px; margin: 14px 0 4px; }
.md ul, .md ol { padding-left: 20px; } .md li { margin: 3px 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md hr { border: none; border-top: 1px solid var(--border); }
.md table { border-collapse: collapse; width: 100%; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; }

/* artifacts */
.art { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px; margin-bottom: 8px; color: var(--text); width: 100%; text-align: left; }
.art .kind { font: 600 10px var(--mono); color: var(--accent); text-transform: uppercase; min-width: 34px; }
.art .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.art .sz { font: 11px var(--mono); color: var(--muted); }

/* datasets */
.ds-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px; margin-bottom: 8px; width: 100%; text-align: left; color: var(--text); }
.ds-row .nm { flex: 1; font-size: 14px; } .ds-row .rw { font: 11px var(--mono); color: var(--muted); }
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
table.data { border-collapse: collapse; font-size: 13px; min-width: 100%; font-variant-numeric: tabular-nums; }
.data th { position: sticky; top: 0; background: var(--panel2); font-family: var(--mono); font-size: 11px;
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); cursor: pointer; white-space: nowrap; }
.data th.sorted { color: var(--accent); }
.data td { padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 300px;
  overflow: hidden; text-overflow: ellipsis; }
.ds-controls { display: flex; gap: 8px; margin: 0 0 10px; }
.ds-controls input { flex: 1; background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 12px 0 2px;
  font: 12px var(--mono); color: var(--muted); }
.pager button { background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 14px; }
.pager button:disabled { opacity: .35; }

/* artifact viewer overlay */
#viewer { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: none; flex-direction: column; }
#viewer.open { display: flex; }
#viewer .vhead { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top)); background: var(--panel); border-bottom: 1px solid var(--border); }
#viewer .vhead .nm { flex: 1; font-size: 13px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#viewer .vhead button { background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 12px; }
#viewer .vbody { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
#viewer iframe { width: 100%; height: 100%; border: none; background: #fff; }
#viewer img { max-width: 100%; display: block; margin: 0 auto; padding: 14px; }
#viewer .md { margin: 14px; }

/* login */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 26px 24px; }
.login-box h1 { font-size: 19px; margin: 0 0 4px; } .login-box h1 em { color: var(--accent); font-style: normal; }
.login-box p { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.login-box input { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 11px 13px; font-size: 15px; margin-bottom: 12px; }
.login-box button { width: 100%; background: var(--accent); color: #0d1420; font-weight: 700; border: none;
  border-radius: 9px; padding: 11px; font-size: 15px; }
.login-err { color: #ff7d7d; font-size: 13px; min-height: 18px; margin-top: 8px; }
