:root {
    color-scheme: light;

    --bg: #f5f7f4;
    --surface: #ffffff;
    --surface-soft: #edf3ef;

    --text: #17221c;
    --muted: #65736b;

    --primary: #163b2d;
    --primary-strong: #0f2b20;

    --border: #dbe4de;
    --danger: #a33131;

    --shadow: 0 12px 30px rgba(20, 45, 32, 0.08);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    color: var(--text);
    background: var(--bg);
}

button,
input {
    font: inherit;
}

button,
a,
input {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}


/* App */

.app-shell {
    width: min(100%, 760px);
    min-height: 100vh;
    margin: 0 auto;

    background: var(--bg);
}


/* Header */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding:
        max(14px, env(safe-area-inset-top))
        18px
        14px;

    background: rgba(245, 247, 244, 0.94);

    backdrop-filter: blur(14px);

    border-bottom:
        1px solid rgba(219, 228, 222, 0.8);
}

.brand {
    display: inline-flex;
    gap: 10px;
    align-items: center;

    color: var(--text);

    font-weight: 800;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;

    width: 38px;
    height: 38px;

    border-radius: 12px;

    background: var(--primary);

    font-size: 20px;
}

.connection-status {
    padding: 7px 10px;

    border-radius: 999px;

    background: #fff0d8;
    color: #744b0b;

    font-size: 12px;
    font-weight: 800;
}


/* Content */

.content {
    padding:
        24px
        18px
        calc(100px + env(safe-area-inset-bottom));
}

.hero,
.page-heading {
    margin: 10px 2px 24px;
}

.hero h1,
.page-heading h1 {
    margin: 6px 0 8px;

    font-size: clamp(2rem, 8vw, 3rem);
    line-height: 1.02;

    letter-spacing: -0.04em;
}

.hero-copy,
.page-heading p:not(.eyebrow) {
    margin: 0;

    color: var(--muted);

    font-size: 1rem;
    line-height: 1.55;
}

.eyebrow {
    margin: 0;

    color: var(--primary);

    font-size: 0.76rem;
    font-weight: 900;

    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.back-link {
    display: inline-block;

    margin-bottom: 18px;

    color: var(--primary);

    font-weight: 800;
    text-decoration: none;
}


/* Startseite */

.home-grid {
    display: grid;
    gap: 14px;
}

.tool-card,
.calculator-card,
.result-card,
.info-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--surface);

    box-shadow: var(--shadow);
}

.tool-card {
    display: grid;

    grid-template-columns: auto 1fr auto;

    gap: 16px;

    align-items: center;

    min-height: 120px;

    padding: 20px;

    color: var(--text);

    text-decoration: none;
}

.tool-card:active {
    transform: scale(0.99);
}

.tool-icon {
    display: grid;
    place-items: center;

    width: 54px;
    height: 54px;

    border-radius: 17px;

    background: var(--surface-soft);

    font-size: 28px;
}

.tool-card strong,
.tool-card small {
    display: block;
}

.tool-card strong {
    margin-bottom: 5px;

    font-size: 1.08rem;
}

.tool-card small {
    color: var(--muted);

    line-height: 1.45;
}

.chevron {
    color: var(--muted);

    font-size: 32px;
}

.info-card {
    margin-top: 18px;

    padding: 18px;
}

.info-card p {
    margin: 6px 0 0;

    color: var(--muted);

    line-height: 1.45;
}


/* Formulare */

.calculator-card {
    display: grid;
    gap: 18px;

    padding: 20px;
}

.field {
    display: grid;
    gap: 8px;

    font-weight: 800;
}

.field > span:first-child {
    font-size: 0.92rem;
}

.field small {
    color: var(--muted);

    font-weight: 600;
}

input {
    width: 100%;
    min-height: 54px;

    padding: 13px 14px;

    border: 1px solid var(--border);
    border-radius: 14px;

    outline: none;

    background: #fff;
    color: var(--text);

    font-size: 1.08rem;
    font-weight: 700;
}

input:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(22, 59, 45, 0.12);
}

.input-with-unit {
    display: grid;

    grid-template-columns: 1fr auto;

    align-items: center;

    border: 1px solid var(--border);
    border-radius: 14px;

    overflow: hidden;

    background: #fff;
}

.input-with-unit:focus-within {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(22, 59, 45, 0.12);
}

.input-with-unit input {
    border: 0;
    border-radius: 0;

    box-shadow: none;
}

.input-with-unit > span:last-child {
    padding: 0 14px;

    color: var(--muted);

    font-weight: 800;
}


/* Buttons */

.primary-button,
.secondary-button,
.lock-button {
    min-height: 52px;

    border: 0;
    border-radius: 14px;

    font-weight: 900;
}

.primary-button {
    padding: 0 18px;

    background: var(--primary);
    color: #fff;
}

.primary-button:active {
    background: var(--primary-strong);
}

.secondary-button {
    padding: 0 14px;

    background: var(--surface-soft);
    color: var(--primary);
}


/* Fehler */

.form-error {
    margin: -4px 0 0;

    color: var(--danger);

    font-size: 0.9rem;
    font-weight: 700;

    line-height: 1.4;
}


/* Ergebnisse */

.result-card {
    margin-top: 18px;

    overflow: hidden;
}

.result-row {
    display: flex;

    justify-content: space-between;

    gap: 18px;

    padding: 17px 20px;

    border-bottom: 1px solid var(--border);
}

.result-row:last-child {
    border-bottom: 0;
}

.result-row span {
    color: var(--muted);
}

.result-row strong {
    text-align: right;
}

.result-row.total {
    background: var(--surface-soft);
}

