/* 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;
  --st-new: #c2570c; --st-open: #18803d; --st-finished: #1d63c9; --st-wontdo: #b3261e; --st-closed: #18803d; --st-cancelled: #8a8a8a;
  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;
    --st-new: #f59a4a; --st-open: #4cc76a; --st-finished: #6fa3ff; --st-wontdo: #f2827a; --st-closed: #4cc76a; --st-cancelled: #8f8f8f;
    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; }
details.ended { margin: 26px 0 6px; }
details.ended > summary { font-size: 15px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; padding: 4px 0; }
details.ended[open] > summary { margin-bottom: 6px; }
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 { align-items: center; }
.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; }
.row.group-new { margin: 12px 0 4px; }
.btn.small { padding: 4px 10px; font-size: 14px; display: inline-flex; align-items: center; gap: 2px; }
.icon { width: 18px; height: 18px; fill: currentColor; }
/* Ticket state icons (Lucide strokes). */
.st { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.st-new, .st-invite { color: var(--st-new); } .st-open { color: var(--st-open); } .st-finished { color: var(--st-finished); }
.st-wont_do { color: var(--st-wontdo); } .st-closed { color: var(--st-closed); } .st-cancelled { color: var(--st-cancelled); }
ul.list a.item.with-st { display: flex; gap: 10px; align-items: flex-start; }
ul.list a.item.with-st .st { margin-top: 2px; }
ul.list a.item.with-st > span { min-width: 0; flex: 1; }
.tid { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.mine-star { color: var(--st-new); fill: currentColor; }
ul.list a.item .tid { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.mine-star { margin-top: 2px; }
h1.with-star { display: flex; gap: 10px; align-items: flex-start; } h1.with-star > span { flex: 1; min-width: 0; }
h1.with-star .tid { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.mine-star { width: 22px; height: 22px; margin-top: 4px; }
.status-line { display: inline-flex; align-items: center; gap: 6px; }
.status-line .st { width: 16px; height: 16px; }

/* The New menu */
.menu { position: relative; }
.menu-list {
  position: absolute; left: 0; top: calc(100% + 4px); z-index: 10; min-width: 150px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, .12); padding: 4px 0;
}
.menu-list.right { left: auto; right: 0; }
.menu-list button { display: block; width: 100%; text-align: left; padding: 8px 14px; color: var(--text); background: none; border: 0; cursor: pointer; font-size: 15px; }
.menu-list button:hover, .menu-list button:focus-visible { background: var(--hover-bg); outline: none; }
button.pane-btn { background: none; border: 0; cursor: pointer; font-weight: 700; }

/* The bar on top of an opened screen */
.pane-bar {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 4px 0; position: sticky; top: 0; z-index: 3;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.pane-title { flex: 1; min-width: 0; font-weight: 600; color: var(--muted); }
.pane-title > * { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-title.named span { color: var(--text); font-size: 18px; }
.pane-title small { font-weight: 400; font-size: 13px; color: var(--muted); }
.pane-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; flex: none;
  color: var(--text); text-decoration: none; font-size: 20px; line-height: 1;
}
.pane-btn:hover, .pane-btn:focus-visible { background: var(--hover-bg); outline: none; }

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.chase { list-style: none; margin: 14px 0 0; padding: 0; display: flex; gap: 8px; }
ul.chase a, ul.chase .none { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--text); text-decoration: none; font-variant-numeric: tabular-nums; }
ul.chase a:hover, ul.chase a:focus-visible { background: var(--hover-bg); outline: none; }
ul.chase li.current a { border-color: var(--accent); }
ul.chase .none { color: var(--muted); opacity: .6; }
ul.chase b { font-weight: 600; }
ul.chase .st { width: 18px; height: 18px; }
.chase-mine { color: var(--st-new); } .chase-review { color: var(--st-finished); } .chase-waiting { color: var(--st-open); }
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; }
.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; }
.intro { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
.intro p { margin: 0 0 6px; } .intro ul { margin: 0 0 10px; padding-left: 20px; } .intro li { margin: 4px 0; }
.ticket-links { font-size: 13px; color: var(--muted); margin: 8px 0 18px; }
.ticket-links button.link, .ticket-links a { font-size: 13px; color: var(--muted); }
.ticket-links button.link:hover, .ticket-links a:hover { color: var(--accent); }
.ticket-links button.link.danger { color: var(--danger); }
ol.history { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
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; }
ol.history a.thumb { display: block; margin-top: 6px; }
ol.history a.thumb img { max-width: min(240px, 100%); max-height: 180px; border: 1px solid var(--line); border-radius: 6px; display: block; }
.form label.btn.file-btn { display: inline-block; position: relative; cursor: pointer; font-size: 15px; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.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; }
.pane > .pane-bar { max-width: none; }
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; }
}

/* Work done through a connected app, e.g. Claude */
ol.history .via { color: var(--accent); font-size: 12px; font-weight: normal; border: 1px solid currentColor; border-radius: 8px; padding: 0 5px; margin-left: 4px; }
.consent { max-width: 520px; margin: 40px auto; }
ol.steps { padding-left: 20px; }
ol.steps li { margin: 6px 0; }
ol.steps code { overflow-wrap: anywhere; }
.add-claude { display: block; font-size: 14px; margin: 8px 0 4px; }
