:root {
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --text-main: #ffffff;
    --text-sub: #b0b0b0;
    --accent: #00e5ff;
    --card-radius: 16px;
    
    /* 可搭乘的顏色 (鮮豔綠) */
    --match-color: #00e676; 
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Segoe UI', Roboto, sans-serif;
    margin: 0; padding: 20px;
    box-sizing: border-box;
}

.app-container { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 15px; }

header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
h1 { margin: 0; font-size: 1.4rem; color: var(--text-main); }
.btn-icon { background: none; border: none; color: var(--accent); font-size: 1.4rem; cursor: pointer; padding: 5px; }

/* 定位區 */
.location-status {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    padding: 15px 20px;
    display: flex; align-items: center; gap: 15px;
    border: 1px solid #333;
}
.gps-icon-box {
    width: 45px; height: 45px; background: rgba(0, 229, 255, 0.1); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 1.2rem;
}
.gps-text { flex: 1; }
.gps-text .label { font-size: 0.75rem; color: var(--text-sub); text-transform: uppercase; }
.current-station { font-size: 1.6rem; font-weight: bold; color: #fff; margin: 2px 0; }
.direction-hint { font-size: 0.9rem; color: var(--accent); }
.btn-refresh { background: none; border: none; color: var(--text-sub); font-size: 1.1rem; cursor: pointer; }

.divider-text { font-size: 0.9rem; color: #555; margin-left: 5px; font-weight: bold; }

/* Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); 
    gap: 12px;
}
.grid-item {
    background: #2a2a2a; border-radius: 16px; aspect-ratio: 1 / 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s; border: 2px solid transparent; color: #eee;
}
.grid-item:hover { background: #333; transform: translateY(-2px); }
.grid-item:active { transform: scale(0.95); }
.grid-item i { font-size: 2rem; margin-bottom: 8px; color: var(--accent); }
.grid-item span { font-size: 1rem; font-weight: bold; text-align: center; }

.grid-item.add-new { border: 2px dashed #444; background: transparent; color: #666; }
.grid-item.add-new:hover { border-color: var(--accent); color: var(--accent); }
.grid-item.add-new:hover i { color: var(--accent); }

/* Results */
.results-container { display: flex; flex-direction: column; gap: 12px; }

.train-card {
    background: var(--bg-card); 
    border-left: 4px solid #333; /* 預設深色(不可搭) */
    padding: 15px 20px; border-radius: 8px;
    display: flex; justify-content: space-between; align-items: center;
    animation: fadeIn 0.4s ease;
    position: relative;
    overflow: hidden;
    opacity: 0.6; /* 預設讓不可搭的車稍微暗一點 */
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ★ 可搭乘的樣式 ★ */
.train-card.card-match {
    border-left-color: var(--match-color);
    opacity: 1; /* 可搭乘的車全亮 */
    background: #252525;
}

.match-badge {
    position: absolute;
    top: 0; left: 0;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-bottom-right-radius: 6px;
    font-weight: bold;
    color: #000;
    background-color: var(--match-color);
}

.train-main { margin-left: 5px; } 
.train-main h3 { margin: 0; font-size: 1.1rem; }
.train-details { font-size: 0.85rem; color: var(--text-sub); margin-top: 4px; }
.train-time-box { text-align: right; }
.t-time { font-size: 1.4rem; font-weight: bold; color: var(--text-main); }
.t-status { font-size: 0.8rem; padding: 2px 6px; border-radius: 4px; background: #333; color: #aaa; }
.t-status.late { background: rgba(255, 82, 82, 0.2); color: #ff5252; }
.t-status.ontime { color: #69f0ae; }

.loading-spinner { text-align: center; padding: 20px; color: var(--accent); }
.empty-state { text-align: center; color: var(--text-sub); padding: 30px; border: 2px dashed #333; border-radius: 16px; font-size: 0.9rem; }

/* Modal & Form (維持不變) */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); backdrop-filter: blur(4px); display: none; justify-content: center; align-items: center; z-index: 100; }
.modal-content { background: #1a1a1a; width: 85%; max-width: 400px; padding: 20px; border-radius: 16px; border: 1px solid #333; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; margin-bottom: 15px; color: white; align-items: center; }
.close-btn { background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }
.manage-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: #252525; margin-bottom: 8px; border-radius: 8px; }
.manage-info { display: flex; align-items: center; gap: 10px; color: #fff; flex: 1; }
.manage-actions { display: flex; gap: 5px; }
.btn-del, .btn-edit { width: 32px; height: 32px; border-radius: 6px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.btn-del { background: #333; color: #ff5252; } .btn-del:hover { background: #ff5252; color: white; }
.btn-edit { background: #333; color: var(--edit-color); } .btn-edit:hover { background: var(--edit-color); color: white; }
.form-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.btn-text-cancel { background: none; border: none; color: #888; cursor: pointer; font-size: 0.9rem; text-decoration: underline; } .btn-text-cancel:hover { color: #fff; }
.add-form input, .add-form select { width: 100%; padding: 12px; margin-bottom: 10px; background: #2a2a2a; border: 1px solid #444; color: #fff; border-radius: 8px; box-sizing: border-box; font-size: 1rem; }
.icon-selector { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 5px; margin-bottom: 15px; }
.icon-opt { min-width: 40px; height: 40px; background: #2a2a2a; border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 1px solid #444; color: #888; }
.icon-opt.selected { border-color: var(--accent); color: var(--accent); background: rgba(0,229,255,0.1); }
.btn-save { width: 100%; background: var(--accent); color: #000; border: none; padding: 12px; font-weight: bold; border-radius: 8px; cursor: pointer; font-size: 1rem; transition: 0.2s; } .btn-save.editing { background: var(--edit-color); color: white; }