:root {
  --bg: #f5f5f5;
  --text: #333;
  --header-bg: #e30613;
  --tile-bg: #ccc;
  --tile-active: #bbb;
  --section-bg: #e0e0e0;
  --border: #eee;
  --input-border: #ccc;
  --accent: #0066cc;
  --accent-dark: #004a99;
  --link: #0066cc;
  --success-bg: #d4edda;
  --success-text: #155724;
  --error-bg: #f8d7da;
  --error-text: #721c24;
  --delete-bg: #dc3545;
  --version: #4caf50;
  --grey-text: #666;
  --input-bg: #fff;
  --upload-bg: #28a745;
  --disabled-bg: #999;
  --hover-bg: #f0f0f0;
  --placeholder: #888;
  --frame-bg: #f0f0f0;
  --star: #f4a800;
}

body.dark-mode {
  --bg: #1a1a1a;
  --text: #eee;
  --tile-bg: #333;
  --tile-active: #444;
  --section-bg: #2a2a2a;
  --border: #444;
  --input-border: #555;
  --accent: #4a9eff;
  --accent-dark: #3a7acc;
  --link: #6bb3ff;
  --success-bg: #1e4620;
  --success-text: #8fd18f;
  --error-bg: #4a2a2a;
  --error-text: #ff9999;
  --delete-bg: #e35d6a;
  --grey-text: #aaa;
  --input-bg: #222;
  --upload-bg: #2e7d32;
  --disabled-bg: #555;
  --hover-bg: #333;
  --placeholder: #888;
  --frame-bg: #121212;
  --star: #ffc700;
}

html.dark-mode {
  --frame-bg: #121212;
}

/* Corporate desktop frame (540px): entire app (incl. header) shows mobile variant on desktop */
html {
    background: var(--frame-bg);
}
body {
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
    border-radius: 0;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}
body.dark-mode {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
}
.content { padding: 20px; }
.main-content { display: flex; flex-direction: column; }

.header {
    background: var(--header-bg);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.header {
    gap: 8px;
}

/* Titel bleibt einzeilig und schrumpft auf schmalen Displays */
.header h1 {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-size: clamp(15px, 4.4vw, 28px);
    font-weight: 700;
    letter-spacing: -0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-icons {
    display: flex;
    flex-shrink: 0;
    gap: 4px;
    font-size: 20px;
    cursor: pointer;
}
.header-icons span,
.header-icons a {
    padding: 8px 10px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: white;
    min-width: 44px;
    min-height: 44px;
}
.header-icons span:hover,
.header-icons a:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}
.header-icons span:active,
.header-icons a:active {
    transform: scale(0.95);
}
.header-icons #home-btn { font-size: 22px; }

.back-link {
    color: white;
    text-decoration: none;
    font-size: 22px;
    font-weight: 600;
    flex-shrink: 0;
    margin-right: 0;
    padding: 10px 14px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
}
.back-link:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateX(-3px);
}
.back-link:active {
    transform: translateX(-1px) scale(0.95);
    background: rgba(255, 255, 255, 0.35);
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
}

/* Mobile Buttons (2-col on home, 1-col on sub) */
.menu-tile {
    background: var(--tile-bg);
    height: 100px;
    padding: 12px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transition: all 0.15s ease;
    text-decoration: none;
    color: var(--text);
    border: none;
    cursor: pointer;
    box-sizing: border-box;
}

.menu-tile:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
    transform: translateY(-2px);
}

.menu-tile:active {
    transform: scale(0.96);
    background: var(--tile-active);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Subpage 1-col grid (replaces per-page <style> overrides) */
.menu-grid.sub {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 20px;
    min-height: unset;
}
.menu-grid.sub .menu-tile {
    height: 70px;
    min-height: unset;
    font-size: 16px;
    font-weight: 600;
}

/* Light corporate polish */
.menu-tile:focus-visible,
.search-btn:focus-visible,
.upload-btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.train-image {
    padding: 0;
    line-height: 0;
    background: white;
    border-bottom: 2px solid var(--border);
}
.train-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: contain;
    padding: 8px 0;
}

