:root {
    --bg: #2a0607;
    --bg-bar: #360909;
    --bg-gutter: #200505;
    --line: #4d1213;
    --text: #eadcd6;
    --dim: #a07e79;
    --faint: #6e4c49;
    --accent: #f0b35a;
    --accent-ink: #2a0607;

    --error: #ff6f66;
    --warn: #f2b84b;
    --info: #6cb8ea;
    --debug: #9d98ad;

    --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-padding-top: 130px;
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--ui);
    min-height: 100vh;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- верхняя панель ---------- */

.bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-bar);
    border-bottom: 1px solid var(--line);
    padding: 10px 16px 10px;
    display: grid;
    gap: 10px;
}

.bar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.title { min-width: 0; }

.title h1 {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: .01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.meta {
    margin-top: 2px;
    font-size: 12px;
    color: var(--dim);
}

.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 11px;
    font-size: 13px;
    color: var(--text);
    transition: background .12s, border-color .12s;
}
.btn:hover { background: rgba(255, 255, 255, .05); border-color: var(--faint); }
.btn[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}
.btn.small { padding: 3px 9px; font-size: 12px; }

.icon {
    width: 26px;
    height: 26px;
    display: inline-grid;
    place-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--dim);
    font-size: 15px;
    line-height: 1;
}
.icon:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

.bar-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    flex-wrap: wrap;
}

.search {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 340px;
    max-width: 640px;
    background: var(--bg-gutter);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 3px 6px 3px 10px;
}
.search:focus-within { border-color: var(--accent); }

.search input {
    flex: 1;
    min-width: 0;
    background: none;
    border: 0;
    outline: 0;
    font-size: 14px;
    padding: 4px 0;
}
.search input::placeholder { color: var(--faint); }

.search-count {
    font-size: 12px;
    color: var(--dim);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.levels { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 11px 3px 9px;
    font-size: 13px;
    color: var(--text);
}
.chip::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--c);
}
.chip b { font-weight: 500; color: var(--dim); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="false"] { opacity: .45; }
.chip[aria-pressed="false"]::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); }
.chip:hover { border-color: var(--faint); }

/* ---------- сам лог ---------- */

.log {
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.55;
    padding: 6px 0 40px;
    overflow-x: auto;
}

.line {
    display: flex;
    min-width: max-content;
    border-left: 3px solid transparent;
}
.line[hidden] { display: none; }

.num {
    flex: 0 0 auto;
    min-width: 64px;
    padding: 0 12px 0 8px;
    text-align: right;
    color: var(--faint);
    background: var(--bg-gutter);
    user-select: none;
    cursor: pointer;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    position: sticky;
    left: 0;
}
.num:hover { color: var(--accent); }

.txt {
    padding: 0 16px 0 14px;
    white-space: pre;
    tab-size: 4;
}

.ts { color: var(--dim); }

.lv-error { border-left-color: var(--error); background: rgba(255, 90, 80, .10); }
.lv-warn  { border-left-color: var(--warn);  background: rgba(242, 184, 75, .07); }
.lv-info  { border-left-color: transparent; }
.lv-debug { border-left-color: transparent; color: var(--debug); }
.lv-debug .ts { color: var(--faint); }
.lv-error .txt { color: #ffd9d4; }

.line:hover { background-color: rgba(255, 255, 255, .04); }

.line.target {
    background: rgba(240, 179, 90, .16);
    border-left-color: var(--accent);
}
.line.target .num { color: var(--accent); }

mark {
    background: rgba(240, 179, 90, .35);
    color: inherit;
    border-radius: 2px;
}
mark.cur {
    background: var(--accent);
    color: var(--accent-ink);
}

/* перенос строк */
.log.wrap { overflow-x: hidden; }
.log.wrap .line { min-width: 0; }
.log.wrap .txt {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    min-width: 0;
    flex: 1;
}

/* ---------- состояния ---------- */

.state {
    max-width: 520px;
    margin: 18vh auto 0;
    padding: 0 20px;
    text-align: center;
    color: var(--dim);
    line-height: 1.5;
}
.state h2 { color: var(--text); font-size: 20px; font-weight: 650; margin-bottom: 8px; }
.state code {
    font-family: var(--mono);
    font-size: .92em;
    background: var(--bg-gutter);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--text);
}
.state[hidden] { display: none; }

.open-form {
    margin-top: 20px;
    display: flex;
    gap: 8px;
}
.open-form input {
    flex: 1;
    min-width: 0;
    background: var(--bg-gutter);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 15px;
}
.open-form input:focus { border-color: var(--accent); outline: 0; }
.open-form .btn { padding: 9px 16px; font-size: 15px; }

.jump {
    position: fixed;
    right: 14px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-bar);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 3px;
}
.jump[hidden] { display: none; }

@media (max-width: 640px) {
    .bar { padding: 8px 10px; }
    .log { font-size: 12px; }
    .num { min-width: 50px; padding-right: 8px; }
    .txt { padding-left: 10px; }
    html { scroll-padding-top: 170px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}
