/* OrbitBay — clean light design system (devbay family) */
:root {
    --bg: #f8fafc;
    --bg-soft: #f1f5f9;
    --text: #0f172a;
    --text-dim: #64748b;
    --text-faint: #94a3b8;
    --card: #ffffff;
    --card-strong: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --accent-1: #6366f1;
    --accent-2: #4f46e5;
    --accent-3: #818cf8;
    --accent-soft: rgba(99, 102, 241, 0.08);
    --accent-border: rgba(99, 102, 241, 0.35);
    --good: #10b981;
    --good-soft: rgba(16, 185, 129, 0.1);
    --warn: #d97706;
    --warn-soft: rgba(245, 158, 11, 0.14);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.08);
    --radius: 0.625rem;
    --radius-sm: 0.5rem;
    --shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
    --shadow-hover: 0 4px 12px 0 rgba(15, 23, 42, 0.08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
            "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --text-faint: #64748b;
    --card: #1e293b;
    --card-strong: #0f172a;
    --border: #334155;
    --border-strong: #475569;
    --accent-1: #818cf8;
    --accent-2: #a5b4fc;
    --accent-3: #6366f1;
    --accent-soft: rgba(129, 140, 248, 0.14);
    --accent-border: rgba(129, 140, 248, 0.45);
    --good: #34d399;
    --good-soft: rgba(52, 211, 153, 0.12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.1);
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px 0 rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}

.container { width: min(1100px, 94vw); margin: 0 auto; }

/* ---------- header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-logo { display: flex; }
.brand-name { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-accent { color: var(--accent-1); }
.nav-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    background: var(--card); border: 1px solid var(--border);
    color: var(--text-dim); cursor: pointer; transition: all 0.15s ease;
    font-family: inherit;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-strong); }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.lang-select {
    appearance: none; -webkit-appearance: none;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-dim);
    font-family: inherit; font-size: 0.8rem; font-weight: 600;
    padding: 8px 28px 8px 12px; cursor: pointer; transition: all 0.15s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
.lang-select:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 48px 0 26px; }
.hero-title {
    font-size: clamp(1.9rem, 4.6vw, 2.9rem);
    font-weight: 800; letter-spacing: -0.03em; line-height: 1.15;
}
.hero-title em {
    font-style: normal;
    background: linear-gradient(90deg, var(--accent-1), var(--accent-3));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub {
    margin: 14px auto 0; max-width: 620px;
    color: var(--text-dim); font-size: 1.02rem;
}

/* ---------- cards & forms ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.card-title { font-size: 1.02rem; font-weight: 700; letter-spacing: -0.01em; }

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s ease; white-space: nowrap;
    border: 1px solid transparent;
}
.btn-primary {
    background: var(--accent-1); color: #fff;
    border-color: var(--accent-1);
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost {
    background: var(--card); color: var(--text-dim);
    border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-strong); }
.btn.busy { background: var(--accent-soft); color: var(--accent-1); }

label { font-size: 0.76rem; font-weight: 600; color: var(--text-dim); text-transform: none; }
input[type="number"], select {
    font-family: inherit;
    background: var(--card); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px 10px; font-size: 0.9rem; width: 100%;
    transition: border-color 0.15s ease;
}
input[type="number"]:focus, select:focus, input[type="text"]:focus, textarea:focus {
    outline: none; border-color: var(--accent-3);
}

/* ---------- location card ---------- */
.loc-grid {
    display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
}
.loc-grid .btn { padding: 8px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field input { min-width: 130px; }
.field-minel select { min-width: 92px; }
.loc-status {
    margin-top: 10px; font-size: 0.84rem; color: var(--text-dim);
    min-height: 1.2em;
}
.loc-status.approx { color: var(--warn); }

/* ---------- satellite card ---------- */
.sat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sat-title { font-size: 1.02rem; font-weight: 700; }
.sat-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sat-search { position: relative; flex: 0 1 280px; }
.sat-search input[type="text"] {
    font-family: inherit; font-size: 0.88rem;
    background: var(--card); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px 12px; width: 100%;
}
.sat-search input[type="text"]::placeholder { color: var(--text-faint); }
.search-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-hover);
    max-height: 300px; overflow-y: auto; z-index: 40;
}
.sr-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 12px; font-size: 0.87rem; cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: var(--accent-soft); }
.sr-item.loading, .sr-item.empty { color: var(--text-faint); cursor: default; }
.sr-item b { color: var(--accent-1); font-weight: 700; }
.sr-catnr { color: var(--text-faint); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 12px; border-radius: 999px;
    background: var(--card); border: 1px solid var(--border);
    color: var(--text-dim); font-family: inherit; font-size: 0.83rem;
    font-weight: 600; cursor: pointer; transition: all 0.15s ease;
    max-width: 100%;
}
.chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on { background: var(--accent-soft); border-color: var(--accent-border); color: var(--text); }
.chip .chip-x { font-size: 0.7rem; color: var(--text-faint); }
.chip .chip-x:hover { color: var(--danger); }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip.extra.on .chip-name { color: var(--accent-2); font-weight: 600; }

