:root {
    --bg: var(--tg-theme-bg-color, #14171c);
    --card: var(--tg-theme-secondary-bg-color, #1d2129);
    --text: var(--tg-theme-text-color, #e8ecf1);
    --muted: var(--tg-theme-hint-color, #8b97a8);
    --accent: var(--tg-theme-button-color, #4c8dff);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);
    --danger: #e5534b;
    --ok: #3fb950;
    --bar-height: 56px;
}

* { box-sizing: border-box; }

/* An author rule that sets `display` beats the UA rule for [hidden], so `.modal`'s
   display: flex would keep the sheet on screen forever. Make the attribute win. */
[hidden] { display: none !important; }

body {
    margin: 0;
    padding: 0 0 calc(var(--bar-height) + 12px);
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg);
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

h1 { font-size: 17px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }

main { padding: 12px 14px; }

/* No bottom bar on the repository and issue screens — drop the space it would occupy. */
body.no-bar { padding-bottom: 12px; }

.row {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--card);
    border: none;
    border-radius: 12px;
    color: var(--text);
    padding: 12px 14px;
    margin-bottom: 8px;
    font-size: 15px;
}

.row .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: rgba(255, 255, 255, .1);
    color: var(--muted);
}

.badge.waiting { background: rgba(229, 180, 75, .18); color: #e5b44b; }
.badge.failed { background: rgba(229, 83, 75, .18); color: var(--danger); }
.badge.done { background: rgba(63, 185, 80, .18); color: var(--ok); }

button {
    font: inherit;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: var(--card);
    color: var(--text);
    padding: 10px 12px;
}

button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button[disabled] { opacity: .5; }

#bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid rgba(255, 255, 255, .07);
}

#bottom-bar button { flex: 1; font-size: 13px; padding: 10px 6px; }

.comment {
    background: var(--card);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
}

.comment .who { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.comment.factory { border-left: 3px solid var(--accent); }

.question { background: var(--card); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.question .q { font-weight: 600; margin-bottom: 8px; }
.options { display: flex; flex-wrap: wrap; gap: 6px; }
.options button.selected { background: var(--accent); color: var(--accent-text); }
.question input {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .15);
    background: transparent;
    color: var(--text);
}

.actions { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: flex-end;
    z-index: 10;
}

.modal-card {
    width: 100%;
    background: var(--bg);
    border-radius: 16px 16px 0 0;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
}

.modal-card input, .modal-card textarea {
    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .15);
    background: transparent;
    color: var(--text);
    font: inherit;
}

.modal-card textarea { min-height: 120px; resize: vertical; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions button { flex: 1; }

.toast {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: calc(var(--bar-height) + 16px);
    padding: 10px 12px;
    border-radius: 10px;
    background: #2a2f38;
    z-index: 20;
    font-size: 14px;
}

/* Without the bar the toast has no bar to clear. */
body.no-bar .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }

.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }
