html {
    height: 100%;
    /* Prevent overscroll/bounce on iOS */
    overflow: hidden;
    position: fixed;
    width: 100%;
}

body {
    margin: 0px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    user-select: none;
    padding: 0px;
    height: 100%;
    background: #f0f2f5;
    /* Prevent overscroll/bounce on iOS */
    overflow: hidden;
    position: fixed;
    width: 100%;
    /* Prevent callout on long-press */
    -webkit-touch-callout: none;
    /* Prevent tap highlight */
    -webkit-tap-highlight-color: transparent;
    /* Smooth scrolling */
    -webkit-overflow-scrolling: touch;
}

/* Prevent pull-to-refresh */
body.no-pull-refresh {
    overscroll-behavior-y: contain;
}

#overlay {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

#mapcanvas {
    width: 100%;
    user-select: none;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

#follow_button {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px;
    user-select: none;
    position: absolute;
    top: 0;
    left: 0;
    background: linear-gradient(135deg, #27aae1 0%, #1e8bc3 100%);
    color: white;
    box-shadow:
        0 4px 15px rgba(39, 170, 225, 0.4),
        0 0 0 3px rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 5;
}

#follow_button:hover {
    transform: scale(1.1);
    box-shadow:
        0 6px 20px rgba(39, 170, 225, 0.5),
        0 0 0 3px rgba(255, 255, 255, 0.5);
}

#follow_button:active {
    transform: scale(0.95);
}

#distance,
#speed {
    position: fixed;
    right: 15px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 20px;
    z-index: 5;
    background: linear-gradient(135deg, rgba(74, 144, 217, 0.5) 0%, rgba(53, 122, 189, 0.5) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

#distance {
    bottom: calc(env(safe-area-inset-bottom) + 15px);
}

#speed {
    top: calc(env(safe-area-inset-top) + 10px);
}

#distance:hover,
#speed:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.stat {
    position: relative;
    font-size: min(36px, 10vw);
    font-weight: 700;
    display: flex;
    align-items: baseline;
    color: #ffffff;
    letter-spacing: -0.02em;
}

#speed {
    cursor: pointer;
}

#distance {
    pointer-events: none;
}

.units {
    color: rgba(255, 255, 255, 0.8);
    font-size: min(14px, 4vw);
    font-weight: 600;
    margin-left: 4px;
    letter-spacing: 0;
}

#buttons {
    position: absolute;
    display: flex;
    flex-direction: column;
}

#log_controls {
    display: none;
    position: fixed;
    z-index: 20;
    width: min(90%, 500px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 1.5rem;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    padding: 2rem;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.3s ease-out;
}

#pause {
    background: linear-gradient(135deg, #27aae1 0%, #1e8bc3 100%);
    border-radius: 1rem;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 4px 15px rgba(39, 170, 225, 0.3);
}

.button {
    width: min(100px, 20vh, 20vw);
    padding: 12px;
    user-select: none;
    -webkit-user-drag: none;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 0.75rem;
}

.button:hover {
    filter: brightness(1.1);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.button:active {
    filter: brightness(0.9);
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

#settings {
    position: fixed;
    display: none;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(90%, 600px);
    z-index: 200;
    padding: 2rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 1.5rem;
    overflow-y: auto;
    max-height: 85vh;
    box-sizing: border-box;
    font-size: 16px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -48%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

#tile_server_url,
#kml_url,
#path_affinity,
#speed_filter_seconds,
#server_url,
#username,
#quick_phrases {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e4e8;
    border-radius: 0.5rem;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #ffffff;
    box-sizing: border-box;
}

#tile_server_url:focus,
#kml_url:focus,
#path_affinity:focus,
#speed_filter_seconds:focus,
#server_url:focus,
#username:focus,
#quick_phrases:focus {
    outline: none;
    border-color: #27aae1;
    box-shadow: 0 0 0 3px rgba(39, 170, 225, 0.1);
}

#server_test {
    cursor: pointer;
    border-radius: 0.75rem;
    border: none;
    text-align: center;
    color: #ffffff;
    background: linear-gradient(135deg, #27aae1 0%, #1e8bc3 100%);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(39, 170, 225, 0.3);
    width: 50%;
    margin: 0.2em;
    float: right;
}

.settings_button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 170, 225, 0.4);
}

.settings_button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(39, 170, 225, 0.3);
}

.tile_server_button {
    font-size: 0.9em;
    display: inline-block;
    cursor: pointer;
    padding: 0.5rem;
    margin: 0.25rem 0.5%;
    text-align: center;
    color: #27aae1;
    background: #ffffff;
    border: 2px solid #27aae1;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.tile_server_button:hover {
    background: #27aae1;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 170, 225, 0.2);
}

