body {
    font-family: monospace;
    max-width: 800px;
    margin: 40px auto;
    padding: 0 20px;
    background: #1a1a1a;
    color: #00ff00;
}

h1, h2 {
    color: #fff;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

input, button {
    background: #333;
    color: #fff;
    border: 1px solid #00ff00;
    padding: 10px;
    font-family: monospace;
    margin: 5px 0;
}

button:hover {
    background: #00ff00;
    color: #000;
    cursor: pointer;
}

.box {
    background: #222;
    padding: 20px;
    border-radius: 5px;
    margin-bottom: 20px;
    border: 1px solid #333;
}

/* --- Элементы формы QR-кода --- */

#qr-url {
    width: 80%;
}

.field {
    margin: 12px 0;
}

.field label {
    display: inline-block;
    margin-bottom: 4px;
}

.settings-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin: 12px 0;
}

.settings-grid .field {
    margin: 0;
}

/* Компактные color-инпуты без "полей ввода" вокруг */
input[type="color"] {
    padding: 2px;
    width: 48px;
    height: 34px;
    vertical-align: middle;
    cursor: pointer;
}

input[type="file"] {
    display: block;
    max-width: 100%;
}

.checkbox-field input {
    margin-right: 6px;
    vertical-align: middle;
}

.checkbox-field label {
    cursor: pointer;
}

/* --- Результат и ошибки --- */

.qr-result {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.qr-result img {
    max-width: 300px;
    height: auto;
    border: 1px solid #333;
    background: #fff;
    padding: 8px;
}

#qr-download {
    color: #00ff00;
    border: 1px solid #00ff00;
    padding: 8px 14px;
    text-decoration: none;
    display: inline-block;
}

#qr-download:hover {
    background: #00ff00;
    color: #000;
}

.qr-error {
    margin-top: 15px;
    color: #ff5555;
    border: 1px solid #ff5555;
    padding: 10px;
    border-radius: 4px;
}

/* --- Ссылка-переход --- */

.go-link {
    color: #00ff00;
    border: 1px solid #00ff00;
    padding: 8px 14px;
    text-decoration: none;
    display: inline-block;
}

.go-link:hover {
    background: #00ff00;
    color: #000;
}

/* --- Таймлайн головной боли --- */

.hd-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #ccc;
}

.hd-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.lg-sun { color: #ffcf3f; }
.lg-moon { color: #9fb4ff; }

.lg-pill {
    display: inline-block;
    width: 18px;
    height: 9px;
    border-radius: 5px;
}
.lg-pill-ok { background: #00d26a; }
.lg-pill-bad { background: #ff4d4d; }
.lg-pill-unk { background: #888; }

.hd-hint {
    font-size: 13px;
    color: #999;
    margin: 4px 0 12px;
}

/* Горизонтальная прокрутка ленты на узких экранах (мобильный Firefox). */
.timeline-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    border: 1px solid #333;
    border-radius: 4px;
    background: #181818;
}

/* Каркас таймлайна: слева закреплённая ось Oy, справа область графика.
   Размеры (в px) выставляет timeline.js — здесь только внешний вид. */
.timeline {
    position: relative;
    min-height: 238px;
}

/* Ось Oy (интенсивность) — «приклеена» слева при горизонтальной прокрутке. */
.tl-yaxis {
    position: sticky;
    left: 0;
    top: 0;
    z-index: 3;
    float: left;
    background: #181818;
    border-right: 1px solid #333;
}

.tl-yscale {
    position: absolute;
    left: 0;
    right: 0;
}

.tl-ytick {
    position: absolute;
    right: 4px;
    transform: translateY(50%);
    font-size: 10px;
    color: #888;
}

.tl-ycap {
    position: absolute;
    bottom: 4px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 9px;
    color: #ffcf3f;
}

/* Область графика с абсолютно позиционированными столбцами. */
.tl-plot {
    position: absolute;
    top: 0;
}

/* Горизонтальные линии сетки по значениям интенсивности. */
.tl-grid {
    position: absolute;
    left: 0;
    height: 0;
    border-top: 1px dashed #2b2b2b;
    pointer-events: none;
}
.tl-grid-base {
    border-top: 2px solid #00ff9c;
}

/* Вертикальная линия начала года + подпись. */
.tl-yearline {
    position: absolute;
    top: 0;
    width: 0;
    border-left: 1px dashed #4a4a2a;
    pointer-events: none;
}
.tl-yearlbl {
    position: absolute;
    top: 2px;
    color: #ffcf3f;
    font-size: 10px;
    pointer-events: none;
}

/* Кнопка-столбец = ЗОНА НАЖАТИЯ («ячейка» 1D-Вороного между соседями).
   Ширина и позиция ячейки задаются из timeline.js так, чтобы зоны нажатия
   соседних эпизодов НЕ перекрывались — тап всегда попадает в один эпизод. */
.tl-col {
    position: absolute;
    top: 0;
    bottom: 0;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    border-radius: 4px;
    z-index: 1;
}

.tl-col:hover {
    background: rgba(255, 255, 255, 0.06);
    z-index: 4;
}
.tl-col.active {
    background: rgba(0, 255, 156, 0.12);
    outline: 1px solid #00ff9c;
    z-index: 5;
}

/* Видимая графика столбца — центрируется по реальной дате ВНУТРИ ячейки.
   Именно она может визуально «наезжать» на соседей в плотных участках, но
   зоны нажатия (.tl-col) при этом остаются раздельными. */
.tl-col-inner {
    position: absolute;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.tl-time {
    height: 22px;
    display: flex;
    gap: 1px;
    align-items: center;
    justify-content: center;
}

/* Область столбца интенсивности (высота = BARS_H в timeline.js). */
.tl-barbox {
    position: relative;
    width: 100%;
    height: 150px;
}

.tl-range {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    opacity: 0.35;
    border-radius: 3px;
}

.tl-avg {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 4px;
    border-radius: 2px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.tl-val {
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10px;
    color: #ddd;
}

.tl-noval {
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    text-align: center;
    color: #777;
}

.tl-pill {
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Подпись даты — абсолютно позиционируется по реальной дате (left из JS)
   и центрируется по горизонтали через translateX(-50%). Высота строки дат =
   DATE_H в timeline.js. */
.tl-date {
    position: absolute;
    top: calc(22px + 150px + 20px + 2px); /* TIME_H + BARS_H + PILL_H + отступ */
    font-size: 9px;
    color: #aaa;
    writing-mode: vertical-rl;
    transform: translateX(-50%);
    height: 40px;
    pointer-events: none;
    white-space: nowrap;
}

/* Тесный участок: подпись мельче и разнесена по вертикали через чётность
   индекса (.tl-date-high / .tl-date-low), чтобы соседние даты не сливались. */
.tl-date-sm {
    font-size: 8px;
    color: #9a9a9a;
}
.tl-date-high {
    top: calc(22px + 150px + 20px + 1px);
}
.tl-date-low {
    top: calc(22px + 150px + 20px + 20px);
}

/* Переключатель режимов раскладки (пропорционально / равномерно). */
.tl-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin: 10px 0 4px;
}
.tl-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #ddd;
    user-select: none;
}
.tl-switch input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Иконки. */
.ic {
    width: 16px;
    height: 16px;
}
.ic-sun { fill: #ffcf3f; stroke: #ffcf3f; }
.ic-moon { fill: #9fb4ff; stroke: none; }
.ic-pill { stroke: rgba(0, 0, 0, 0.5); }
.ic-pill-ok rect { fill: #00d26a; }
.ic-pill-bad rect { fill: #ff4d4d; }
.ic-pill-unk rect { fill: #888; }
.ic-pill line { stroke: rgba(0, 0, 0, 0.4); }

.hd-empty {
    color: #999;
    padding: 20px;
}

/* Карточка эпизода. */
.hd-card {
    position: relative;
    margin-top: 16px;
    background: #161616;
    border: 1px solid #00ff9c;
    border-radius: 6px;
    padding: 16px;
}

.hd-card h3 {
    margin: 0 0 10px;
    color: #fff;
}

.hd-card-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 34px;
    height: 34px;
    line-height: 1;
    font-size: 20px;
    padding: 0;
    border: 1px solid #555;
    background: #333;
    color: #fff;
    border-radius: 4px;
}

.hd-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.hd-badge {
    font-size: 12px;
    color: #cfe;
    border: 1px solid #2a5;
    border-radius: 12px;
    padding: 3px 10px;
}

.hd-raw {
    color: #cfcfcf;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Мобильная адаптация. Ширина столбца задаётся инлайном из timeline.js
   (COL_W), поэтому здесь её не переопределяем. */
@media (max-width: 600px) {
    body {
        margin: 20px auto;
        padding: 0 10px;
    }
}
