/* Все ресурсы локальные: страница должна открываться внутри WebView без сети
   к сторонним хостам. */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #f5f6f8;
    color: #16202b;
}
a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 6px 0 14px; }
h2 { font-size: 17px; margin: 22px 0 10px; }

.topbar {
    display: flex; justify-content: space-between; align-items: center;
    background: #17182b; color: #fff; padding: 11px 18px;
}
.topbar .brand { color: #fff; font-weight: 600; font-size: 18px; }
.topbar .brand:hover { text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar .link { color: #b7bdd6; font-size: 14px; }
.chip {
    background: #2c2e4a; color: #fff; border-radius: 999px;
    padding: 4px 12px; font-size: 14px; font-weight: 600;
}
.chip:hover { background: #3a3d61; text-decoration: none; }

.container { max-width: 960px; margin: 0 auto; padding: 20px 16px 64px; }
.lead { color: #4b5563; font-size: 16px; max-width: 640px; }

.card {
    background: #fff; border: 1px solid #e4e7ec; border-radius: 12px;
    padding: 16px 18px; margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card h2 { margin: 0 0 8px; font-size: 17px; }
.cards-row { display: flex; gap: 12px; flex-wrap: wrap; }
.cards-row .card { flex: 1 1 160px; margin-bottom: 12px; }
.card.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-size: 26px; font-weight: 700; }
.balance-big { font-size: 34px; font-weight: 700; margin: 0 0 8px; }

label { display: block; font-size: 14px; color: #475569; margin-bottom: 10px; }
textarea, input[type=text], input[type=email], input[type=password], select {
    width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 9px;
    font: inherit; background: #fff; margin-top: 4px;
}
textarea { resize: vertical; min-height: 90px; }
select { margin-top: 4px; }

.btn {
    display: inline-block; padding: 9px 18px; border: 1px solid #4f46e5;
    border-radius: 9px; background: #4f46e5; color: #fff; font: inherit;
    cursor: pointer; text-decoration: none;
}
.btn:hover { background: #4338ca; text-decoration: none; }
.btn.ghost { background: #fff; color: #16202b; border-color: #cbd5e1; }
.btn.ghost:hover { background: #f1f5f9; }
.btn.danger { background: #fff; color: #dc2626; border-color: #fca5a5; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px;
    align-items: center; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-form input { flex: 1 1 160px; margin-top: 0; }
.pack-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.pack { min-width: 110px; }

.flash { padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 14px; }
.flash-ok { background: #dcfce7; color: #14532d; }
.flash-error { background: #fee2e2; color: #991b1b; }
.hint { color: #667085; font-size: 13px; margin: 6px 0; }
.dim { color: #667085; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.plus { color: #15803d; }
.minus { color: #b42318; }
.hidden { display: none !important; }

table.grid {
    width: 100%; border-collapse: collapse; background: #fff;
    border: 1px solid #e4e7ec; border-radius: 12px; overflow: hidden;
    margin-bottom: 16px;
}
table.grid th, table.grid td {
    padding: 9px 12px; text-align: left; border-bottom: 1px solid #eef1f5;
    font-size: 14px;
}
table.grid th { background: #f8fafc; color: #475569; font-weight: 600; }
table.grid tr:last-child td { border-bottom: none; }
table.grid .num { text-align: right; white-space: nowrap; }
/* Широкая таблица (отчёт по периодам) едет вбок внутри себя, а не тянет страницу. */
.scroll-x { overflow-x: auto; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #f8fafc; }

.badge {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    background: #e7eaf0; color: #475569; font-size: 12px; white-space: nowrap;
}
.badge-ok { background: #dcfce7; color: #14532d; }
.badge-work { background: #fef3c7; color: #854d0e; }
.badge-err { background: #fee2e2; color: #991b1b; }

/* Создание песни: два режима рядом */
.mode-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.mode-tabs .tab {
    padding: 8px 16px; border: 1px solid #d5d9e2; border-radius: 999px;
    background: #fff; cursor: pointer; font: inherit; color: #475569;
}
.mode-tabs .tab.active { background: #17182b; border-color: #17182b; color: #fff; }

.status { display: flex; align-items: center; gap: 10px; padding: 10px 0;
    color: #475569; font-size: 14px; }
/* Бегущее время ожидания: не должно прыгать по ширине на каждой цифре */
.elapsed { color: #94a3b8; font-variant-numeric: tabular-nums; white-space: nowrap; }
.spinner {
    width: 18px; height: 18px; border: 3px solid #d5d9e2; border-top-color: #4f46e5;
    border-radius: 50%; animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 8px; background: #e7eaf0; border-radius: 999px;
    overflow: hidden; margin: 10px 0 4px; }
.progress-fill { height: 100%; width: 0; background: #4f46e5; transition: width .3s; }

/* Страница песни */
.song-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.song-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
    flex-wrap: wrap; font-size: 14px; color: #667085; }
pre.lyrics {
    white-space: pre-wrap; font-family: inherit; font-size: 15px; line-height: 1.55;
    background: #f8fafc; border: 1px solid #eef1f5; border-radius: 9px;
    padding: 12px 14px; margin: 0 0 12px;
}
.brief-field { margin-bottom: 12px; }
.brief-field label { font-weight: 600; color: #16202b; }
.track { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 12px; }
.track audio { flex: 1; min-width: 220px; }
.track .inline { display: inline; }
.track-title { font-weight: 600; font-size: 14px; min-width: 76px; }
/* Публичная ссылка на трек или клип: адрес виден и тогда, когда буфер запрещён */
.share-url { flex: 1 1 100%; margin: 6px 0 0; padding: 6px 10px; font-size: 13px;
    color: #475569; background: #f8fafc; border: 1px solid #e4e7ec;
    border-radius: 8px; }
/* Список стилей, которые понимает движок */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    background: #f1f5f9; border: 1px solid #e4e7ec; border-radius: 999px;
    padding: 3px 10px; font-size: 13px; color: #334155;
}
/* Режим выбора: теги нажимаются, выбранные — фирменным цветом */
button.tag.pickable { cursor: pointer; font: inherit; font-size: 13px; }
button.tag.pickable:hover { border-color: #4f46e5; }
button.tag.on { background: #4f46e5; border-color: #4f46e5; color: #fff; }
/* Свой тег, вписанный руками: пунктир отличает его от словарного */
button.tag.custom { border-style: dashed; }
/* Спорит с уже выбранным: видно, но приглушено — нажатие объяснит, кто мешает */
button.tag.off { opacity: .35; }
/* Планка с итогом выбора: прилипает к низу, список стилей длинный */
.pickbar {
    position: sticky; bottom: 0; z-index: 10;
    display: flex; align-items: center; gap: 12px;
    background: #fff; border: 1px solid #e4e7ec; border-radius: 12px;
    padding: 10px 14px; margin: 14px 0;
    box-shadow: 0 -2px 10px rgba(16, 24, 40, .08);
}
.pickbar-info { flex: 1; font-size: 14px; color: #475569; }
.pickbar .btn { flex: none; }

/* Обложка песни */
.cover-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.cover-side { flex: 1 1 260px; }
.cover-row .cover {
    width: 190px; height: 190px; object-fit: cover; flex: none;
    border-radius: 12px; background: #17182b; display: block;
}
.cover-row .inline { display: inline; }
.cover-thumb {
    width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block;
    border-radius: 8px; background: #17182b;
}
.share-page .share-cover {
    display: block; width: 100%; max-width: 420px; margin: 12px auto 0;
    border-radius: 12px; background: #17182b;
}
.share-page .share-audio { width: 100%; margin: 12px 0; }
.share-page .share-video { display: block; margin: 12px auto; max-width: 100%;
    max-height: 70vh; aspect-ratio: 9 / 16; border-radius: 10px; background: #000; }

details.version { margin-bottom: 8px; }
details.version summary { cursor: pointer; font-size: 14px; color: #475569; }
.vocal-options { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.vocal-options label { flex: 1 1 150px; margin-bottom: 0; }

/* Предыдущие наборы стилевых тегов */
.tagset { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 8px 0; border-bottom: 1px solid #eef1f5; }
.tagset:last-of-type { border-bottom: none; }
.tagset-tags { flex: 1 1 220px; font-size: 14px; color: #334155; }
.tagset-actions { display: flex; gap: 6px; flex: none; }

/* Карточка узнанной песни-ориентира */
.ref-card { background: #f8fafc; border-color: #d5d9e2; margin-top: 12px; }
.ref-card h3 { margin: 0 0 8px; font-size: 16px; }
.ref-card p { margin: 0 0 8px; }

/* Блок со ссылкой на приложение */
.app-card { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.app-card .app-text { flex: 1 1 260px; }
.app-card h2 { margin-top: 0; }
.app-card .btn { margin-right: 10px; }
/* Подложка под QR всегда белая: тёмный фон ломает распознавание камерой. */
.qr {
    background: #fff; border: 1px solid #e4e7ec; border-radius: 10px;
    padding: 8px; flex: none; line-height: 0;
}
.qr img { display: block; width: 160px; height: 160px; }

/* Клипы */
.clip-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px; }
.clip-card { background: #fff; border: 1px solid #e4e7ec; border-radius: 12px;
    padding: 10px; }
.clip-card video { width: 100%; aspect-ratio: 9 / 16; border-radius: 8px;
    background: #000; display: block; }
/* Карточка библиотеки — это label: клик в любом месте ставит галочку. */
.pick-card { cursor: pointer; display: block; }
.pick-card:has(.pick:checked) { border-color: #4f46e5; box-shadow: 0 0 0 2px #c7d2fe; }
.pick { width: 18px; height: 18px; vertical-align: middle; margin-right: 6px; }
.clip-meta { display: flex; justify-content: space-between; align-items: center;
    gap: 8px; margin-top: 8px; font-size: 13px; color: #667085; }

@media (max-width: 720px) {
    .container { padding: 14px 12px 48px; }
    .card { padding: 14px 13px; }
    .topbar { position: sticky; top: 0; z-index: 10; }
    h1 { font-size: 21px; }
    /* 16px — iOS иначе зумит поле при фокусе */
    textarea, input[type=text], input[type=email], input[type=password], select {
        font-size: 16px; padding: 11px 12px;
    }
    .btn { padding: 12px 18px; }
    .btn.small { padding: 8px 13px; }
    .btn-row .btn, .btn-row form { flex: 1 1 auto; }
    .btn-row form .btn { width: 100%; }
    table.grid th, table.grid td { padding: 9px 8px; }
    .clip-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
