:root {
    --color-bg: #f5f8f8;
    --color-surface: #ffffff;
    --color-primary: #4a9ea5;
    --color-primary-dark: #2c6b71;
    --color-accent: #4a9ea5;
    --color-text: #333333;
    --color-muted: #6b7676;
    --color-border: #d5e2e3;
    --color-danger: #b42318;
    --header-height: 4.25rem;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body, #app {
    height: 100%;
    margin: 0;
}

html {
    background: var(--color-bg);
}

body {
    font-family: "Noto Sans", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
}

* {
    box-sizing: border-box;
}

a {
    color: inherit;
    text-decoration: none;
}

.page {
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.page-list {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--header-height);
    padding: calc(0.75rem + var(--safe-top)) 1rem 0.75rem;
    background: var(--color-primary-dark);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-header-text {
    flex: 1;
    min-width: 0;
}

.app-header h1 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.25;
    white-space: normal;
}

.app-header p {
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-button,
.primary-button {
    appearance: none;
    border: 0;
    border-radius: 4px;
    font: inherit;
    cursor: pointer;
}

.icon-button {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.icon-button:disabled {
    opacity: 0.5;
}

.primary-button {
    background: var(--color-primary);
    color: #fff;
    padding: 0.7rem 1rem;
    font-weight: 700;
}

.list-toolbar {
    flex: 0 0 auto;
    background: var(--color-bg);
    padding-bottom: 0.75rem;
    z-index: 15;
}

.jump-bar,
.filter-row,
.tools-row {
    display: flex;
    gap: 0.6rem;
    padding: 0.75rem 1rem 0;
}

.tools-row {
    gap: 0.5rem;
    padding-top: 0.45rem;
}

.filter-row input {
    flex: 1 1 100%;
}

.tools-row select {
    flex: 1 1 0;
}

.jump-bar input,
.filter-row input,
.tools-row select {
    flex: 1;
    min-width: 0;
    font: inherit;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-surface);
}

.tools-row select {
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
}

.banner {
    margin: 0.75rem 1rem 0;
    padding: 0.7rem 0.85rem;
    border-radius: 4px;
    background: #e7f3f4;
    color: var(--color-primary-dark);
    font-size: 0.9rem;
}

.banner-error {
    background: #f8d7da;
    color: var(--color-danger);
}

.banner-info {
    background: #e7f3f4;
    color: var(--color-primary-dark);
}

.terrain-list {
    list-style: none;
    margin: 0;
    padding: 0 1rem calc(1rem + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.terrain-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.8rem 0.9rem;
    min-height: 3.4rem;
}

.terrain-number {
    flex: 0 0 3rem;
    height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: #fff;
    border-radius: 4px;
    font-weight: 700;
}

.terrain-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.terrain-name {
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.terrain-meta {
    color: var(--color-muted);
    font-size: 0.8rem;
}

.badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #e7f3f4;
    color: var(--color-primary-dark);
    border-radius: 999px;
    padding: 0.2rem 0.5rem;
}

.empty-state {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--color-muted);
}

.page-map {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

.map-canvas {
    flex: 1;
    min-height: 0;
    width: 100%;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    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;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #d5e2e3;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--color-primary);
    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, "Loading");
}
