:root {
    --blue: #1e88e5;
    --blue-dark: #0b3d6e;
    --ink: #1b2430;
    --muted: #667085;
    --line: #e3e8ef;
    --bg: #f4f6f9;
    --card: #ffffff;
    --danger: #c62828;
    --radius: 10px;
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    color: var(--ink);
    background: var(--bg);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0.5rem 0; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.25rem; }
h1:focus { outline: none; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.note { background: #fff8e1; border-left: 3px solid #f9a825; padding: 0.5rem 0.75rem; border-radius: 4px; font-size: 0.9rem; }
.message { background: #e3f2fd; padding: 0.6rem 0.9rem; border-radius: var(--radius); }

/* Layout */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--blue-dark);
    color: white;
}

.brand { display: flex; align-items: center; gap: 0.5rem; color: white; font-weight: 700; font-size: 1.1rem; }
.brand img { border-radius: 6px; }
.brand:hover { text-decoration: none; }

.tabs { display: flex; gap: 0.25rem; overflow-x: auto; }
.tabs a { color: #cfe3f7; padding: 0.4rem 0.7rem; border-radius: 6px; white-space: nowrap; }
.tabs a.active { background: rgba(255, 255, 255, 0.16); color: white; }
.tabs a:hover { text-decoration: none; color: white; }

.page { max-width: 960px; margin: 0 auto; padding: 0.75rem 1rem 5rem; }

@media (max-width: 640px) {
    .topbar { padding: 0.5rem 0.75rem; }
    .topbar { gap: 0.5rem; }
    .brand span { display: none; }
    .brand img { width: 24px; height: 24px; }
    .tabs { flex: 1; justify-content: space-between; }
    .tabs a { padding: 0.35rem 0.4rem; font-size: 0.88rem; }
    .page { padding: 0.5rem 0.75rem 4rem; }
}

.crumbs { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
}

.card > h2:first-child { margin-top: 0.25rem; }
.prose p { line-height: 1.55; }

details.card summary { cursor: pointer; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary h2 { display: inline; margin: 0; }
details.card summary::before { content: "▸ "; color: var(--muted); }
details.card[open] summary::before { content: "▾ "; }

.code-tag {
    display: inline-block;
    min-width: 2.2em;
    padding: 0.05em 0.4em;
    margin-right: 0.3em;
    border-radius: 6px;
    background: var(--blue);
    color: white;
    font-size: 0.8em;
    font-weight: 700;
    text-align: center;
    vertical-align: 0.1em;
}

/* Home */

.hero { padding: 0.5rem 0 0.25rem; }
.hero h1 { font-size: 2rem; color: var(--blue-dark); margin-bottom: 0.25rem; }
.hero p { margin: 0 0 0.75rem; color: var(--muted); }

.search-box { display: flex; gap: 0.5rem; }
.search-box input { flex: 1; }

.area-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.6rem; }

.area-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    height: 100%;
}

.area-card:hover { border-color: var(--blue); text-decoration: none; }
.area-code { flex: none; width: 2.8rem; height: 2.8rem; display: grid; place-items: center; border-radius: 8px; background: var(--blue-dark); color: white; font-weight: 700; font-size: 0.95rem; }
.area-body { display: flex; flex-direction: column; }
.area-name { font-weight: 600; }
.area-meta { font-size: 0.82rem; color: var(--muted); }

/* Route lists */

.sector-block h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.sector-block h2 a { color: var(--ink); }

.route-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.route-list:empty { display: none; }

.route-row {
    display: grid;
    grid-template-columns: 1.8rem 1fr auto auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}

.route-row:last-child { border-bottom: none; }
.route-row:hover { background: #f0f6fd; text-decoration: none; }
.route-no { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-main { display: flex; flex-direction: column; min-width: 0; }
.route-name { font-weight: 600; overflow-wrap: anywhere; }
.route-meta { font-size: 0.8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0 0.6rem; }
.route-status { display: flex; gap: 0.2rem; font-size: 0.95rem; }
.stars { color: #f9a825; font-size: 0.8rem; margin-left: 0.2rem; }
.status-todo { color: var(--blue); }
.status-favorite { color: #e53935; }

.route-row.labelled { grid-template-columns: 3.6rem 1fr auto auto; }

/* Grades */

.grade {
    display: inline-block;
    min-width: 3.1rem;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    text-align: center;
    white-space: nowrap;
}

.grade-none { background: #eceff1; color: #546e7a; }
.grade-easy { background: #c8e6c9; color: #1b5e20; }
.grade-mid { background: #b3e5fc; color: #01579b; }
.grade-hard { background: #ffe0b2; color: #e65100; }
.grade-harder { background: #ffcdd2; color: #b71c1c; }
.grade-extreme { background: #4a148c; color: white; }

/* Route detail */

.route-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.route-header .grade { font-size: 1.1rem; padding: 0.3rem 0.6rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.9rem; }
.facts dd { margin: 0; }

.description { font-style: italic; line-height: 1.5; }
.protection { font-size: 0.9rem; line-height: 1.45; }

.symbols { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; }
.symbol {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #f7f9fc;
    font-size: 0.8rem;
    white-space: nowrap;
}

.symbol-bolted { background: #263238; color: white; border-color: #263238; }
.symbol-classic, .symbol-recommended { background: #fff8e1; border-color: #ffe082; }
.symbol-serious, .symbol-badbolts { background: #ffebee; border-color: #ef9a9a; color: var(--danger); }
.symbol-unequipped, .symbol-aid { background: #efebe9; border-color: #bcaaa4; }

.symbol-legend { list-style: none; padding: 0; margin: 0.75rem 0; display: grid; gap: 0.35rem; font-size: 0.9rem; }

.toggle-row, .button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }

/* Forms */

input, select, textarea, button {
    font: inherit;
    color: inherit;
}

input[type=text], input[type=search], input[type=date], input[type=number], select, textarea {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid #cdd5df;
    border-radius: 8px;
    background: white;
}

button, .button-link {
    display: inline-block;
    padding: 0.45rem 0.85rem;
    border: 1px solid #cdd5df;
    border-radius: 8px;
    background: white;
    color: var(--ink);
    cursor: pointer;
}

.button-link:hover { text-decoration: none; background: #f0f6fd; }
button:disabled, .button-link.disabled { opacity: 0.4; pointer-events: none; }
button.primary, .search-box button { background: var(--blue); border-color: var(--blue); color: white; }
button.danger { border-color: var(--danger); color: var(--danger); }
button.link { border: none; background: none; padding: 0; color: var(--blue); }
button.link.danger { color: var(--danger); }
button.toggle.on { background: var(--blue); border-color: var(--blue); color: white; }

.field { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
.field > input, .field > select, .field > textarea { color: var(--ink); font-size: 1rem; }

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.6rem; }
.filters .wide { grid-column: 1 / -1; }
.kinds { border: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.kinds legend { font-size: 0.85rem; color: var(--muted); padding: 0; margin-bottom: 0.2rem; }
.check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.92rem; }
.check-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; }

/* Logbook */

.note-list { padding-left: 1.2rem; line-height: 1.8; }

/* More / info */

.menu { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.menu a { display: flex; flex-direction: column; padding: 0.75rem 1rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
.menu a:hover { border-color: var(--blue); text-decoration: none; }
.menu span { font-size: 0.85rem; color: var(--muted); }

.grade-table { border-collapse: collapse; }
.grade-table th, .grade-table td { padding: 0.2rem 1rem 0.2rem 0; text-align: left; }

/* Scans */

.scan-figure { margin: 0.75rem 0; }
.scan-figure img { display: block; width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); background: white; }
.scan-figure figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

.scan-list { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.scan-list a { display: grid; grid-template-columns: 6.5rem 1fr; gap: 0.5rem; padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.scan-list li:last-child a { border-bottom: none; }
.scan-pages { font-weight: 600; font-variant-numeric: tabular-nums; }
.scan-content { font-size: 0.85rem; color: var(--muted); }

.viewer-toolbar { position: sticky; top: 3rem; z-index: 5; display: flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0; background: var(--bg); }
.viewer-toolbar button, .viewer-toolbar .button-link { padding: 0.3rem 0.7rem; }
.viewer-title { font-weight: 600; white-space: nowrap; }
.viewer-toolbar .small { white-space: nowrap; }

@media (max-width: 640px) {
    .viewer-toolbar { gap: 0.25rem; font-size: 0.9rem; }
    .viewer-toolbar button, .viewer-toolbar .button-link { padding: 0.25rem 0.5rem; }
}
.spacer { flex: 1; }
.viewer { overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: white; max-height: calc(100vh - 7.5rem); }
.viewer-canvas { position: relative; }
.viewer-canvas img { position: absolute; top: 0; left: 0; max-width: none; display: block; }

/* Blazor */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* "New version available" bar, driven by js/update.js (not by Blazor, so it also shows on the old build). */
#update-ui {
    background: var(--blue-dark);
    color: #fff;
    box-sizing: border-box;
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1.25rem;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    z-index: 20;
    font-size: 0.95rem;
}
#update-ui button {
    margin-left: auto;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: transparent;
    color: #fff;
    border-radius: 6px;
    padding: 0.25rem 0.7rem;
}
#update-ui button + button { margin-left: 0; font-weight: 400; border-color: transparent; }
#update-ui button:hover { background: rgba(255, 255, 255, 0.15); }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Prišlo je do napake."; }

.loading-progress { position: absolute; display: block; width: 8rem; height: 8rem; inset: 20vh 0 auto 0; margin: 0 auto; }
.loading-progress circle { fill: none; stroke: #e0e0e0; stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: var(--blue); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; transition: stroke-dasharray 0.05s ease-in-out; }
.loading-progress-text { position: absolute; text-align: center; font-weight: bold; inset: calc(20vh + 3.25rem) 0 auto 0.2rem; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Nalagam"); }
