/* The terminal view (terminal-view.js, docs/TERMINAL.md §8): text on the console's own grounds, light and dark. Flat:
   hairlines, no card; full screen on a phone. The 16 colours are the terminal's own, picked per scheme so every one of
   them reads on its ground (gate/test/console-terminal-vt.test.ts checks each against --tm-bg, at least 4.5:1, except
   black on dark and white on light, which are the program's own choice of "the same as the ground"). */
:root {
  --tm-bg: var(--ink-0); --tm-fg: var(--text); --tm-cur: var(--text); --tm-sel: color-mix(in srgb, var(--sky) 34%, transparent);
  --tm-0: #4a525e; --tm-1: #ff6b6b; --tm-2: #4fd18b; --tm-3: #f2c94c; --tm-4: #6ea8fe; --tm-5: #d68afc; --tm-6: #4fd1d9; --tm-7: #c9ced6;
  --tm-8: #8a94a3; --tm-9: #ff8f8f; --tm-10: #7ee2a8; --tm-11: #ffe08a; --tm-12: #9cc3ff; --tm-13: #e5b0ff; --tm-14: #8ae6ec; --tm-15: #f3f4f6;
  /* the same 16 as a ground (a program's coloured bars): in dark, the same values */
  --tm-b0: var(--tm-0); --tm-b1: var(--tm-1); --tm-b2: var(--tm-2); --tm-b3: var(--tm-3); --tm-b4: var(--tm-4); --tm-b5: var(--tm-5); --tm-b6: var(--tm-6); --tm-b7: var(--tm-7);
  --tm-b8: var(--tm-8); --tm-b9: var(--tm-9); --tm-b10: var(--tm-10); --tm-b11: var(--tm-11); --tm-b12: var(--tm-12); --tm-b13: var(--tm-13); --tm-b14: var(--tm-14); --tm-b15: var(--tm-15);
}
:root[data-scheme="light"] {
  --tm-bg: var(--ink-2); --tm-fg: var(--text); --tm-cur: var(--text); --tm-sel: color-mix(in srgb, var(--sky) 22%, transparent);
  --tm-0: #1b1a17; --tm-1: #b3261e; --tm-2: #17703a; --tm-3: #7a5600; --tm-4: #1f5fbf; --tm-5: #9a2f97; --tm-6: #0b6b74; --tm-7: #5b5750;
  --tm-8: #66625a; --tm-9: #c2362b; --tm-10: #1b7a40; --tm-11: #725000; --tm-12: #2a64c4; --tm-13: #a33ba0; --tm-14: #0e6f78; --tm-15: #d9d4ca;
  /* in light, tints: black text (a program's usual choice on a coloured bar) reads on every one of them */
  --tm-b0: #1b1a17; --tm-b1: #f4b8b3; --tm-b2: #a9dfb9; --tm-b3: #f0d58a; --tm-b4: #b5cdf5; --tm-b5: #e8b8e6; --tm-b6: #9fdde2; --tm-b7: #d9d4ca;
  --tm-b8: #a8a39a; --tm-b9: #f7c6c1; --tm-b10: #bfe8cb; --tm-b11: #f6e2a8; --tm-b12: #c9daf8; --tm-b13: #efcdee; --tm-b14: #b9e8ec; --tm-b15: #f3f0ea;
}

.tm-scrim { position: fixed; inset: 0; z-index: var(--z-preview); background: var(--scrim); display: flex; animation: tm-in var(--dur-2) var(--ease-out); }
@keyframes tm-in { from { opacity: 0; } }
.tm { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; margin: 12px; overflow: hidden;
  background: var(--tm-bg); color: var(--tm-fg); border: 1px solid var(--line); border-radius: var(--content-radius); box-shadow: var(--elev-3); }
.tm:focus { outline: none; }