.tile_server_button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(39, 170, 225, 0.2);
}

.settings_item {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #e1e4e8;
}

#session_history_section {
    display: none;
}

#session_history_list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.session_history_link {
    display: block;
    padding: 8px 12px;
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    color: #0366d6;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s ease;
}

.session_history_link:hover {
    background: #e1e4e8;
    border-color: #0366d6;
}

.settings_header {
    display: flex;
    align-items: flex-start;
    gap: 1em;
    flex-wrap: wrap;
}

.settings_header_icon {
    height: max(10vh, 10vw);
    max-height: 80px;
    border-radius: 15%;
    flex-shrink: 0;
}

.settings_header_text {
    flex: 1;
    min-width: 150px;
}

.settings_header_title {
    font-size: max(4vh, 4vw);
    max-font-size: 28px;
    font-weight: 600;
    color: #24292e;
    line-height: 1.2;
}

.settings_item:last-child {
    border-bottom: none;
}

#settings_title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #24292e;
    border-bottom: 2px solid #e1e4e8;
}

.settings_item_header {
    margin-bottom: 1em;
    font-size: 13px;
}

.settings_item_name {
    display: inline-block;
    width: 15%;
    vertical-align: top;
    font-weight: 600;
    font-size: 14px;
    color: #24292e;
    letter-spacing: 0.02em;
}

.settings_item_description {
    display: inline-block;
    color: #586069;
    font-size: 13px;
}

.settings_item_value {
    display: inline-block;
    margin-left: 5%;
    width: 95%;
    vertical-align: top;
    margin-bottom: 1em;
}

.settings_item_status {
    color: #586069;
    font-size: 13px;
}

#error-message {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%);
    color: white;
    border-radius: 1rem;
    width: min(80%, 500px);
    text-align: center;
    z-index: 20;
    font-weight: 500;
    box-shadow:
        0 10px 40px rgba(255, 82, 82, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.url_input {
    inputmode: url;
    autocapitalize: none;
    autocorrect: off;
    spellcheck: false;
    autocomplete: off;
}

#local_proxy,
#show_actual {
    height: 20px;
    width: 20px;
    cursor: pointer;
    accent-color: #27aae1;
}

#session_display {
    display: flex;
    position: fixed;
    top: calc(env(safe-area-inset-top) + 10px);
    left: 15px;
    padding: 8px 16px;
    min-height: 58px;
    box-sizing: border-box;
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.7) 0%, rgba(204, 0, 0, 0.7) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
    z-index: 150;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    border-radius: 20px;
}

#session_display.recording {
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.5) 0%, rgba(204, 0, 0, 0.5) 100%);
}

#session_display.viewing {
    background: linear-gradient(135deg, rgba(68, 136, 255, 0.5) 0%, rgba(0, 68, 204, 0.5) 100%);
}

#start_recording,
#stop_recording,
#exit_readonly {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border: none;
    border-radius: 10px;
    padding: 6px 16px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#start_recording:hover,
#stop_recording:hover,
#exit_readonly:hover {
    background: white;
}

#start_recording:disabled,
#stop_recording:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#recording_stats {
    font-size: 11px;
    font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
    color: rgba(255, 255, 255, 0.9);
    white-space: pre-line;
    text-align: right;
}

#copied_popup {
    display: none;
    position: fixed;
    top: calc(env(safe-area-inset-top) + 50px);
    left: 15px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
    z-index: 200;
    pointer-events: none;
}

#copied_popup.show {
    display: block;
    animation: popup-fade 1.2s ease-out forwards;
}

@keyframes popup-fade {
    0% {
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

#gps_status {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    margin-bottom: calc(env(safe-area-inset-bottom) + 10px);
    background: rgba(255, 200, 50, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    z-index: 15;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#gps_status.ok {
    background: rgba(68, 221, 68, 0.95);
    color: #fff;
}

#gps_status.error {
    background: rgba(255, 80, 80, 0.95);
    color: #fff;
}

#gps_status.hidden {
    opacity: 0;
    pointer-events: none;
}

#bottombuttons {
    position: fixed;
    bottom: 0;
    left: 0;
    width: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    padding-bottom: calc(env(safe-area-inset-bottom) + 15px);
    z-index: 100;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Jellybean-style buttons */
.jellybean-button {
    width: min(70px, 15vw);
    height: min(70px, 15vw);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.2),
        0 0 0 3px rgba(255, 255, 255, 0.5);
    border: 3px solid rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    outline: none;
}

