:root {
  --bg: #ffffff;
  --text: #1d2330;
  --muted: #6b7484;
  --line: #e3e6ec;
  --soft: #f5f6f8;
  --accent: #2459d6;
  --accent-text: #ffffff;
  --ok: #16834a;
  --warn: #a26700;
  --bad: #c2312d;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181e;
    --text: #e6e9ef;
    --muted: #98a1b0;
    --line: #2c323d;
    --soft: #1d2129;
    --accent: #6a96ff;
    --accent-text: #0b1020;
    --ok: #53c98a;
    --warn: #f0b44c;
    --bad: #ff7b74;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
}
input, select, button, textarea { font: inherit; color: inherit; }
input, select {
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: -1px; }
button {
  padding: 5px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--soft); cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
button.quiet { background: none; }

/* top bar: one row */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--line); flex: none;
}
.topbar h1 { font-size: 15px; font-weight: 700; margin: 0 4px 0 0; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 600; color: var(--warn); border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; white-space: nowrap; }
.topbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.topbar input { width: 150px; }
.topbar select { max-width: 200px; }
.state { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); min-width: 0; flex: 1; }
.state span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }

/* two panes */
.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.pane { display: flex; flex-direction: column; min-height: 0; padding: 16px 20px; }
.pane + .pane { border-left: 1px solid var(--line); }
.pane-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pane-head h2 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 auto 0 0; }
textarea.xml {
  flex: 1; min-height: 0; width: 100%; resize: none; padding: 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--soft); font-family: var(--mono); font-size: 12px; line-height: 1.5; white-space: pre; tab-size: 2;
}
.send-row { display: flex; align-items: flex-start; gap: 12px; margin-top: 10px; min-height: 34px; }
.result { font-size: 13px; padding-top: 6px; min-width: 0; flex: 1; }
.result .ok { color: var(--ok); font-weight: 600; }
.result .bad { color: var(--bad); font-weight: 600; }
.result .warn { color: var(--warn); font-weight: 600; }
.result details { margin-top: 4px; }
.result summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.issues { margin: 6px 0 0; padding: 0; list-style: none; max-height: 140px; overflow: auto; font-size: 12px; }
.issues li { padding: 2px 0; }
.issues .ln { font-family: var(--mono); color: var(--muted); display: inline-block; min-width: 72px; margin-right: 8px; }

/* received list */
.list { flex: 1; min-height: 0; overflow: auto; margin: 0 -8px; }
/* Vertical line of the timeline: runs through the centres of the direction marks. */
.timeline { background: linear-gradient(var(--line), var(--line)) no-repeat 92px 18px / 2px calc(100% - 36px); }
.row { display: grid; grid-template-columns: 64px 22px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.row:hover { background: var(--soft); }
.row .time { font-family: var(--mono); font-size: 12px; color: var(--muted); }
/* Direction mark: filled with an up arrow for what was sent, outlined with a down arrow for what came back. */
.row .mark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; line-height: 1; border: 2px solid var(--c); }
.row.out .mark { background: var(--c); color: #fff; }
.row.in .mark { background: var(--bg); color: var(--c); }
.row .word { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .word.ok { color: var(--ok); } .row .word.bad { color: var(--bad); } .row .word.warn { color: var(--warn); }
.row .meta { font-size: 11px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.row.out .word { color: var(--muted); }
.expanded { margin: 0 8px 10px 114px; }
.expanded pre {
  margin: 0 0 6px; max-height: 300px; overflow: auto; padding: 10px; background: var(--soft); border-radius: 6px;
  font-family: var(--mono); font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.empty { color: var(--muted); font-size: 13px; padding: 8px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* "More" drawer */
dialog.drawer {
  margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: 440px; max-width: 100vw; border: 0; border-left: 1px solid var(--line);
  padding: 18px 22px; background: var(--bg); color: var(--text); overflow: auto;
}
dialog.drawer::backdrop { background: rgb(0 0 0 / .18); }
.drawer h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 0 8px; }
.drawer .head { display: flex; justify-content: space-between; align-items: center; }
.drawer .head h2 { margin: 0; font-size: 15px; }
.drawer label { display: block; font-size: 12px; color: var(--muted); margin-top: 8px; }
.drawer label input, .drawer label select { display: block; width: 100%; margin-top: 3px; }
.drawer .check { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.drawer .check input { width: auto; margin: 0; }
.drawer .buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.drawer .two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.drawer .note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: var(--text); color: var(--bg); padding: 7px 14px; border-radius: 6px; font-size: 13px;
}

/* "To send": short form */
#send-pane { overflow: hidden; }
.form-scroll { flex: none; max-height: 62vh; overflow: auto; margin: 0 -4px; padding: 0 4px; }
.form { display: flex; flex-direction: column; gap: 14px; max-width: 620px; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field input, .field select { font-size: 17px; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.field.small input, .field.small select { font-size: 14px; padding: 6px 9px; }
.more-fields summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.ids { margin-top: 10px; font-size: 12px; color: var(--muted); }
.ids .mono { font-family: var(--mono); }
p.lead { font-size: 16px; color: var(--muted); margin: 8px 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: none; padding: 6px 16px; }
.seg button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
button.big { font-size: 16px; padding: 10px 34px; border-radius: 8px; }
.send-row { align-items: center; margin-top: 18px; }
.result { font-size: 15px; padding-top: 0; }
.xml-toggle { margin-top: 12px; font-size: 13px; }
pre.xml-preview {
  flex: 1; min-height: 0; overflow: auto; margin: 8px 0 0; padding: 10px; background: var(--soft); border-radius: 8px;
  font-family: var(--mono); font-size: 11px; white-space: pre;
}
/* "Received": plain details */
.row.open { background: var(--soft); }
.expanded dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 4px 0 8px; font-size: 13px; }
.expanded dl.kv dt { color: var(--muted); }
.expanded dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.expanded dl.kv dd.tech { font-family: var(--mono); font-size: 11px; color: var(--muted); }
textarea.xml.adv { flex: none; height: 220px; margin-top: 8px; }
