body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    width: 360px;
    padding: 0;
    margin: 0;
    color: #333;
    background-color: #f4f6f8;
}

.view-container {
    padding: 15px;
    box-sizing: border-box;
}

h1 { font-size: 14px; margin: 0 0 12px 0; text-align: center; color: #24292e; font-weight: 700; }
h2 { font-size: 12px; margin: 0 0 8px 0; color: #24292e; font-weight: 700; }
p { font-size: 12px; margin: 0 0 8px 0; color: #444; }

/* --- Selection Gate --- */
.selection-group { margin-bottom: 10px; }
.selection-group label { display: block; font-weight: 700; font-size: 10px; color: #444; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
select { 
    width: 100%; 
    padding: 8px; 
    border: 1px solid #dce0e4; 
    border-radius: 6px; 
    background: #fff;
    
    /* Force single line with ellipsis to prevent layout jitter */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Setup Fork --- */
.setup-option {
    background: #f6f8fa;
    padding: 10px 12px;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    text-align: left;
    margin-bottom: 8px;
}
.divider-line {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 8px 0;
    color: #959da5;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.divider-line::before, .divider-line::after { content: ''; flex: 1; border-bottom: 1px solid #ddd; }
.divider-line span { padding: 0 10px; }
.error-msg { color: #d73a49; font-size: 11px; margin-top: 5px; }

/* --- Zone A: Director --- */
.zone-a {
    background: #fff;
    padding: 15px;
    border-bottom: 1px solid #e1e4e8;
    position: sticky; top: 0; z-index: 10;
}
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 10px;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}
.badge.red { background: #ffeef0; color: #d73a49; }
.badge.green { background: #e6ffed; color: #22863a; }
.badge.blue { background: #dbedff; color: #0366d6; }
.badge.orange { background: #fff8c5; color: #b08800; }
.badge.grey { background: #f6f8fa; color: #586069; border: 1px solid #e1e4e8; }

/* --- SYNC CONTROL DECK --- */
.sync-deck {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 5px;
}

/* 1. Master Switch Container */
.master-switch {
    border: none;
    border-radius: 20px;
    padding: 6px 16px; /* Space for text + toggle */
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
    z-index: 2;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px; /* Space between text and toggle */
}

/* Physical Toggle Switch Visual */
.toggle-track {
    width: 28px;
    height: 16px;
    border-radius: 8px;
    position: relative;
    transition: background 0.2s;
}
.toggle-knob {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    transition: left 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Linked State (Green) */
.sync-deck.linked .master-switch {
    background: #e6ffed; /* Light Green Background */
    color: #22863a;      /* Dark Green Text */
    border: 1px solid #2ea44f;
}
.sync-deck.linked .toggle-track { background: #2ea44f; }
.sync-deck.linked .toggle-knob { left: 14px; } /* Right position */

/* Unlinked State (Grey) */
.sync-deck.unlinked .master-switch {
    background: #f6f8fa;
    color: #57606a;
    border: 1px solid #d0d7de;
}
.sync-deck.unlinked .toggle-track { background: #afb8c1; }
.sync-deck.unlinked .toggle-knob { left: 2px; } /* Left position */

/* Hover effects */
.master-switch:hover { transform: translateY(-1px); box-shadow: 0 3px 6px rgba(0,0,0,0.15); }

/* 2. Circuit Lines */
.deck-circuit {
    width: 80%;
    height: 12px;
    position: relative;
    margin-top: -10px; /* Tuck under button */
    z-index: 1;
}
.circuit-line.vertical {
    width: 1px; /* Thinner */
    height: 100%;
    background: #d0d7de;
    margin: 0 auto;
}
.circuit-line.horizontal {
    position: absolute;
    bottom: 0;
    left: 0; right: 0;
    height: 1px; /* Thinner */
    background: #d0d7de;
}
.circuit-droppers {
    display: flex;
    justify-content: space-between;
    width: 100%;
    position: absolute;
    bottom: -6px;
}
.drop-line {
    width: 1px; /* Thinner */
    height: 6px;
    background: #d0d7de;
}

/* Circuit Colors */
.sync-deck.linked .circuit-line, .sync-deck.linked .drop-line { 
    background: #2ea44f; 
    border: none;
    transition: background 0.3s; 
}
.sync-deck.unlinked .circuit-line, .sync-deck.unlinked .drop-line { 
    background: transparent; /* Hide background for dashed border */
    border-color: #d0d7de;
    opacity: 0.6; /* Fainter */
}
.sync-deck.unlinked .circuit-line.vertical, .sync-deck.unlinked .drop-line {
    border-left: 1px dashed #d0d7de;
    width: 0; /* Use border width */
}
.sync-deck.unlinked .circuit-line.horizontal {
    border-top: 1px dashed #d0d7de;
    height: 0; /* Use border height */
    background: transparent;
}

/* 3. Stations */
.deck-stations {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 6px;
}

/* Station Toolbar (Inline Seek Controls) */
.station-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2px;
}

.relative-seek-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

.micro-btn {
    background: none;
    border: none;
    padding: 2px;
    font-size: 10px;
    cursor: pointer;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #586069;
}
.micro-btn:hover {
    background: #e1e4e8;
}

.micro-input {
    width: 28px;
    height: 16px;
    font-size: 10px;
    font-family: monospace;
    text-align: center;
    border: 1px solid #d1d5da;
    border-radius: 3px;
    padding: 0;
    -moz-appearance: textfield;
}
.micro-input::-webkit-outer-spin-button,
.micro-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Grouping Container (Card + Label) */
.station-group {
    display: flex;
    flex-direction: column;
    width: 48%; /* Layout width is now handled here */
    gap: 4px;
}

.station {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%; /* Fills the group container */
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.station-label {
    font-size: 9px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.5px;
}

/* Icon - supports both inline SVG and Image files */
.station-icon svg, .station-icon img { 
    width: 18px; 
    height: 18px; 
    display: block; 
}
.station-icon { 
    display: flex; 
    align-items: center; 
    cursor: help; /* Cursor hints at the tooltip */
}

/* Timestamp */
.timestamp {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    font-weight: 600;
    color: #24292e;
    margin-left: auto; /* Push to right */
}

/* Signal Meter (Equalizer) */
.signal-meter {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
    width: 14px;
    cursor: help; /* Cursor hints at the tooltip */
}
.bar {
    width: 3px;
    background: #d0d7de; /* Default Off */
    border-radius: 1px;
    height: 3px;
}

/* Meter States */
/* ACTIVE (Dancing Green) */
.signal-meter.active .bar {
    background: #2ea44f;
    animation: equalize 0.8s infinite ease-in-out;
}
.signal-meter.active .bar.b1 { animation-delay: 0s; }
.signal-meter.active .bar.b2 { animation-delay: 0.2s; }
.signal-meter.active .bar.b3 { animation-delay: 0.4s; }

/* HOLDING (Static Orange) */
.signal-meter.holding .bar {
    background: #b08800; /* Orange */
    height: 8px !important; /* Fixed height */
    animation: none;
}

/* DEAD (Flat Grey) */
.signal-meter.dead .bar {
    background: #d0d7de;
    height: 2px !important;
    animation: none;
}

@keyframes equalize {
    0% { height: 3px; }
    50% { height: 12px; }
    100% { height: 3px; }
}

.director-controls { display: flex; gap: 5px; margin-bottom: 8px; }
.director-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 11px;
    border: 1px solid #d1d5da;
    background: #f6f8fa;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}
.director-btn:hover { background: #e1e4e8; }
.director-btn.primary { background: #0366d6; color: white; border-color: #0366d6; }
.director-btn.primary:hover { background: #005cc5; }
.director-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.jit-notice { 
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px; 
    color: #586069; 
    margin-bottom: 15px; 
    font-weight: 500;
}
.jit-notice svg {
    fill: currentColor;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* --- Zone B: Map --- */
.zone-b-container {
    height: 200px; /* Restored height */
    overflow-y: auto;
    background: #f4f6f8;
    border-bottom: 1px solid #e1e4e8;
    position: relative;
}
#empty-map-msg {
    text-align: center; color: #999; font-size: 12px;
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}

/* List Item Container */
.map-item {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 8px 12px;
    font-size: 12px;
}
.map-item:hover { background: #fafbfc; }

.map-item.active-point {
    background-color: #f1f8ff; /* Light blue bg */
    border-left: 3px solid #0366d6; /* Blue accent border */
    /* Adjust padding to account for the border so content doesn't shift */
    padding-left: 9px; 
}

/* Display Mode Layout */
.map-item-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-item .info { display: flex; flex-direction: column; gap: 3px; }
/* Base: Paused (Black/Dark Grey) */
.map-item .mode { font-weight: 700; font-size: 10px; color: #24292e; text-transform: uppercase; letter-spacing: 0.5px;}
/* Specifics */
.map-item .mode.is-synced { color: #0366d6; }
.map-item .mode.is-end { color: #d73a49; }

.map-item .timestamps { 
    display: grid; 
    grid-template-columns: auto auto auto auto; 
    gap: 4px;
    align-items: center;
    font-size: 11px;
    color: #444;
}
.map-item .ts-label { color: #888; font-weight: 500; font-size: 9px; text-transform: uppercase;}
.map-item .ts-val { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-weight: 600; color: #24292e; }

/* Action Buttons (Icons) */
.map-item .actions { display: flex; gap: 4px; align-items: center; }
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #586069;
    font-size: 14px; /* Sizing for Emojis */
    transition: all 0.2s;
}
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; }
.icon-btn:hover { background-color: #e1e4e8; color: #0366d6; }

/* Delete Button - Always Red */
.icon-btn.delete-btn { color: #d73a49; }
.icon-btn.delete-btn:hover { background-color: #ffeef0; }

/* Edit Mode Layout */
.edit-form {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
}
.edit-inputs {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}
.edit-group { display: flex; flex-direction: column; gap: 2px; }
.edit-group label { font-size: 9px; color: #666; font-weight: 600; }
.edit-input {
    width: 100%;
    padding: 4px;
    font-size: 11px;
    font-family: monospace;
    border: 1px solid #d1d5da;
    border-radius: 4px;
    box-sizing: border-box;
}
.edit-input:focus { border-color: #0366d6; outline: none; }

.edit-actions { display: flex; gap: 2px; }
.icon-btn.save { color: #22863a; }
.icon-btn.save:hover { background-color: #28a745; color: white; }
.icon-btn.cancel:hover { background-color: #6c757d; color: white; }

/* --- Zone C: Layout & Actions --- */
.zone-c { 
    padding: 10px 15px; /* Tighter vertical padding */
    background: #fff; 
    display: flex;
    flex-direction: column;
    gap: 10px; /* Slightly tighter gap */
}

/* Utilities Row (Drift + Tips) */
.footer-utilities {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #555;
    padding-bottom: 5px;
}

.drift-toggle-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.drift-toggle-group label {
    cursor: pointer;
    font-weight: 500;
}

/* Custom Tooltip (?) */
.info-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 14px;
    height: 14px;
    background: #e1e4e8;
    color: #586069;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    cursor: help;
    position: relative;
}

/* Tooltip Popup on Hover (Base Styles) */
.info-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 22px; /* Position above the icon */
    
    background: #24292e;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    
    /* Constraint Fix: Wrap text */
    white-space: normal;
    width: 200px;
    
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Context: Playback Mode (Icon on Right -> Grow Left) */
.footer-playback .info-icon:hover::after {
    right: 0;
    left: auto;
    text-align: right;
}

/* Context: Edit Mode (Icon near right edge -> Grow Left) */
.footer-edit .info-icon:hover::after {
    right: 0;
    left: auto;
    text-align: left;
}

/* Tooltip Arrow */
.info-icon:hover::before {
    content: '';
    position: absolute;
    bottom: 14px;
    /* Keep arrow centered on the icon */
    left: 50%;
    transform: translateX(-50%);
    
    border-width: 4px;
    border-style: solid;
    border-color: #24292e transparent transparent transparent;
}

/* Primary Action Button */
.action-btn {
    width: 100%; 
    padding: 10px; 
    border: none; 
    border-radius: 6px;
    background: #2ea44f; 
    color: white; 
    font-weight: 600; 
    font-size: 13px;
    margin: 0;
}
.action-btn:hover { background: #2c974b; }

/* Danger/Exit Button */
.danger-link {
    width: 100%;
    color: #d73a49;
    font-size: 11px;
    font-weight: 600;
    background: #fff;
    border: 1px solid #d73a49;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}
.danger-link:hover { 
    background: #ffeef0;
}

/* --- Buttons --- */
button { cursor: pointer; transition: 0.2s; }
/* Removed #btn-export-map from here to let .btn-primary class handle it */
#btn-continue {
    width: 100%; padding: 8px; border: 1px solid #2ea44f; border-radius: 6px;
    background: #fff; color: #2ea44f; font-weight: 600; font-size: 12px;
}
#btn-continue:hover { background: #e6ffed; }
#btn-continue:disabled { border-color: #d1d5da; color: #959da5; cursor: not-allowed; background: #fff; }

.secondary-btn { width: 100%; padding: 8px; border: 1px solid #d1d5da; border-radius: 6px; background: #fff; color: #24292e; font-weight: 600; font-size: 13px; }
.secondary-btn:hover { background: #f6f8fa; border-color: #c0c4c8; }
.link-btn { display: block; margin: 10px auto 0; background: none; border: none; color: #0366d6; font-size: 12px; font-weight: 600; text-decoration: none; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* --- Tips Overlay --- */
.overlay { 
    background: #fff; 
    height: 100vh; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    z-index: 20; 
    overflow-y: auto; /* Enable vertical scrolling */
}
.tips-list li { margin-bottom: 12px; font-size: 13px; line-height: 1.4; }
#btn-close-tips { width: auto; padding: 5px 15px; border: 1px solid #ccc; background: #fff; border-radius: 4px; }

/* --- Layout Utilities for Phase 3 (Compact) --- */
.compact-footer {
    display: flex;
    flex-direction: column;
    gap: 8px; /* Tight vertical gap */
}

.footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #555;
    min-height: 24px;
}

/* Speed Row Specifics */
.speed-label-group {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-weight: 600;
    color: #444;
}

.flex-select {
    flex: 1; /* Default: Grow to fill space */
    width: 0; 
    padding: 4px;
    font-size: 11px;
    border: 1px solid #d1d5da;
    border-radius: 4px;
    background: #fff;
    height: 26px;
    transition: flex-grow 0.2s;
}

/* When Custom is selected, shrink the dropdown */
.flex-select.is-custom {
    flex: 0 0 auto; /* Stop growing, auto width based on content */
    width: auto;
    min-width: 80px; /* Minimum comfortable width for "Custom..." */
}

.mini-input {
    /* When visible, take remaining space */
    flex: 1; 
    padding: 4px;
    font-size: 11px;
    border: 1px solid #d1d5da;
    border-radius: 4px;
    font-family: monospace;
    height: 26px; 
    box-sizing: border-box;
}

/* Action Buttons Row */
.action-row {
    display: flex;
    gap: 8px;
    margin-top: 8px; /* Increased from 2px for better separation */
}

/* Ghost/Outline Green Button */
.btn-primary {
    width: 100%; /* Full width */
    padding: 8px;
    border: 1px solid #2ea44f;
    border-radius: 6px;
    background: #fff;
    color: #2ea44f;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary:hover { 
    background: #e6ffed; /* Light Green Tint (matches Linked badge) */
    color: #2ea44f; 
}

.btn-secondary {
    flex: 1; /* Equal Width */
    width: 100%;
    padding: 8px;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    background: #fff;
    color: #24292e; /* Neutral Text */
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 6px;
}
.btn-secondary:hover { background: #f6f8fa; border-color: #c0c4c8; }

/* Start Mode Radio Group */
.start-mode-group {
    text-align: left;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.mode-option {
    display: flex;
    flex-direction: column;
    padding: 7px 8px;
    border-radius: 5px;
    border: 1px solid #e1e4e8;
    background: #f6f8fa;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.mode-option:hover {
    border-color: #0366d6;
    background: #f1f8ff;
}
.mode-option-row {
    display: flex;
    align-items: center;
    gap: 7px;
}
.mode-option input[type="radio"] {
    margin: 0;
    flex-shrink: 0;
    accent-color: #0366d6;
    width: 13px;
    height: 13px;
    cursor: pointer;
}
.mode-option label {
    font-size: 12px;
    font-weight: 600;
    color: #24292e;
    cursor: pointer;
    margin: 0;
    display: block;
}
.mode-desc {
    color: #586069;
    font-size: 11px;
    margin-top: 3px;
    padding-left: 20px;
    line-height: 1.4;
}

/* End Point Badge (Text Only) */
.map-item .mode.is-end {
    color: #d73a49; /* Red */
    padding: 0;
    border: none;
}

/* --- VIEW 3 REFACTOR (v2.0) --- */

/* Parent Container State Utility */
.mode-playback .footer-edit, 
.mode-playback .edit-toolbar, 
.mode-playback .nav-btn#btn-nav-back, 
.mode-playback .master-switch-small,
.mode-playback .row-edit-ui {
    display: none !important;
}

.mode-edit .footer-playback, 
.mode-edit .playback-status-badge, 
.mode-edit .nav-btn#btn-nav-edit,
.mode-edit .row-playback-ui {
    display: none !important;
}

/* 1. Header Bar */
.director-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 10px 15px;
    border-bottom: 1px solid #e1e4e8;
    height: 40px;
    box-sizing: border-box;
    margin: -20px -20px 0 -20px; /* Counteract view-container padding */
}
.header-center { font-weight: 700; font-size: 13px; color: #24292e; }
.nav-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #0366d6;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.nav-btn:hover { background: #f1f8ff; }

/* 1. Master Switch (V1 Restored) */
.master-switch {
    border: none;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
    z-index: 2;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sync-deck.linked .master-switch {
    background: #e6ffed; color: #22863a; border: 1px solid #2ea44f;
}
.sync-deck.unlinked .master-switch {
    background: #f6f8fa; color: #57606a; border: 1px solid #d0d7de;
}
.master-switch:hover { transform: translateY(-1px); box-shadow: 0 3px 6px rgba(0,0,0,0.15); }

/* 2. Zone A adjustments */
.zone-a { padding-top: 0; } /* Remove padding, Deck touches top */

/* Deck Header Grid (Nav | Toggle | Space) */
.deck-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* Precise centering */
    align-items: center;
    width: 100%;
    margin-bottom: 5px;
}

/* Back Button (Embedded in Deck) */
.deck-back-btn {
    background: none;
    border: none;
    color: #0366d6;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    justify-self: start; /* Push to left */
    padding: 0;
}
.deck-back-btn:hover { text-decoration: underline; }

/* Hide Back button in Playback Mode */
.mode-playback .deck-back-btn { visibility: hidden; pointer-events: none; }

/* --- Creation Toolbar (V2.2) --- */
.mode-playback .edit-toolbar-container { display: none; }

.edit-toolbar-container {
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 8px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.toolbar-label {
    font-size: 9px;
    font-weight: 700;
    color: #959da5;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.toolbar-row {
    display: flex;
    gap: 8px; /* Wider gap for grid */
}
.tool-btn {
    flex: 1; /* 50% width each */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    padding: 9px; /* Slightly taller click target */
    font-size: 11px;
    font-weight: 600;
    color: #444; /* Slightly softer black */
    cursor: pointer;
    transition: all 0.2s;
}
.tool-btn:hover { background: #f6f8fa; border-color: #c0c4c8; }

/* Primary (Synced) - Ghost Blue */
.tool-btn.primary {
    background: #fff;
    color: #0366d6;
    border-color: #d1d5da; /* Standard Grey to avoid 'selected' look */
    font-weight: 600;
}
.tool-btn.primary:hover { 
    background: #f1f8ff; 
    border-color: #0366d6; /* Blue border only on hover */
}

/* Danger (End) - Grey Border, Red Text */
.tool-btn.danger { 
    color: #d73a49; 
    border-color: #d1d5da; /* Standard Grey */
}
.tool-btn.danger:hover { 
    background: #ffeef0; 
    border-color: #d73a49; /* Red border ONLY on hover */
}

/* --- Map List Updates --- */
.row-playback-ui .timestamps {
    display: grid;
    grid-template-columns: 55px auto; /* Fixed label width, auto time */
    column-gap: 8px;
    row-gap: 2px;
    font-size: 11px;
    margin-top: 4px;
}
.row-playback-ui .ts-label { font-weight: 600; color: #586069; }
.row-playback-ui .ts-val { font-family: monospace; color: #24292e; text-align: right; }

/* 3. Map List Items */
.map-item {
    cursor: pointer; /* Playback mode: Row is button */
    padding: 8px 12px;
}
.mode-edit .map-item { cursor: default; } /* Edit mode: Row is form */

/* Playback Row Styles */
.row-playback-ui {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.row-playback-ui .ts-val { font-size: 12px; font-family: monospace; color: #333; }
.row-playback-ui .mode-tag { 
    font-size: 10px; 
    font-weight: 700; 
    color: #24292e; /* Paused: Black text */
    text-transform: uppercase; 
    background: #f6f8fa; /* Paused: Grey BG */
    padding: 2px 5px;
    border-radius: 3px;
}
.row-playback-ui .mode-tag.is-synced { color: #0366d6; background: #f1f8ff; }
.row-playback-ui .mode-tag.is-end { color: #d73a49; background: #ffeef0; }

/* Edit Row Styles */
.row-edit-ui {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 5px;
    align-items: center;
}
.edit-field input {
    width: 100%;
    padding: 4px;
    font-size: 11px;
    font-family: monospace;
    border: 1px solid #d1d5da;
    border-radius: 3px;
}
.edit-actions-cell {
    display: flex;
    gap: 2px;
}
.mini-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #586069;
    border-radius: 3px;
}
.mini-icon-btn:hover { background: #e1e4e8; color: #0366d6; }
.mini-icon-btn.delete:hover { color: #d73a49; background: #ffeef0; }
.mini-icon-btn.test { color: #22863a; }

/* 4. Footer Tweaks */
.skew-group { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.skew-read-only { font-size: 11px; color: #586069; font-weight: 600; }

.speed-label-group { display: flex; align-items: center; gap: 4px; }
.small-label { font-size: 10px; font-weight: 600; color: #555; }

.centered { 
    justify-content: center; 
    margin-top: 4px; /* Visual separation for End Session */
}

/* --- V2.1 UI Updates --- */

/* List Header */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: #f6f8fa;
    border-bottom: 1px solid #e1e4e8;
    border-top: 1px solid #e1e4e8;
}
.list-title {
    font-size: 11px;
    font-weight: 700;
    color: #586069;
    text-transform: uppercase;
}

.list-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tips Button */
.tips-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #586069;
    padding: 4px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}
.tips-btn:hover {
    background: #e1e4e8;
    color: #24292e;
}

/* Edit Trigger Button */
.edit-mode-btn {
    background: #fff;
    border: 1px solid #d1d5da;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #0366d6;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.edit-mode-btn:hover {
    background: #f1f8ff;
    border-color: #0366d6;
}

/* Hide Edit Trigger in Edit Mode (Back button handles exit) */
.mode-edit .edit-mode-btn { display: none; }

/* --- Footer Row & Skew Control Specifics --- */
.footer-row {
    display: flex;
    align-items: center;
    gap: 8px; /* Maintain gap between items */
}

/* Speed label row — full width, label + ? on own line above the dropdown */
.speed-label-row {
    justify-content: flex-start;
    gap: 4px;
}

/* Select element sizing */
.flex-select {
    flex-grow: 1; /* Default: Allow it to grow */
    flex-shrink: 1; /* Allow it to shrink */
    flex-basis: 0;  /* Start from 0 to distribute space */
    min-width: 0;   /* Allow it to be flexible */
}

/* When Custom is selected, fix its width — keep tight to give input max space */
.flex-select.is-custom {
    flex-grow: 0;   /* Don't grow */
    flex-shrink: 0; /* Don't shrink */
    flex-basis: 68px;
    width: 68px;
}

/* Custom input field sizing */
.mini-input {
    flex-grow: 1;   /* Take up remaining space when visible */
    flex-shrink: 1; /* Allow it to shrink */
    flex-basis: 0;  /* Start from 0 for distribution */
    min-width: 0;   /* Allow it to be flexible */
}
/* --- View 2: Setup Fork (redesigned) --- */
.setup-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 10px 15px;
    background: #fff;
    border-bottom: 1px solid #e1e4e8;
    height: 40px;
    box-sizing: border-box;
}
.setup-header-title {
    font-size: 13px;
    font-weight: 700;
    color: #24292e;
    text-align: center;
}
.setup-body {
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f4f6f8;
    min-height: calc(100% - 40px);
    box-sizing: border-box;
}

.setup-zone {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.setup-zone-title {
    font-size: 13px;
    font-weight: 700;
    color: #24292e;
}
.setup-zone-desc {
    font-size: 11px;
    color: #586069;
    margin: 0;
}

/* Horizontal OR divider */
.setup-or-divider {
    display: flex;
    flex-direction: row;
    align-items: center;
    color: #586069;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    margin: 2px 0;
}
.setup-or-divider::before,
.setup-or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #d1d5da;
}
.setup-or-divider span {
    padding: 0 12px;
}


/* --- View 0: Sign-In Gate --- */
.signin-tagline {
    font-size: 12px;
    color: #586069;
    text-align: center;
    margin: 0 0 20px 0;
}

.btn-google-signin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: #ffffff;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #24292e;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.15s, border-color 0.15s;
}
.btn-google-signin:hover:not(:disabled) {
    background: #f6f8fa;
    border-color: #0366d6;
}
.btn-google-signin:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.google-logo {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.signin-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #d1d5da;
    border-top-color: #0366d6;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.signin-error {
    font-size: 11px;
    color: #d73a49;
    text-align: center;
    margin: 8px 0 0 0;
}

.signin-required-note {
    font-size: 11px;
    color: #586069;
    text-align: center;
    margin: 12px 0 0 0;
}

/* --- View 0b: Welcome Toast --- */

/* --- Profile icon + dropdown (persistent across Views 1, 2, 3) --- */
#profile-icon-wrap {
    position: fixed;
    top: 8px;
    right: 8px;
    z-index: 50;
}

.profile-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    background: #0366d6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-avatar-initials {
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1;
    pointer-events: none;
}

.profile-dropdown {
    position: absolute;
    top: 34px;
    right: 0;
    width: 200px;
    background: #ffffff;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    padding: 10px 0;
    z-index: 100;
}

.profile-dropdown-name {
    padding: 0 12px 2px;
    font-size: 13px;
    font-weight: 600;
    color: #24292e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-dropdown-email {
    padding: 0 12px 8px;
    font-size: 11px;
    color: #586069;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-dropdown-divider {
    height: 1px;
    background: #e1e4e8;
    margin: 4px 0;
}

.profile-dropdown-status {
    padding: 6px 12px;
    font-size: 11px;
    color: #586069;
}

.profile-dropdown-signout {
    display: block;
    width: 100%;
    padding: 6px 12px;
    text-align: left;
    background: none;
    border: none;
    font-size: 12px;
    color: #d73a49;
    cursor: pointer;
}

.profile-dropdown-signout:hover {
    background: #fff0f0;
}

/* ── View 5: Paywall ─────────────────────────────────────── */

.paywall-heading {
    font-size: 16px;
    font-weight: 600;
    color: #24292e;
    text-align: center;
    margin-top: 16px;
}

.paywall-date {
    font-size: 11px;
    color: #888;
    text-align: center;
    margin-top: 4px;
}

.paywall-body {
    font-size: 12px;
    color: #444;
    text-align: center;
    margin: 12px 16px 20px;
    line-height: 1.5;
}

.paywall-subscribe {
    display: block;
    width: calc(100% - 32px);
    margin: 0 16px;
}

.paywall-divider {
    height: 1px;
    background: #e1e4e8;
    margin: 20px 16px;
}

.paywall-link {
    display: block;
    width: 100%;
    background: none;
    border: none;
    font-size: 11px;
    color: #0366d6;
    text-align: center;
    cursor: pointer;
    padding: 2px 0;
}

.paywall-link:hover { text-decoration: underline; }

.paywall-refresh-msg {
    font-size: 11px;
    color: #666;
    text-align: center;
    margin-top: 6px;
    padding: 0 16px;
    line-height: 1.4;
}

.paywall-footer {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    padding-bottom: 8px;
}

.paywall-muted-link {
    background: none;
    border: none;
    font-size: 10px;
    color: #999;
    cursor: pointer;
    padding: 0;
}

.paywall-muted-link:hover { color: #555; text-decoration: underline; }

.loading-msg {
    text-align: center;
    color: #999;
    font-size: 13px;
    padding: 32px 16px;
    font-style: italic;
}

.snap-btn {
    display: inline;
    font-size: 9px;
    padding: 0px 4px;
    margin-left: 4px;
    color: #f59e0b;
    background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: 3px;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
    width: auto;
}

.snap-btn:hover {
    background: rgba(245,158,11,0.2);
}

.update-banner {
    background: #fff8e1;
    border-left: 3px solid #f59e0b;
    color: #92400e;
    font-size: 11px;
    font-weight: 600;
    padding: 8px 10px;
    margin-bottom: 10px;
    border-radius: 3px;
}

.update-banner a {
    color: #92400e;
    text-decoration: underline;
}

/* ── Share Script: action-row two-button layout ─────────────────────────── */
.btn-half {
    flex: 1;
    width: auto;
}

.btn-share {
    border-color: #0366d6;
    color: #0366d6;
}
.btn-share:hover {
    background: #f0f7ff;
    color: #0366d6;
}

/* ── Load from Link: setup view ─────────────────────────────────────────── */


.link-input {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 11px;
    font-family: inherit;
    color: #24292e;
    background: #fff;
    box-sizing: border-box;
    margin-top: 6px;
}
.link-input:focus {
    outline: none;
    border-color: #0366d6;
    box-shadow: 0 0 0 3px rgba(3,102,214,0.15);
}

/* ── Share Modal ─────────────────────────────────────────────────────────── */
.share-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.share-modal {
    background: #fff;
    border-radius: 10px;
    width: 320px;
    max-height: 480px;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
}

.share-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    border-bottom: 1px solid #e8ecef;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.share-modal-title {
    font-size: 13px;
    font-weight: 600;
    color: #24292e;
}

.share-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #586069;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}
.share-modal-close:hover { color: #24292e; }

.share-modal-body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.share-modal-hint {
    font-size: 11px;
    color: #586069;
    margin-bottom: 10px;
    line-height: 1.4;
}

.share-field-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #24292e;
    margin-top: 8px;
    margin-bottom: 3px;
}

.share-optional {
    font-weight: 400;
    color: #586069;
}

.share-required {
    color: #d73a49;
}

.share-inp {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 11px;
    font-family: inherit;
    color: #24292e;
    background: #fff;
    box-sizing: border-box;
}
.share-inp:focus {
    outline: none;
    border-color: #0366d6;
    box-shadow: 0 0 0 3px rgba(3,102,214,0.15);
}

.share-textarea {
    resize: vertical;
    min-height: 48px;
}

.share-upload-btn {
    margin-top: 12px;
}

.share-success-label {
    font-size: 11px;
    color: #586069;
    margin-bottom: 8px;
    font-weight: 600;
}

.share-link-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.share-link-display {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    font-size: 10px;
    font-family: monospace;
    color: #24292e;
    background: #f6f8fa;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-copy {
    padding: 6px 10px;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    background: #f6f8fa;
    color: #24292e;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn-copy:hover { background: #e8ecef; }

.share-copy-confirm {
    font-size: 11px;
    color: #2ea44f;
    margin-top: 6px;
    font-weight: 600;
}

.share-uploading-msg {
    font-size: 12px;
    color: #586069;
    text-align: center;
    padding: 20px 0;
}

/* ── Profile dropdown: neutral action items ──────────────────────────────── */
.profile-dropdown-action {
    display: block;
    width: 100%;
    padding: 6px 12px;
    text-align: left;
    background: none;
    border: none;
    font-size: 12px;
    color: #24292e;
    cursor: pointer;
}
.profile-dropdown-action:hover {
    background: #f6f8fa;
}

.profile-dropdown-action:disabled {
    color: #8b949e;
    cursor: default;
    background: none;
}