.jellybean-button:hover {
    transform: scale(1.1);
    box-shadow:
        0 6px 25px rgba(0, 0, 0, 0.3),
        0 0 0 4px rgba(255, 255, 255, 0.8);
}

.jellybean-button:active {
    transform: scale(0.95);
}

.jellybean-button.blue {
    background: linear-gradient(135deg, #4488ff 0%, #0044cc 100%);
}

.jellybean-button.green {
    background: linear-gradient(135deg, #44dd44 0%, #00aa00 100%);
}

.jellybean-button.red {
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
}

.jellybean-button.orange {
    background: linear-gradient(135deg, #ffaa44 0%, #cc7700 100%);
}

.jellybean-button.gray {
    background: linear-gradient(135deg, #888888 0%, #555555 100%);
}

.jellybean-button.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(100%);
}

.jellybean-icon {
    width: 60%;
    height: 60%;
    object-fit: contain;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

/* Confirmation Modal */
#sws_path {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e4e8;
    border-radius: 0.5rem;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #ffffff;
    box-sizing: border-box;
}

#sws_path:focus {
    outline: none;
    border-color: #27aae1;
    box-shadow: 0 0 0 3px rgba(39, 170, 225, 0.1);
}

.close-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    font-size: 1.8rem;
    line-height: 0;
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #586069;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    padding-bottom: 0.1rem;
    z-index: 1;
}

.close-button:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    transform: scale(1.05);
}

.close-button:active {
    background: rgba(239, 68, 68, 0.2);
    color: #b91c1c;
    transform: scale(0.95);
}

/* Trip control buttons */
.trip-button {
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 0.75rem;
    padding: 8px;
    display: inline-block;
}

.trip-button:hover {
    filter: brightness(1.1);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.trip-button:active {
    filter: brightness(0.9);
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* Comment buttons on right side */
#comment_buttons {
    position: fixed;
    right: 15px;
    bottom: calc(env(safe-area-inset-bottom) + 15px);
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 5;
}

#comment_buttons.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(100%);
}

.comment_button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.2),
        0 0 0 3px rgba(255, 255, 255, 0.5);
    border: 3px solid rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.comment_icon {
    width: 60%;
    height: 60%;
    object-fit: contain;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

.comment_button:hover {
    transform: scale(1.15);
    box-shadow:
        0 6px 25px rgba(0, 0, 0, 0.3),
        0 0 0 4px rgba(255, 255, 255, 0.8);
}

.comment_button:active {
    transform: scale(0.95);
}

#comment_white {
    background: linear-gradient(135deg, #ffffff 0%, #dddddd 100%);
}

#comment_white .comment_icon {
    filter: brightness(0);
}

/* Custom Alert Modal */
#alert_overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    justify-content: center;
    align-items: center;
}

#alert_box {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: min(85%, 320px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
}

#alert_message {
    font-size: 1rem;
    color: #333;
    margin-bottom: 1.5rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

#alert_ok {
    background: linear-gradient(135deg, #4488ff 0%, #0044cc 100%);
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

#alert_ok:active {
    transform: scale(0.95);
}

/* Event Edit Modal */
#event_modal {
    display: none;
    position: fixed;
    z-index: 200;
    width: min(90%, 400px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 1.5rem;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    padding: 2rem;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.3s ease-out;
}

.event_modal_top_bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.event_modal_nav_left {
    display: flex;
    gap: 10px;
}

.event_modal_header {
    font-size: 1.5rem;
    font-weight: 700;
    color: #24292e;
    text-align: center;
    margin-bottom: 1rem;
}

#event_modal .close-button {
    position: static;
}

.event_nav_button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #27aae1 0%, #1e8bc3 100%);
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.event_nav_button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(39, 170, 225, 0.4);
}

.event_nav_button:active {
    transform: scale(0.95);
}

.event_nav_button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.event_modal_section {
    margin-bottom: 1.25rem;
}

.event_modal_section label {
    display: block;
    font-weight: 600;
    color: #24292e;
    margin-bottom: 0.5rem;
    font-size: 14px;
}

#event_color_picker {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    min-height: 70px;
}

.color_option {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
    border: 3px solid transparent;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    background-clip: padding-box;
}

.color_option:hover {
    transform: scale(1.15);
}

.color_option.selected {
    transform: scale(1.4);
    border: 3px solid #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.color_option[data-color="red"] {
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
}

