/* g8r portal. Near-black green everywhere, bright greens only as accents. */

@font-face {
  font-family: "Plex Mono";
  src: url("fonts/IBMPlexMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("fonts/IBMPlexMono-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #050d03;
  --panel: #0a1807;
  --raised: #102310;
  --line: #1a3310;
  --line-strong: #2a4d1f;
  --text: #d8f0cc;
  --muted: #7d9a72;
  --faint: #4f6a47;
  --green: #8ef05a;
  --green-dim: #3fa34d;
  --mint: #7fe0a8;
  --khaki: #c8d45a;
  --acid: #e4f24a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  color: var(--text);
  font: 15px/1.45 "Plex Mono", ui-monospace, Menlo, monospace;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* MARK: Top bar */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top .brand { font-weight: 600; color: var(--green); letter-spacing: 0.02em; font-size: 17px; }
.top .title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .asof { flex: 1; color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.top .asof.stale { color: var(--khaki); }
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--green);
}
.icon-btn:active { background: var(--raised); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 0 0 calc(76px + var(--safe-bottom)); }

/* MARK: Tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; color: var(--muted); text-decoration: none; font-size: 12px;
  border-radius: 10px;
}
.tabs a svg { width: 22px; height: 22px; }
.tabs a[aria-current="page"] { color: var(--green); }

/* MARK: Overview */
.area { margin-top: 18px; }
.area h2 {
  margin: 0; padding: 0 16px 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--green-dim);
  display: flex; justify-content: space-between;
}
.area h2 span { color: var(--faint); letter-spacing: 0.04em; }
.rows { border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 4px 12px; align-items: center;
  width: 100%; padding: 12px 16px; min-height: 64px;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  text-align: left; text-decoration: none; color: inherit;
}
.row:active { background: var(--panel); }
.row .dot { grid-row: 1 / span 2; align-self: start; margin-top: 6px; }
.row .name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { grid-column: 2; color: var(--muted); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .right { grid-column: 3; grid-row: 1 / span 2; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row .by { font-size: 13px; color: var(--text); white-space: nowrap; }
.row .by small { display: block; color: var(--faint); font-size: 11px; }
.row.done .name, .row.done .sub { color: var(--faint); }
.row.done .name { text-decoration: line-through; text-decoration-color: var(--faint); }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.hollow { background: transparent !important; border: 2px solid currentColor; }

.badge {
  display: inline-block; font-size: 11px; line-height: 1; padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--line-strong); color: var(--muted); background: var(--panel); white-space: nowrap;
}
.badge.pending { border-style: dashed; color: var(--muted); opacity: 0.85; }
.badge.applied { color: var(--green-dim); border-color: var(--green-dim); }
.badge.rejected { color: var(--acid); border-color: var(--acid); }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty h1 { color: var(--text); font-size: 18px; margin: 0 0 8px; }

/* MARK: Detail */
.detail { padding: 16px; }
.detail h1 { margin: 0 0 6px; font-size: 22px; line-height: 1.25; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: 13px; color: var(--text);
}
.big { font-size: 26px; font-weight: 600; margin: 4px 0 2px; }
.big small { font-size: 14px; color: var(--muted); font-weight: 400; }
.card { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 12px; margin: 14px 0; }
.card h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--green-dim); }
.card p { margin: 0; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .legend { display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; margin-top: 4px; }
.links { list-style: none; margin: 0; padding: 0; }
.links li + li { border-top: 1px solid var(--line); }
.links a {
  display: flex; align-items: center; gap: 10px; padding: 10px 2px; color: var(--text); text-decoration: none;
}
.links a span.n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.links .none { color: var(--faint); padding: 4px 0; }
.mono-path { color: var(--muted); font-size: 13px; word-break: break-all; }
.notice { border: 1px solid var(--acid); color: var(--acid); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 13px; }
.notice.soft { border-color: var(--line-strong); color: var(--muted); border-style: dashed; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.btn {
  min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
  font-weight: 600; text-align: center;
}
.btn:active { background: var(--raised); }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--bg); }
.btn.primary:active { background: var(--green-dim); }
.btn.wide { grid-column: 1 / -1; }
.btn[disabled] { opacity: 0.5; }

/* MARK: Forms and sheets */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 30; background: rgba(2, 6, 1, 0.72);
  display: flex; align-items: flex-end;
}
.sheet {
  width: 100%; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-top: 1px solid var(--line-strong); border-radius: 16px 16px 0 0;
  padding: 8px 16px calc(16px + var(--safe-bottom));
}
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 4px auto 10px; }
.sheet header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sheet header h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; }
.sheet header button { background: none; border: 0; color: var(--muted); padding: 8px; min-height: 40px; }
.page-form { padding: 16px; }
.page-form h1 { margin: 0 0 12px; font-size: 20px; }

