/* Logbuch web app: the bar, the start page and dialogs. The viewer styles itself (shadow DOM). */
:root {
  --bg: #0e1116; --panel: #161b22; --panel2: #1c2230; --line: #2a3140; --fg: #e6edf3; --muted: #8b96a8;
  --accent: #6cb6ff; --accent-strong: #2f6fdb; --danger: #ff7b72; --ok: #3fb950; --warn: #d29922;
  --danger-bg: #3d1a1a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-mode="light"] {
  --bg: #ffffff; --panel: #f6f8fa; --panel2: #eef1f5; --line: #d0d7de; --fg: #1f2328; --muted: #59636e;
  --accent: #0969da; --accent-strong: #0969da; --danger: #cf222e; --ok: #1a7f37; --warn: #9a6700;
  --danger-bg: #ffebe9;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { display: flex; flex-direction: column; overflow: hidden; font-size: 14px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---- the bar: only what fits the current state; it wraps instead of clipping on narrow screens ---- */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 44px; flex: none; min-width: 0; }
.bar button, .bar .follow { background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; text-decoration: none; color: var(--fg); white-space: nowrap; }
.bar button:hover { background: var(--panel2); }
.bar .brand { font-weight: 700; border-color: transparent; }
.bar .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 0 1 auto; max-width: 40vw; margin-left: 4px; }
.bar .status { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.bar .grow { flex: 1 1 0; min-width: 0; }
.bar .follow { display: inline-flex; align-items: center; gap: 5px; }
#configBtn, #helpBtn { border-color: transparent; color: var(--muted); }
#configBtn [aria-hidden], #helpBtn [aria-hidden] { font-size: 16px; line-height: 1; }
#configBtn:hover, #helpBtn:hover { color: var(--fg); }
/* with a log open the bar keeps to icons for Settings and Help */
body.viewing #configBtn .lbl, body.viewing #helpBtn .lbl { display: none; }

/* the app's part of a live stream: Stop / Reconnect and recording (state, Pause and Export are the viewer's) */
.live { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.live .rec { color: var(--danger); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.live button { padding: 4px 9px; }

/* narrow: icons instead of words, nothing clipped (the bar wraps; the status stays readable for screen readers) */
@media (max-width: 760px) { .bar .title { max-width: 34vw; } .live .lbl { display: none; } .live button { padding: 4px 8px; } }
@media (max-width: 520px) { .bar { gap: 4px; padding: 6px 8px; } .brand .lbl, #shareBtn .lbl, #configBtn .lbl, #helpBtn .lbl { display: none; } .bar button { padding: 5px 8px; } .bar .status { flex-basis: 100%; order: 10; } }

main { flex: 1; min-height: 0; position: relative; display: flex; }
logbuch-viewer { flex: 1; min-width: 0; height: 100%; }

/* a stream without lines yet: say what is going on instead of showing an empty table */
.waiting { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; padding: 16px; }
.waiting .card-box { pointer-events: auto; max-width: 520px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.waiting p { margin: 0; line-height: 1.5; overflow-wrap: anywhere; }
.waiting .acts { margin-top: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.waiting button { border: 1px solid var(--line); background: transparent; border-radius: 6px; padding: 5px 12px; cursor: pointer; }
.waiting .primary-btn { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

/* ---- start page: one primary action, three quieter ways, then recent logs and examples ---- */
.start { flex: 1; overflow: auto; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.start > * { width: 100%; max-width: 720px; }
.notes { display: flex; flex-direction: column; gap: 10px; }
.notes:empty { display: none; }
.back { align-self: flex-start; background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back:hover { background: var(--panel2); }
.badge { color: var(--ok); font-weight: 600; margin-left: 6px; }
.note { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; border: 1px solid var(--accent); border-radius: 10px; padding: 10px 14px; background: color-mix(in srgb, var(--accent) 8%, var(--bg)); line-height: 1.5; }
.note .acts { white-space: nowrap; }
.intro { text-align: center; }
.intro h1 { margin: 0 0 8px; font-size: 28px; }
.intro p { margin: 0; color: var(--muted); line-height: 1.5; }
.card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; }
.card:hover, .card:focus-visible { border-color: var(--accent); }
.card .ic { font-size: 22px; }
.card span:last-child { color: var(--muted); font-size: 13px; line-height: 1.4; }
.card.primary { align-items: center; text-align: center; padding: 28px 20px; border: 2px dashed color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.card.primary .ic { font-size: 30px; }
.card.primary b { font-size: 18px; color: var(--accent); }
body.dropping .card.primary { border-style: solid; border-color: var(--accent); }
.ways { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 960px; }
.way { display: inline-flex; align-items: baseline; gap: 6px; background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.way:hover, .way:focus-visible { border-color: var(--accent); background: var(--panel); }
.way span:last-child { color: var(--muted); font-size: 12px; }
.way b { font-weight: 600; }
.recent h2 { font-size: 15px; margin: 0 0 8px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.recent h2 .link { font-size: 13px; color: var(--muted); }
.recent h2 .link:hover { color: var(--danger); }
.recent ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.recent li { display: flex; border-top: 1px solid var(--line); }
.recent li:first-child { border-top: 0; }
.recent .rec { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; padding: 9px 12px; background: transparent; border: 0; text-align: left; cursor: pointer; }
.recent .rec:hover, .recent .rec:focus-visible { background: var(--panel2); }
.recent .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; min-width: 0; }
.recent .meta { color: var(--muted); font-size: 12px; white-space: nowrap; margin-left: auto; }
.recent .x { background: transparent; border: 0; color: var(--muted); padding: 0 12px; cursor: pointer; min-width: 36px; }
.recent .x:hover { color: var(--danger); }
@media (max-width: 520px) { .way span:last-child { display: none; } .recent .rec { flex-wrap: wrap; } .recent .meta { margin-left: 22px; flex-basis: 100%; } .start { padding: 24px 16px; } }
.examples { color: var(--muted); margin: 0; text-align: center; line-height: 1.6; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: inherit; font-weight: normal; }

/* ---- menus ---- */
.menu { position: fixed; z-index: 20; min-width: 240px; max-width: min(320px, calc(100vw - 16px)); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.menu button { display: flex; width: 100%; gap: 12px; justify-content: space-between; align-items: baseline; text-align: left; padding: 6px 10px; background: transparent; border: 0; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.menu button:hover, .menu button:focus-visible { background: var(--accent-strong); color: #fff; outline: none; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover, .menu button.danger:focus-visible { background: var(--danger); color: var(--bg); }
.menu .hint { color: var(--muted); font-size: 12px; }
.menu button:hover .hint, .menu button:focus-visible .hint { color: inherit; }
.menu .sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ---- app messages: a live region at the bottom, above the viewer's status bar ---- */
.toast { position: fixed; left: 16px; right: 16px; bottom: 40px; margin: 0 auto; width: fit-content; z-index: 25; display: flex; align-items: baseline; gap: 10px; max-width: min(680px, calc(100vw - 32px)); background: var(--panel2); color: var(--fg); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 9px 10px 9px 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .35); line-height: 1.45; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.on { opacity: 1; pointer-events: auto; }
.toast.error { border-left-color: var(--danger); }
.toast { flex-wrap: wrap; }
#msgText { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.toast .acts { display: inline-flex; gap: 12px; white-space: nowrap; }
.toast .acts:empty { display: none; }
.toast .x { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; }
.toast .x:hover { color: var(--fg); }

/* ---- dialogs: title bar with ✕, the message of the dialog above its fields, a divided footer ---- */
dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(720px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog form { display: flex; flex-direction: column; }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.dlg-head .x { margin-left: auto; background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 2px 8px; border-radius: 5px; font-size: 15px; }
.dlg-head .x:hover { background: var(--panel2); color: var(--fg); }
#dlgBody { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
dialog h2 { margin: 0; font-size: 16px; }
dialog p { margin: 0; line-height: 1.5; }
dialog label { color: var(--muted); line-height: 1.45; }
dialog input, dialog textarea { width: 100%; font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); color: var(--fg); border: 1px solid var(--muted); border-radius: 6px; padding: 7px 9px; }
.dlg-msg { border-left: 4px solid var(--accent); background: var(--panel2); padding: 8px 12px; border-radius: 6px; }
.dlg-msg.error { border-left-color: var(--danger); background: var(--danger-bg); }
.howto { margin: 0; padding-left: 18px; line-height: 1.55; display: flex; flex-direction: column; gap: 6px; }
#dlgFoot { display: flex; flex-direction: row-reverse; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
#dlgFoot button { padding: 6px 14px; border-radius: 6px; border: 1px solid var(--line); background: transparent; cursor: pointer; }
#dlgFoot button.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
#dlgFoot button.primary.danger { background: var(--danger); border-color: var(--danger); color: var(--bg); }

.dropzone { display: none; position: fixed; inset: 8px; z-index: 30; border: 2px dashed var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--bg) 80%, transparent); align-items: center; justify-content: center; font-size: 20px; pointer-events: none; }
body.dropping .dropzone { display: flex; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