.color_option[data-color="yellow"] {
    background: linear-gradient(135deg, #ffdd44 0%, #ccaa00 100%);
}

.color_option[data-color="green"] {
    background: linear-gradient(135deg, #44dd44 0%, #00aa00 100%);
}

.color_option[data-color="blue"] {
    background: linear-gradient(135deg, #4488ff 0%, #0044cc 100%);
}

.color_option[data-color="white"] {
    background: linear-gradient(135deg, #ffffff 0%, #dddddd 100%);
    border: 1px solid #ccc;
}

#event_comment {
    width: 100%;
    height: 80px;
    padding: 0.75rem;
    border: 2px solid #e1e4e8;
    border-radius: 0.5rem;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

#event_comment:focus {
    outline: none;
    border-color: #27aae1;
    box-shadow: 0 0 0 3px rgba(39, 170, 225, 0.1);
}

#quick_phrases_section {
    display: none;
}

#quick_phrase_buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.quick_phrase_button {
    padding: 6px 12px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick_phrase_button:hover {
    background: #e0e0e0;
}

.quick_phrase_button:active {
    background: #d0d0d0;
}

#event_time_offset {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e4e8;
    border-radius: 0.5rem;
    font-size: 14px;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

#event_time_offset:focus {
    outline: none;
    border-color: #27aae1;
    box-shadow: 0 0 0 3px rgba(39, 170, 225, 0.1);
}

.event_modal_hint {
    font-size: 12px;
    color: #586069;
    margin-top: 0.25rem;
}

#event_timestamp_display {
    font-size: 13px;
    color: #586069;
    text-align: center;
}

.event_modal_buttons,
.settings_buttons {
    display: flex;
    gap: 15px;
    margin-top: 1.5rem;
}

.settings_buttons {
    justify-content: flex-end;
}

.event_button {
    flex: 1;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.event_button_delete {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.event_button_delete:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.event_button_save {
    background: linear-gradient(135deg, #27aae1 0%, #1e8bc3 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 170, 225, 0.3);
}

.event_button_save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 170, 225, 0.4);
}

.event_button:active {
    transform: translateY(0);
}

/* View Data Button */
#view_data_button {
    cursor: pointer;
    border-radius: 0.75rem;
    border: none;
    text-align: center;
    color: #ffffff;
    background: linear-gradient(135deg, #27aae1 0%, #1e8bc3 100%);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(39, 170, 225, 0.3);
    width: 50%;
    margin: 0.2em;
}

#view_data_button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 170, 225, 0.4);
}

#view_data_button:active {
    transform: translateY(0);
}

/* Data Viewer Popup */
#data_viewer {
    display: none;
    position: fixed;
    z-index: 250;
    width: min(95%, 700px);
    max-height: 80vh;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 1.5rem;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    padding: 2rem;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.3s ease-out;
    flex-direction: column;
}

#data_viewer.visible {
    display: flex;
}

.data_viewer_header {
    font-size: 1.5rem;
    font-weight: 700;
    color: #24292e;
    margin-bottom: 1rem;
    text-align: center;
}

#data_viewer_content {
    flex: 1;
    overflow-y: auto;
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 12px;
    font-family: "SF Mono", "Monaco", "Inconsolata", "Fira Mono", "Droid Sans Mono", monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 60vh;
    margin: 0;
}

/* Time scrubber for read-only mode */
#time_scrubber {
    position: fixed;
    right: 15px;
    top: calc(env(safe-area-inset-top) + 70px);
    bottom: calc(env(safe-area-inset-bottom) + 20px);
    width: 50px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#time_scrubber_track {
    position: relative;
    width: 8px;
    flex: 1;
    min-height: 100px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    cursor: pointer;
    touch-action: none;
}

#time_scrubber_fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(180deg, #27aae1 0%, #1e8bc3 100%);
    border-radius: 4px;
    pointer-events: none;
}

#time_scrubber_thumb {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #27aae1 0%, #1e8bc3 100%);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    cursor: grab;
    touch-action: none;
}

#time_scrubber_thumb:active {
    cursor: grabbing;
}

#sensor_info {
    position: fixed;
    left: 15px;
    top: calc(env(safe-area-inset-top) + 75px);
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    text-align: left;
    z-index: 10;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

#sensor_info_latlon,
#sensor_info_heading_speed,
#sensor_info_accel,
#sensor_info_gyro {
    font-size: 9px;
    color: #666;
    white-space: pre;
    margin-top: 2px;
    font-family: "SF Mono", "Monaco", "Inconsolata", "Consolas", monospace;
}

/* Large mode for sensor info */
#sensor_info.large #sensor_info_latlon,
#sensor_info.large #sensor_info_heading_speed,
#sensor_info.large #sensor_info_accel,
#sensor_info.large #sensor_info_gyro {
    font-size: 18px;
    margin-top: 4px;
}