.version {
    text-align: center;
    color: var(--version);
    font-size: 12px;
    font-weight: 600;
    padding: 12px 20px;
    background: var(--hover-bg);
    letter-spacing: 0.5px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* === Unified list / data pages (Bahnhofspläne, Streckenbücher, Regelwerke) === */
.search-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--hover-bg);
    margin: 0;
    border-bottom: 1px solid var(--border);
}
.search-container input,
.upload-input {
    width: 100%;
    padding: 16px 14px;
    font-size: 16px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    box-sizing: border-box;
    background: var(--input-bg);
    color: var(--text);
    transition: all 0.2s ease;
}
.search-container input:focus,
.upload-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}
.search-btn {
    box-sizing: border-box;
    width: 100%;
    padding: 16px 14px;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.25);
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}
.search-btn:hover {
    box-shadow: 0 6px 16px rgba(0, 102, 204, 0.35);
    transform: translateY(-2px);
}
.search-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.2);
}
.search-btn:disabled {
    background: var(--disabled-bg);
    box-shadow: none;
    transform: none;
}

.upload-btn {
    width: 100%;
    padding: 16px 14px;
    background: var(--upload-bg);
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.25);
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}
.upload-btn:hover {
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.35);
    transform: translateY(-2px);
}
.upload-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}
.section-header {
    background: var(--section-bg);
    padding: 14px 20px;
    font-weight: 700;
    font-size: 14px;
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.plan-list {
    padding: 0;
    background: white;
    border-radius: 0 0 8px 8px;
}
body.dark-mode .plan-list {
    background: #252525;
}
.plan-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
}
.plan-item:hover {
    background: var(--hover-bg);
}
.plan-item:last-child {
    border-bottom: none;
}
.plan-item a {
    color: var(--link);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}
