/* troq: plain and textual. Colours as tokens, redefined for dark mode. */
:root {
  --bg: #fff; --text: #1a1a1a; --muted: #6b6b6b; --line: #e3e3e3; --soft: #f5f5f3;
  --accent: #0b6e4f; --accent-text: #fff; --hover-bg: #e8f1ec; --danger: #b3261e; --warn-bg: #fff4d6; --warn-text: #5c4500;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414; --text: #e8e8e8; --muted: #9a9a9a; --line: #2e2e2e; --soft: #1e1e1e;
    --accent: #5cc8a0; --accent-text: #0d1f18; --hover-bg: #23302a; --danger: #f2827a; --warn-bg: #3a3014; --warn-text: #f0d68a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
#app { max-width: 720px; margin: 0 auto; padding: 0 16px 48px; padding-top: env(safe-area-inset-top); }
.boot { padding: 40px 0; color: var(--muted); }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 18px 0 6px; line-height: 1.3; overflow-wrap: anywhere; }
h2 { font-size: 15px; margin: 26px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 8px 0; }
input, textarea, select, button { font: inherit; color: inherit; }

/* Top line: troq on the left, a few text links on the right. */
.top { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; padding: 14px 0 10px; border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; font-size: 20px; color: var(--text); text-decoration: none; margin-right: auto; }
.top a, .top button.link { font-size: 15px; }

button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  border-radius: 6px; padding: 7px 14px; cursor: pointer; text-decoration: none; font-size: 15px;
}
.btn.plain { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }

/* Lists of tickets and groups */
ul.list { list-style: none; margin: 0; padding: 0; }
ul.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
/* A ticket or group row is one link: the whole row is clickable and lights up on hover. */
ul.list li:has(> a.item) { padding: 0; }
ul.list a.item { display: block; padding: 10px 10px; margin: 0 -10px; color: var(--text); text-decoration: none; border-radius: 6px; cursor: pointer; }
ul.list a.item:hover, ul.list a.item:focus-visible { background: var(--hover-bg); outline: none; }
ul.list a.item:hover .title { text-decoration: underline; }
ul.list a.item .title { display: block; font-weight: 600; overflow-wrap: anywhere; }
ul.list a.item .meta { display: block; }
.meta { color: var(--muted); font-size: 14px; }
.new { color: var(--accent); font-weight: 600; }
.empty { color: var(--muted); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; margin: 16px 0; max-width: 520px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.form input:not([type=radio]):not([type=checkbox]), .form textarea, .form select {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: var(--bg); font-size: 16px; color: var(--text);
}
.form input:focus, .form textarea:focus, .form select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form textarea { min-height: 90px; resize: vertical; }
.form label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 16px; }
.hint { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); }
.terms { color: var(--muted); font-size: 13px; line-height: 1.45; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 20px; max-width: 520px; }

/* A ticket */
.status { font-weight: 600; }
.body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 12px 0; }
.panel { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 12px 0; background: var(--soft); }
.panel .form { margin: 8px 0 0; }
.notice { background: var(--warn-bg); color: var(--warn-text); border-radius: 6px; padding: 8px 12px; margin: 12px 0; font-size: 15px; }
ol.history { list-style: none; margin: 0; padding: 0; }
ol.history li { padding: 6px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
ol.history .when { color: var(--muted); font-size: 13px; margin-right: 8px; white-space: nowrap; }
ol.history .sys { color: var(--muted); font-style: italic; }
ol.history .text { white-space: pre-wrap; }
ol.history .pending { opacity: .6; }
.link-box { font-family: ui-monospace, monospace; font-size: 13px; background: var(--bg); border: 1px solid var(--line); padding: 8px; border-radius: 6px; overflow-wrap: anywhere; user-select: all; }

.offline { background: var(--warn-bg); color: var(--warn-text); font-size: 14px; padding: 6px 10px; margin-top: 8px; border-radius: 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #323232; color: #fff; padding: 8px 16px; border-radius: 6px; font-size: 14px; z-index: 30; max-width: 90%; }

/* Desktop: the list in a sidebar, the opened ticket or group beside it (like WhatsApp on a desktop). */
.split { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; height: 100dvh; }
.side { overflow-y: auto; padding: 0 16px 32px; border-right: 1px solid var(--line); background: var(--soft); }
.side .top { position: sticky; top: 0; background: var(--soft); z-index: 2; }
.pane { overflow-y: auto; padding: 0 36px 48px; }
.pane > * { max-width: 760px; }
ul.list li.current a.item { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
a.plain-link { color: var(--text); text-decoration: none; }
a.plain-link:hover { text-decoration: underline; }
@media (min-width: 900px) {
  #app:has(.split) { max-width: none; padding: 0; }
}