.result-row.arrival {
    background: var(--surface);
}

.result-row.arrival strong {
    color: var(--primary);
}


/* Etappenplaner */

.two-column-fields {
    display: grid;
    gap: 16px;
}

.planner-toolbar {
    display: flex;

    gap: 14px;

    align-items: center;
    justify-content: space-between;

    margin: 26px 2px 12px;
}

.planner-toolbar strong {
    display: block;

    margin-top: 5px;
}

.stage-list {
    display: grid;
    gap: 12px;
}

.stage-card {
    display: grid;

    grid-template-columns: 1fr auto;

    gap: 12px;

    align-items: end;

    padding: 16px;

    border: 1px solid var(--border);
    border-radius: 18px;

    background: var(--surface);
}

.stage-card.locked {
    border-color: #b9ccbf;

    background: #f9fbf9;
}

.stage-title {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 10px;

    margin-bottom: 8px;

    font-size: 0.9rem;
    font-weight: 900;
}

.stage-state {
    color: var(--muted);

    font-size: 0.75rem;
    font-weight: 800;
}

.lock-button {
    width: 54px;

    background: var(--surface-soft);
    color: var(--primary);

    font-size: 20px;
}

.lock-button[aria-pressed="true"] {
    background: var(--primary);
    color: #fff;
}

.stage-summary {
    margin-top: 16px;
}

.helper-text {
    margin: 14px 4px 0;

    color: var(--muted);

    font-size: 0.86rem;
    line-height: 1.5;
}


/* Bottom Navigation */

.bottom-nav {
    position: fixed;

    bottom: 0;
    left: 50%;

    z-index: 20;

    display: grid;

    grid-template-columns: repeat(3, 1fr);

    width: min(100%, 760px);

    transform: translateX(-50%);

    padding:
        8px
        10px
        calc(8px + env(safe-area-inset-bottom));

    border-top: 1px solid var(--border);

    background: rgba(255, 255, 255, 0.96);

    backdrop-filter: blur(14px);
}

.nav-item {
    display: grid;

    place-items: center;

    gap: 3px;

    min-height: 58px;

    border-radius: 14px;

    color: var(--muted);

    font-size: 0.76rem;
    font-weight: 800;

    text-decoration: none;
}

.nav-item span:first-child {
    font-size: 20px;
}

.nav-item.active {
    background: var(--surface-soft);
    color: var(--primary);
}

/* Routennotizen */

select {
    width: 100%;
    min-height: 54px;

    padding: 13px 14px;

    border: 1px solid var(--border);
    border-radius: 14px;

    outline: none;

    background: #fff;
    color: var(--text);

    font-size: 1rem;
    font-weight: 700;
}

select:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px
        rgba(22, 59, 45, 0.12);
}


.notes-editor {
    margin-top: 22px;
}


.notes-toolbar {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 14px;

    margin:
        0
        2px
        14px;
}


.notes-toolbar strong {
    display: block;

    margin-top: 5px;
}


.notes-point-list {
    display: grid;

    gap: 12px;
}


.note-point-card {
    padding: 16px;

    border:
        1px solid
        var(--border);

    border-radius: 18px;

    background:
        var(--surface);

    box-shadow:
        var(--shadow);
}


.note-point-header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;

    margin-bottom: 16px;
}


.note-point-grid {
    display: grid;

    gap: 14px;
}


.remove-point-button {
    border: 0;

    background:
        transparent;

    color:
        var(--danger);

    font-weight: 800;

    padding:
        8px
        4px;
}


.notes-error {
    margin:
        16px
        4px
        0;
}


.notes-generate-button {
    width: 100%;

    margin-top: 18px;
}


.notes-empty {
    padding:
        18px;

    border:
        1px dashed
        var(--border);

    border-radius:
        16px;
}


.route-preview {
    margin-top:
        28px;
}


.canvas-preview-card {
    overflow: hidden;

    padding:
        10px;

    border:
        1px solid
        var(--border);

    border-radius:
        var(--radius);

    background:
        var(--surface);

    box-shadow:
        var(--shadow);
}


#route-notes-canvas {
    display: block;

    width: 100%;
    height: auto;

    border-radius:
        14px;

    background:
        var(--bg);
}

/* Größere Displays */

@media (min-width: 640px) {
    .content {
        padding-left: 28px;
        padding-right: 28px;
    }

    .home-grid,
    .two-column-fields {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
    .note-point-grid {
    grid-template-columns:
        0.8fr
        1fr
        1.8fr;
}

.note-point-note-field {
    grid-column:
        1 / -1;
}
}
.notes-add-button {
    width: 100%;
    margin-top: 14px;
}
.notes-import-button {
    width: 100%;
    margin-top: 4px;
}


.notes-status {
    margin: 2px 0 0;

    color: var(--primary);

    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.4;
}
.stage-notes-button {
    width: 100%;
    margin-top: 16px;
}
.preview-actions {
    display: flex;
    gap: 8px;
}


.preview-actions button {
    padding-left: 14px;
    padding-right: 14px;
}


button:disabled {
    cursor: default;
    opacity: 0.45;
}


.point-distance-info {
    margin:
        14px
        0
        0;

    padding-top:
        12px;

    border-top:
        1px solid
        var(--border);

    color:
        var(--primary);

    font-size:
        0.88rem;

    font-weight:
        800;
}


@media (max-width: 520px) {

    .route-preview .notes-toolbar {
        align-items:
            stretch;

        flex-direction:
            column;
    }


    .preview-actions {
        display: grid;

        grid-template-columns:
            1fr 1fr;
    }

}