.scan-progress { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.scan-progress[hidden] { display: none; }
.progress-bar {
    flex: 1; height: 6px; border-radius: 999px;
    background: var(--bg-soft); overflow: hidden; max-width: 320px;
}
.progress-fill {
    height: 100%; width: 0%; border-radius: 999px;
    background: var(--accent-1); transition: width 0.3s ease;
}
.scan-text { font-size: 0.84rem; color: var(--text-dim); }

.tle-status { margin-top: 10px; font-size: 0.82rem; color: var(--text-faint); min-height: 1.2em; }
.tle-status.loading { color: var(--accent-1); }
.tle-status.error { color: var(--danger); }

/* ---------- main grid ---------- */
.grid-main {
    display: grid; grid-template-columns: 1fr; gap: 18px;
}
.grid-main > .card { min-width: 0; }
@media (min-width: 1080px) {
    .grid-main { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
}

/* ---------- sky chart ---------- */
.chart-wrap { display: flex; justify-content: center; }
#skycanvas { width: 100%; max-width: 560px; min-width: 0; display: block; touch-action: none; }
.live-badge {
    background: var(--danger); color: #fff;
    font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em;
    padding: 3px 9px; border-radius: 999px; display: inline-flex; align-items: center;
}
.live-badge[hidden] { display: none; }
.live-badge::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: #fff; margin-right: 5px;
    animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.chart-legend {
    display: flex; align-items: center; justify-content: center;
    gap: 8px 20px; flex-wrap: wrap; margin-top: 8px;
    font-size: 0.78rem; color: var(--text-dim);
}
.legend-line { display: inline-block; width: 26px; height: 3px; border-radius: 2px; vertical-align: middle; }
.legend-live { background: var(--accent-1); }
.legend-dim { background: var(--text-faint); }
.chart-hint {
    margin-top: 10px; text-align: center;
    font-size: 0.85rem; color: var(--text-dim); min-height: 1.3em;
}

/* ---------- passes ---------- */
.night-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.8rem; color: var(--text-dim); cursor: pointer; user-select: none;
}
.night-toggle input { accent-color: var(--accent-1); cursor: pointer; }

.now-strip {
    display: flex; align-items: center; gap: 9px;
    background: var(--bg-soft); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 9px 13px;
    font-size: 0.88rem; color: var(--text-dim); margin-bottom: 12px;
}
.now-strip[hidden] { display: none; }
.now-strip.live {
    background: var(--good-soft); border-color: rgba(16, 185, 129, 0.3);
    color: var(--text);
}
.now-dot {
    width: 9px; height: 9px; border-radius: 50%; flex: none;
    background: var(--accent-1);
}
.now-strip.live .now-dot { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.now-strip strong { color: var(--text); }
.now-coords { color: var(--text-dim); }
.now-till { margin-left: auto; font-weight: 600; color: var(--good); white-space: nowrap; }

.table-wrap { overflow-x: auto; }
.pass-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.pass-table thead th {
    text-align: left; font-size: 0.7rem; font-weight: 700;
    color: var(--text-faint); letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 6px 10px 8px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.pass-table td {
    padding: 7px 10px; border-bottom: 1px solid var(--border);
    vertical-align: middle; white-space: nowrap;
}
.pass-table tbody tr { cursor: pointer; transition: background 0.12s ease; }
.pass-table tbody tr:hover { background: var(--bg-soft); }
.pass-table tbody tr.pinned { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent-1); }
.pass-table tbody tr:last-child td { border-bottom: none; }
.pass-table .col-sat { min-width: 150px; max-width: 220px; }
.sat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.sat-name { font-weight: 600; }
.col-start .sub { display: block; font-size: 0.72rem; color: var(--text-faint); font-weight: 500; }
.col-from .dir { font-weight: 700; }
.col-from .azdeg { color: var(--text-faint); font-size: 0.72rem; margin-left: 5px; }
.max.high { color: var(--good); font-weight: 800; }
.max { font-weight: 700; }
.max.low { color: var(--text-dim); }
.vis-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.vis-dot.night { background: var(--good); }
.vis-dot.twilight { background: var(--warn); }
.vis-dot.day { background: var(--text-faint); }
.live-chip {
    margin-left: 8px; background: var(--danger); color: #fff;
    font-size: 0.62rem; font-weight: 800; letter-spacing: 0.05em;
    padding: 2px 7px; border-radius: 999px; vertical-align: 1px;
}
.pass-count { margin-top: 10px; font-size: 0.8rem; color: var(--text-faint); }
.empty-state {
    padding: 26px 10px; text-align: center;
    color: var(--text-faint); font-size: 0.9rem;
}
.empty-state p + p { margin-top: 6px; font-size: 0.82rem; }
#pass-table[style*="display: none"] + .empty-state { display: block; }

/* ---------- tips ---------- */
.tips-card details summary {
    cursor: pointer; font-weight: 700; font-size: 0.95rem;
    list-style: none; display: flex; align-items: center; gap: 8px;
    color: var(--text);
}
.tips-card details summary::-webkit-details-marker { display: none; }
.tips-card details summary::before {
    content: '›'; display: inline-block; color: var(--accent-1);
    font-weight: 800; transition: transform 0.15s ease;
}
.tips-card details[open] summary::before { transform: rotate(90deg); }
.tips-list { margin: 12px 0 0 22px; color: var(--text-dim); font-size: 0.88rem; }
.tips-list li { margin-bottom: 7px; }

/* ---------- modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(15, 23, 42, 0.45);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    animation: fadeIn 0.15s ease;
}
.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-hover);
    width: min(560px, 100%); padding: 22px;
}
.modal-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 6px; }
.modal-sub { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 14px; }
#tle-input {
    width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem; line-height: 1.5;
    background: var(--card); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; resize: vertical; min-height: 110px;
}
.modal-err { color: var(--danger); font-size: 0.84rem; margin-top: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 30px; background: var(--bg); }
.footer-inner {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 24px; flex-wrap: wrap; padding: 26px 0;
}
.footer-tag { color: var(--text-dim); font-size: 0.85rem; margin-top: 4px; }
.footer-meta { color: var(--text-faint); font-size: 0.78rem; text-align: right; line-height: 1.8; }

/* ---------- misc ---------- */
.hidden { display: none !important; }

@media (max-width: 760px) {
    .footer-inner { flex-direction: column; }
    .footer-meta { text-align: left; }
    .field input { min-width: 0; width: 100%; }
    .loc-grid { align-items: stretch; }
    .loc-grid .btn { justify-content: center; }
    .sat-actions { width: 100%; }
    .sat-search { flex: 1 1 100%; }
    .pass-table .col-sat { min-width: 120px; max-width: 150px; }
    .pass-table th.col-len, .pass-table td.col-len { display: none; }
}