label.field { display: block; margin: 0 0 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; letter-spacing: 0.04em; }
input[type="text"], input[type="date"], input[type="number"], input:not([type]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font-size: 16px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-dim); outline-offset: 0; border-color: var(--green-dim); }
.two { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.form-error { color: var(--acid); font-size: 13px; min-height: 1.4em; margin: 4px 0 8px; }

.pick { list-style: none; margin: 0 0 12px; padding: 0; }
.pick h4 { margin: 14px 0 4px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--green-dim); }
.pick label {
  display: flex; align-items: center; gap: 12px; padding: 10px 4px; min-height: 52px;
  border-bottom: 1px solid var(--line);
}
.pick label .n { flex: 1; min-width: 0; }
.pick label .n small { display: block; color: var(--faint); font-size: 12px; }
.pick input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; flex: none;
  width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--line-strong); background: var(--panel); margin: 0;
  display: grid; place-items: center;
}
.pick input[type="checkbox"]:checked { background: var(--green); border-color: var(--green); }
.pick input[type="checkbox"]:checked::after {
  content: ""; width: 6px; height: 12px; border: solid var(--bg); border-width: 0 3px 3px 0; transform: translateY(-2px) rotate(45deg);
}
.pick label.off { opacity: 0.45; }
.sticky-foot { position: sticky; bottom: calc(-16px - var(--safe-bottom)); background: var(--bg); padding: 10px 0 4px; display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

/* MARK: Graph */
.graph-bar { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.graph-bar::-webkit-scrollbar { display: none; }
.graph-bar button {
  flex: none; padding: 6px 12px; min-height: 36px; border-radius: 999px; background: var(--panel);
  border: 1px solid var(--line-strong); color: var(--muted); font-size: 13px;
}
.graph-bar button[aria-pressed="true"] { color: var(--bg); background: var(--green); border-color: var(--green); }
.graph-view {
  position: fixed; left: 0; right: 0;
  top: var(--graph-top, 120px); bottom: calc(66px + var(--safe-bottom));
  overflow: hidden; touch-action: none; background: var(--bg);
}
.graph-view svg { width: 100%; height: 100%; display: block; }
.graph-view .gnode rect { fill: var(--panel); stroke: var(--line-strong); stroke-width: 1.2; }
.graph-view .gnode text { fill: var(--text); font-size: 13px; font-family: "Plex Mono", ui-monospace, monospace; }
.graph-view .gnode text.sub { fill: var(--muted); font-size: 10.5px; }
.graph-view .gnode.focus rect { stroke: var(--green); stroke-width: 2.4; fill: var(--raised); }
.graph-view .gnode.dim, .graph-view .gedge.dim { opacity: 0.18; }
.graph-view .gnode.done text { fill: var(--faint); }
.graph-view .gedge { fill: none; stroke: var(--green-dim); stroke-width: 1.4; }
.graph-view .gedge.hot { stroke: var(--green); stroke-width: 2.2; }
.graph-zoom { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 8px; }
.graph-card {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; padding: 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
}
.graph-card .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.graph-card .sub { color: var(--muted); font-size: 13px; grid-column: 1; }
.graph-card .btn { grid-column: 2; grid-row: 1 / span 2; min-height: 42px; }
.graph-hint { position: absolute; left: 16px; bottom: 14px; color: var(--faint); font-size: 12px; pointer-events: none; }

/* MARK: Pair */
.pair { padding: calc(48px + var(--safe-top)) 24px 24px; max-width: 460px; margin: 0 auto; }
.pair .logo { width: 72px; height: 72px; border-radius: 16px; display: block; margin-bottom: 20px; border: 1px solid var(--line); }
.pair h1 { font-size: 22px; margin: 0 0 8px; }
.pair p { color: var(--muted); margin: 0 0 20px; }
.pair input { text-transform: uppercase; letter-spacing: 0.3em; font-size: 22px; text-align: center; font-weight: 600; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(80px + var(--safe-bottom)); z-index: 40;
  background: var(--raised); border: 1px solid var(--green-dim); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 14px;
}
.toast.bad { border-color: var(--acid); color: var(--acid); }
.graph-view .gedge.repo { stroke: var(--faint); stroke-dasharray: 2 4; }
.graph-view .glabel { fill: var(--faint); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; font-family: "Plex Mono", ui-monospace, monospace; }
select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238ef05a' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
::placeholder { color: var(--faint); opacity: 1; }