.plan-item a:hover {
    color: var(--accent-dark);
}
.delete-btn {
    background: var(--delete-bg);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.25);
}
.delete-btn:hover {
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.4);
    transform: translateY(-1px);
}
.delete-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(220, 53, 69, 0.2);
}
.edit-mode .delete-btn { display: inline-block; }
.progress-container {
    padding: 20px;
    display: none;
    background: var(--hover-bg);
    border-bottom: 1px solid var(--border);
}
.progress-bar {
    height: 6px;
    background: linear-gradient(90deg, var(--accent), #0047a3);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
}
.status {
    padding: 14px 16px;
    margin: 12px 20px;
    border-radius: 8px;
    display: none;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.status.success {
    background: var(--success-bg);
    color: var(--success-text);
    border-left: 4px solid var(--success-text);
}
.status.error {
    background: var(--error-bg);
    color: var(--error-text);
    border-left: 4px solid var(--error-text);
}
.status.visible { display: block; }
.edit-hint { font-size: 12px; color: var(--grey-text); }

/* === RI100 search specific (unified to match good .search-container / .plan-item look) === */
.form-container {
    padding: 20px;
    box-sizing: border-box;
    background: var(--hover-bg);
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    border-radius: 8px;
}
.form-group { margin-bottom: 18px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    letter-spacing: 0.2px;
}
.form-group input[type="text"] {
    width: 100%;
    padding: 14px 12px;
    font-size: 18px;
    border: 2px solid var(--input-border);
    border-radius: 6px;
    box-sizing: border-box;
    background: var(--input-bg);
    color: var(--text);
}
.search-btn { /* reuses above */ }
.search-btn:active { background: var(--accent-dark); }
.checkbox-group {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    padding: 12px;
    background: var(--input-bg);
    border-radius: 8px;
    border: 2px solid var(--input-border);
    transition: all 0.2s ease;
    cursor: pointer;
}
.checkbox-group:hover {
    border-color: var(--accent);
}
.checkbox-group input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}
.results {
    padding: 0;
    background: white;
    border-radius: 0 0 8px 8px;
    margin-bottom: 20px;
}
body.dark-mode .results {
    background: #252525;
}
.result-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.result-item:hover {
    background: var(--hover-bg);
    transform: translateX(2px);
}
.result-item:last-child {
    border-bottom: none;
}
.result-name {
    font-weight: 500;
    flex: 1;
}
.result-abk {
    font-weight: 700;
    color: white;
    background: var(--accent);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
}

/* === General dark input/button polish === */
body.dark-mode .search-btn:active { background: var(--accent-dark); }
body.dark-mode input::placeholder { color: var(--placeholder); }
input::placeholder { color: var(--placeholder); }
.placeholder-text { color: var(--grey-text); }

/* Edit mode indicator (used by info ⓘ buttons) */
#info-btn.editing { color: var(--delete-bg); }

/* Legacy list styles (for streckenbuecher.html etc) */
.list { padding: 0 16px; }
.list-item { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.date { color: var(--grey-text); font-size: 14px; }

/* === Bahnhof detail page === */
.bf-title {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.type-badge {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.card {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 16px 20px;
    overflow: hidden;
}

.card-title {
    background: var(--section-bg);
    padding: 12px 16px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.3px;
}

.kv-row {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    font-family: 'Courier New', monospace;
}

.kv-row:last-child {
    border-bottom: none;
}

.kv-label {
    font-weight: 600;
    flex: 0 0 auto;
}

.kv-value {
    text-align: right;
    color: var(--text);
    font-weight: 500;
}

/* === Updated Telefonbuch compact list === */
.result-sub {
    font-size: 12px;
    color: var(--grey-text);
    margin-top: 4px;
}

/* === Star button (favorites) === */
.star-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--star);
    transition: all 0.2s ease;
    border-radius: 6px;
}

.star-btn:hover {
    background: rgba(244, 168, 0, 0.1);
    transform: scale(1.15);
}

.star-btn:active {
    transform: scale(0.95);
}

/* === Anmeldung, Konto, Benutzerverwaltung === */
[hidden] {
    display: none !important;
}
.form-label {
    font-size: 14px;
    color: var(--grey-text);
    margin-bottom: -8px;
}
.search-container select {
    width: 100%;
    padding: 16px 14px;
    font-size: 16px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    box-sizing: border-box;
    background: var(--input-bg);
    color: var(--text);
}
.user-row {
    flex-wrap: wrap;
    gap: 8px;
}
.user-meta {
    flex: 1 1 100%;
    font-size: 13px;
    color: var(--grey-text);
}
.user-name {
    font-weight: bold;
    color: var(--text);
}
.user-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}
.user-actions button {
    padding: 6px 10px;
    font-size: 14px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: var(--tile-bg);
    color: var(--text);
    cursor: pointer;
}
.user-actions button.danger {
    color: var(--delete-bg);
}
.password-box {
    font-family: monospace;
    font-size: 18px;
    padding: 10px;
    word-break: break-all;
    background: var(--input-bg);
    border: 1px dashed var(--input-border);
    border-radius: 6px;
    color: var(--text);
}

/* Schmale Displays: Header-Icons enger, damit der Titel Platz hat */
@media (max-width: 400px) {
    .header { padding: 12px 12px; }
    .back-link { min-width: 40px; padding: 8px 10px; }
    .header-icons { gap: 2px; font-size: 18px; }
    .header-icons span, .header-icons a { padding: 6px 3px; min-width: 36px; min-height: 36px; }
}

/* Formulare der Anmeldung / Konto / Benutzerverwaltung: gleichmäßiger Abstand zwischen Feldern und Button */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.auth-form .form-label {
    margin-bottom: -6px;
}

/* === Feedback === */
.search-container textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    font-family: inherit;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    box-sizing: border-box;
    background: var(--input-bg);
    color: var(--text);
    resize: vertical;
}
.form-hint {
    margin: 0;
    font-size: 14px;
    color: var(--grey-text);
}
.feedback-item {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.feedback-title {
    font-weight: bold;
    color: var(--text);
}
.feedback-meta {
    font-size: 13px;
    color: var(--grey-text);
}
.feedback-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text);
}
.feedback-delete {
    align-self: flex-end;
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: var(--tile-bg);
    color: var(--delete-bg);
    cursor: pointer;
}