.tm-head { flex: none; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--line); font-size: 14px; min-width: 0; }
.tm-who { display: flex; align-items: baseline; gap: 8px; min-width: 0; white-space: nowrap; }
.tm-who b { font-weight: 600; }
.tm-sep { color: var(--text-3); }
.tm-name { color: var(--text-2); }
.tm-title { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 40vw; }
.tm-pill { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; color: var(--text-2); }
.tm-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.tm-pill[data-s="live"] i { background: var(--ok); }
.tm-pill[data-s="off"] i { background: var(--bad); border-radius: 1px; }
.tm-pill.bell { border-color: var(--warn); }
.tm-grow { flex: 1; }
.tm-size { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.tm-ib { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; background: none; border: 0; border-radius: var(--radius); color: var(--text-2); cursor: pointer; }
.tm-ib:hover, .tm-ib:focus-visible { color: var(--text); }
.tm-ib svg { width: 18px; height: 18px; }

.tm-bar { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.tm-bar[hidden] { display: none; }
.tm-bar-w { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }

.tm-view { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 6px 10px 2px; cursor: text; overscroll-behavior: contain; }
.tm-rows { position: relative; font-family: var(--mono); font-size: 13px; line-height: 1.3; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.tm-l { white-space: pre; height: 1.3em; overflow: hidden; }
.tm-rows ::selection { background: var(--tm-sel); }
.tm-rows .b { font-weight: 700; }
.tm-rows .d { opacity: .62; }
.tm-rows .i { font-style: italic; }
.tm-rows .u { text-decoration-line: underline; }
.tm-rows .s { text-decoration-line: line-through; }
.tm-rows .u.s { text-decoration-line: underline line-through; }
.tm-rows .tm-link { text-decoration-line: underline; text-decoration-style: dotted; cursor: pointer; }
.tm-cur { box-shadow: inset 0 0 0 9em var(--tm-cur); color: var(--tm-bg) !important; }
.tm-cur.off { box-shadow: inset 0 0 0 1px var(--tm-cur); color: inherit !important; }
.tm-probe { position: absolute; visibility: hidden; white-space: pre; top: 0; left: 0; }
.tm-input { position: absolute; top: 0; left: 0; width: 2px; padding: 0; margin: 0; border: 0; opacity: 0; resize: none; overflow: hidden; caret-color: transparent;
  font-size: 16px; /* never under 16 px, or iOS zooms in */ background: transparent; color: transparent; pointer-events: none; white-space: nowrap; }
.tm-new { position: sticky; float: right; bottom: 8px; margin-top: -32px; height: 28px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--pop-bg); color: var(--text); font: inherit; font-size: 12px; cursor: pointer; box-shadow: var(--elev-1); }
.tm-new[hidden] { display: none; }

.tm-keys { display: none; flex: none; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tm-keys::-webkit-scrollbar { display: none; }
.tm-keys button { flex: none; min-width: 40px; height: 36px; padding: 0 10px; font-family: var(--mono); font-size: 13px; background: none; border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--tm-fg); cursor: pointer; touch-action: manipulation; }
.tm-keys button[aria-pressed="true"] { border-color: var(--tm-fg); box-shadow: inset 0 0 0 1px var(--tm-fg); }
.tm-foot { flex: none; padding: 6px 14px; border-top: 1px solid var(--line); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 640px), (pointer: coarse) { .tm-keys { display: flex; } }
@media (max-width: 640px) {
  .tm { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
  .tm-head { height: 46px; padding-left: 12px; gap: 8px; }
  .tm-size { display: none; }
  .tm-title { max-width: 30vw; }
  .tm-view { padding: 4px 6px 0; }
  .tm-rows { font-size: 12px; }
  .tm-foot { display: none; }
}

/* The apps row's terminal tile (apps-row.js): its last lines as text, on the terminal's own ground. */
.ap-thumb.ap-tt { align-items: flex-end; justify-content: flex-start; background: var(--tm-bg); }
.ap-tt .tm-th { width: 100%; padding: 6px 8px; font-family: var(--mono); font-size: 8.5px; line-height: 1.3; color: var(--tm-fg); text-align: left; overflow: hidden; }
.ap-tt .tm-th .tm-l { height: 1.3em; }
.ap-tt .tm-th .b { font-weight: 700; } .ap-tt .tm-th .d { opacity: .62; }
/* Locked (no fresh passkey, docs/TERMINAL.md §2): a padlock and two words on the same ground; a click confirms. */
.ap-thumb.ap-tt.ap-lock { flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-2); font-size: 12px; }
.ap-lock svg { width: 18px; height: 18px; }
.ap-lock:hover, .ap-lock:focus-visible { color: var(--text); }
.ap-lock[aria-busy="true"] { cursor: progress; opacity: .7; }
.ap-kind-note { margin: 0; font-size: 12px; }
