/* ===== GPX Sail Explorer — app styles ===== */
html, body { height: 100%; }
body { overflow: hidden; }

.app {
	display: flex;
	flex-direction: column;
	height: 100vh;
}

/* Top bar */
.topbar {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 10px 18px;
	border-bottom: 1px solid var(--notion-border);
	background: var(--notion-surface);
	z-index: 1200;
	flex-wrap: wrap;
}
.topbar .brand {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 700;
	font-size: 16px;
	letter-spacing: -0.01em;
}
.topbar .brand .logo { font-size: 22px; }
.topbar .spacer { flex: 1; }
.topbar .hint { color: var(--notion-text-soft); font-size: 13px; }

.voyage-bar {
	display: flex;
	align-items: center;
	gap: 4px;
}
.voyage-sel {
	padding: 5px 8px;
	border: 1px solid var(--notion-border);
	border-radius: 6px;
	font-size: 13px;
	background: var(--notion-surface);
	color: var(--notion-text);
	max-width: 200px;
}
.voyage-btn {
	padding: 5px 10px;
	border: 1px solid var(--notion-border);
	border-radius: 6px;
	font-size: 14px;
	cursor: pointer;
	background: var(--notion-surface);
	color: var(--notion-text);
	line-height: 1;
}
.voyage-btn:hover { background: var(--notion-bg-soft); }
.voyage-btn-del { font-size: 13px; }

.file-btn {
	position: relative;
	overflow: hidden;
}
.file-btn input[type=file] {
	position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0;
}

/* Layout */
.body {
	flex: 1;
	display: flex;
	min-height: 0;
}
#map {
	flex: 1;
	min-width: 0;
	height: 100%;
	background: #aadaff;
}
.sidebar {
	width: 380px;
	max-width: 42vw;
	border-left: 1px solid var(--notion-border);
	background: var(--notion-bg-soft);
	overflow-y: auto;
	padding: 16px 16px 40px;
}

.panel {
	background: var(--notion-surface);
	border: 1px solid var(--notion-border-soft);
	border-radius: 12px;
	padding: 14px;
	margin-bottom: 14px;
	box-shadow: var(--notion-shadow);
}
.panel h3 {
	display: flex; align-items: center; gap: 8px;
	font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em;
	color: var(--notion-text-soft); margin: 0 0 12px;
}

/* Segmented control for metric */
.segmented {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 6px;
}
.segmented label {
	margin: 0;
	display: flex; align-items: center; justify-content: center; gap: 6px;
	padding: 9px 8px;
	border: 1px solid var(--notion-border);
	border-radius: 8px;
	font-size: 13px; font-weight: 600;
	color: var(--notion-text-soft);
	cursor: pointer;
	text-align: center;
	transition: all 120ms;
	user-select: none;
}
.segmented input { display: none; }
.segmented label:hover { background: var(--notion-surface-hover); }
.segmented input:checked + label,
.segmented label.active {
	border-color: var(--notion-blue);
	color: var(--notion-blue);
	background: var(--notion-blue-bg);
}

/* Legend / color bar */
.legend-bar {
	height: 12px; border-radius: 6px; margin: 4px 0 6px;
	border: 1px solid var(--notion-border-soft);
}
.legend-scale {
	display: flex; justify-content: space-between;
	font-size: 12px; color: var(--notion-text-soft);
}
.legend-unit { font-size: 12px; color: var(--notion-text-faint); margin-top: 2px; }

/* Stat grid */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
	background: var(--notion-bg-soft);
	border: 1px solid var(--notion-border-soft);
	border-radius: 10px;
	padding: 10px 12px;
}
.stat .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--notion-text-faint); }
.stat .val { font-size: 20px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.stat .val small { font-size: 12px; font-weight: 500; color: var(--notion-text-soft); }
.stat.hoverable { cursor: pointer; transition: border-color .12s, background .12s; }
.stat.hoverable:hover { border-color: #c0392b; background: var(--notion-bg); }
.stat.hoverable .lbl::after { content: ' ⌖'; color: #c0392b; opacity: .65; }

/* Track list */
.track-row {
	display: flex; align-items: center; gap: 10px;
	padding: 8px 6px; border-radius: 8px;
}
.track-row:hover { background: var(--notion-surface-hover); }
.track-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.track-meta { flex: 1; min-width: 0; }
.track-meta .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-meta .sub { font-size: 11px; color: var(--notion-text-soft); }
.tr-btn { background: transparent; border: none; cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 4px; flex: none; border-radius: 6px; color: var(--notion-text-soft); }
.tr-btn:hover { background: var(--notion-surface-hover); color: var(--notion-text); }
.track-row.is-hidden { opacity: .45; }
.track-row.is-hidden .track-swatch { filter: grayscale(1); }

.media-row {
	display: flex; align-items: center; gap: 8px;
	padding: 5px 8px; border-radius: 8px; cursor: default;
	transition: background .12s;
}
.media-row:hover { background: var(--notion-surface-hover); }
.media-row .media-icon { font-size: 16px; flex: none; width: 22px; text-align: center; }
.media-row .media-info { flex: 1; min-width: 0; }
.media-row .media-info .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-row .media-info .sub { font-size: 11px; color: var(--notion-text-soft); }
.media-row.is-hidden { opacity: .45; }

/* Collapsible media sections */
.media-section { margin-bottom: 4px; }
.media-section-head {
	display: flex; align-items: center; gap: 6px;
	padding: 6px 8px; border-radius: 8px;
	font-size: 13px; font-weight: 600;
	cursor: pointer; user-select: none;
	transition: background .12s;
}
.media-section-head:hover { background: var(--notion-surface-hover); }
.media-section-head.is-hidden { opacity: .5; }
.media-chevron { font-size: 10px; width: 14px; text-align: center; color: var(--notion-text-soft); flex: none; }
.media-section-label { flex: 1; }
.media-eye-btn {
	flex: none; background: transparent; border: none;
	cursor: pointer; font-size: 14px; line-height: 1;
	padding: 2px 4px; flex: none; border-radius: 6px;
	color: var(--notion-text-soft);
}
.media-eye-btn:hover { background: var(--notion-surface-hover); color: var(--notion-text); }
.media-del-btn {
	flex: none; background: transparent; border: none;
	cursor: pointer; font-size: 14px; line-height: 1;
	padding: 2px 4px; flex: none; border-radius: 6px;
	color: var(--notion-text-soft);
}
.media-del-btn:hover { background: var(--notion-surface-hover); color: var(--notion-text); }
.media-section-body { padding-left: 20px; }

/* Chart */
.chart-wrap { position: relative; }
canvas.chart { width: 100%; height: 150px; display: block; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--notion-text-soft); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

/* Empty / loading states */
.empty {
	position: absolute; inset: 0; z-index: 500;
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	text-align: center; gap: 14px; padding: 24px;
	background: linear-gradient(180deg, #cfeaff, #aadaff);
	color: #0b3a5b;
	pointer-events: none;
}
.empty .big { font-size: 54px; }
.empty h2 { font-size: 26px; margin: 0; color: #0b3a5b; letter-spacing: -0.02em; }
.empty p { max-width: 420px; margin: 0; color: #195b82; }
.empty .drop-cta {
	pointer-events: auto;
	margin-top: 6px; background: var(--notion-blue); color:#fff; border-radius: 10px;
	padding: 12px 22px; font-weight: 600; position: relative; overflow: hidden; cursor: pointer;
	box-shadow: 0 6px 18px rgba(39,131,222,.35);
}
.empty .drop-cta input { position:absolute; inset:0; opacity:0; cursor:pointer; }

/* Ohne geladene Tracks: rechte Spalte ausblenden, Karte nimmt die volle Fläche ein */
.app.no-tracks .sidebar { display: none; }
.app.no-tracks .topbar #shareBtn, .app.no-tracks .topbar #clearBtn { display: none; }

.toast {
	position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
	background: #191918; color: #fff; padding: 10px 18px; border-radius: 10px;
	font-size: 13px; z-index: 3000; box-shadow: 0 8px 24px rgba(0,0,0,.25);
	opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; }

.upload-bar {
	position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 9999;
	background: rgba(0,0,0,.08);
}
.upload-bar-inner {
	height: 100%; width: 0%; background: var(--notion-blue);
	transition: width .3s ease; border-radius: 0 2px 2px 0;
}
.upload-bar-text {
	position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
	font-size: 12px; font-weight: 600; color: var(--notion-text-soft);
	white-space: nowrap;
}

.loading-ov {
	position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
	z-index: 900; background: var(--notion-surface); border: 1px solid var(--notion-border);
	border-radius: 999px; padding: 8px 16px; font-size: 13px; font-weight: 600;
	box-shadow: var(--notion-shadow); display: none; align-items: center; gap: 10px;
}
.loading-ov.show { display: inline-flex; }
.spinner {
	width: 14px; height: 14px; border-radius: 50%;
	border: 2px solid var(--notion-border); border-top-color: var(--notion-blue);
	animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.switch-row label { margin: 0; font-weight: 500; font-size: 13px; }

.point-tip { font-size: 12px; line-height: 1.5; }
.point-tip b { color: var(--notion-text); }

.src-note { font-size: 11px; color: var(--notion-text-faint); margin-top: 8px; line-height: 1.5; }
.src-note a { color: var(--notion-text-soft); }

@media (max-width: 760px) {
	.body { flex-direction: column; }
	.sidebar { width: 100%; max-width: none; max-height: 48vh; border-left: none; border-top: 1px solid var(--notion-border); }
	#map { min-height: 240px; }
	.app.no-tracks .body { display: block; height: 100%; }
	.app.no-tracks #map { height: 100%; min-height: 0; }
}

/* ===== v2 additions ===== */
.cond-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cond {
	background: var(--notion-bg-soft);
	border: 1px solid var(--notion-border-soft);
	border-radius: 10px; padding: 12px;
	display: flex; flex-direction: column; gap: 6px;
}
.cond .cond-head { font-size: 12px; font-weight: 600; color: var(--notion-text-soft); display:flex; align-items:center; gap:6px; }
.cond .cond-main { font-size: 22px; font-weight: 700; line-height: 1.1; }
.cond .cond-main small { font-size: 12px; font-weight: 600; color: var(--notion-text-soft); }
.cond .cond-sub { font-size: 12px; color: var(--notion-text-soft); }
.cond .cond-dir { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.cond .compass { flex: none; }
.cond .dir-txt { font-size: 13px; font-weight: 600; }
.cond .dir-txt small { font-weight: 500; color: var(--notion-text-soft); }
.bft { font-size: 11px; font-weight: 600; color:#fff; background: var(--notion-blue); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }

#condCtx { font-size: 11px; font-weight: 500; color: var(--notion-text-faint); text-transform: none; letter-spacing: 0; }

.status-line { font-size: 12px; color: var(--notion-text-soft); display:flex; align-items:flex-start; gap:6px; margin-top:4px; line-height:1.45; }
.status-line .dot { width:8px; height:8px; border-radius:50%; margin-top:5px; flex:none; background: var(--notion-text-faint); }
.status-line.ok .dot { background:#2b8a3e; }
.status-line.warn .dot { background:#d5803b; }
.status-line.err .dot { background:#c0392b; }

.tile-badge {
	position:absolute; bottom:12px; left:12px; z-index:900;
	background:#fff3cd; color:#7a5b00; border:1px solid #ffe08a;
	border-radius:8px; padding:8px 12px; font-size:12px; max-width:320px;
	box-shadow: var(--notion-shadow); display:none;
}
.tile-badge.show { display:block; }

.leaflet-tooltip.sail-tip { font-size:12px; line-height:1.5; }

/* Leaflet layer control + popups: force readable colors regardless of theme */
.leaflet-control-layers{background:#fff !important;color:#1b1b1b !important;border:1px solid rgba(0,0,0,.18) !important;border-radius:8px !important;box-shadow:0 2px 8px rgba(0,0,0,.18) !important;padding:6px 8px !important;}
.leaflet-control-layers-expanded{padding:8px 10px !important;}
.leaflet-control-layers label,.leaflet-control-layers span,.leaflet-control-layers a{color:#1b1b1b !important;font-size:13px !important;line-height:1.5 !important;}
.leaflet-control-layers-list{color:#1b1b1b !important;}
.leaflet-control-layers-separator{border-top:1px solid rgba(0,0,0,.15) !important;}
.leaflet-control-layers-toggle{background-color:#fff !important;}
.leaflet-bar a,.leaflet-bar a:hover{color:#1b1b1b !important;background:#fff !important;}
.leaflet-control-attribution{background:rgba(255,255,255,.8) !important;color:#333 !important;}
.leaflet-control-attribution a{color:#2783de !important;}
.leaflet-control-scale-line{color:#222 !important;background:rgba(255,255,255,.7) !important;border-color:#999 !important;}
.hover-tip{font-size:12px;line-height:1.45;color:#1b1b1b;background:#fff;border:1px solid rgba(0,0,0,.15);border-radius:8px;box-shadow:0 2px 10px rgba(0,0,0,.2);padding:6px 9px;}
.hover-tip b{color:#111;}
.leaflet-tooltip.hover-tip:before{border-top-color:#fff;}

/* ===== Media markers + Lightbox ===== */
.media-marker {
	width: 32px; height: 32px; border-radius: 50%;
	background: #fff; border: 2px solid #2783de;
	display: flex; align-items: center; justify-content: center;
	font-size: 16px; cursor: pointer;
	box-shadow: 0 2px 8px rgba(0,0,0,.25);
	transition: transform .15s, box-shadow .15s;
}
.media-marker.video-marker { border-color: #e64545; }
.media-marker:hover {
	transform: scale(1.2);
	box-shadow: 0 4px 14px rgba(0,0,0,.35);
}

.lightbox {
	position: fixed; inset: 0; z-index: 5000;
	background: rgba(0,0,0,.92);
	display: none; align-items: center; justify-content: center;
	flex-direction: column;
}
.lightbox.show { display: flex; }

.lb-close {
	position: absolute; top: 16px; right: 20px; z-index: 5010;
	background: rgba(255,255,255,.12); color: #fff; border: none;
	border-radius: 50%; width: 44px; height: 44px; font-size: 22px;
	cursor: pointer; display: flex; align-items: center; justify-content: center;
	transition: background .15s;
}
.lb-close:hover { background: rgba(255,255,255,.25); }

.lb-nav {
	position: absolute; top: 50%; z-index: 5010;
	transform: translateY(-50%);
	background: rgba(255,255,255,.1); color: #fff; border: none;
	border-radius: 12px; width: 52px; height: 52px; font-size: 32px;
	cursor: pointer; display: flex; align-items: center; justify-content: center;
	transition: background .15s;
}
.lb-nav:hover { background: rgba(255,255,255,.22); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }

.lb-body {
	max-width: 90vw; max-height: 85vh;
	display: flex; flex-direction: column; align-items: center;
}
.lb-img {
	max-width: 90vw; max-height: 80vh;
	border-radius: 8px;
	box-shadow: 0 8px 40px rgba(0,0,0,.5);
	object-fit: contain;
}
.lb-video {
	max-width: 90vw; max-height: 80vh;
	border-radius: 8px;
	box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.lb-bar {
	display: flex; justify-content: space-between; align-items: center;
	width: 100%; padding: 10px 4px 0;
	color: rgba(255,255,255,.75); font-size: 13px;
}
.lb-caption { font-weight: 600; }
.lb-counter { opacity: .7; }

@media (max-width: 600px) {
	.lb-nav { width: 40px; height: 40px; font-size: 24px; }
	.lb-prev { left: 8px; }
	.lb-next { right: 8px; }
}

/* ===== Auth Modal / Inline ===== */
.auth-modal {
	display: none; align-items: center; justify-content: center;
}
.auth-modal.show { display: flex; }

/* Inline mode: when not logged in, auth replaces body content */
.app.logged-out .body > div:first-child,
.app.logged-out .sidebar {
	display: none !important;
}
.app.logged-out .auth-modal {
	position: static;
	background: linear-gradient(180deg, #cfeaff, #aadaff);
	flex: 1;
	z-index: auto;
	display: flex;
	align-items: center;
	justify-content: center;
}
.app.logged-out .auth-modal .auth-card {
	width: 400px;
	max-width: 90vw;
	box-shadow: 0 8px 32px rgba(0,0,0,.15);
}

/* Modal mode: overlay for re-auth or other use */
.auth-modal.modal-mode {
	position: fixed; inset: 0; z-index: 6000;
	background: rgba(0,0,0,.55);
}
.auth-modal.modal-mode.show { display: flex; }

.auth-card {
	background: var(--notion-surface);
	border: 1px solid var(--notion-border);
	border-radius: 14px;
	padding: 28px 24px;
	width: 360px; max-width: 90vw;
	box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.auth-card h3 {
	margin: 0 0 18px;
	font-size: 18px; font-weight: 700;
	text-align: center; color: var(--notion-text);
}
.auth-field {
	margin-bottom: 14px;
}
.auth-field label {
	display: block; margin-bottom: 4px;
	font-size: 12px; font-weight: 600; color: var(--notion-text-soft);
}
.auth-field input {
	width: 100%; padding: 9px 12px;
	border: 1px solid var(--notion-border);
	border-radius: 8px; font-size: 14px;
	background: var(--notion-bg); color: var(--notion-text);
	box-sizing: border-box;
}
.auth-field input:focus {
	outline: none; border-color: var(--notion-blue);
	box-shadow: 0 0 0 2px var(--notion-blue-bg);
}
.auth-error {
	color: #c0392b; font-size: 13px; min-height: 18px;
	margin-bottom: 8px; text-align: center;
}
.auth-submit {
	width: 100%; padding: 10px;
	background: var(--notion-blue); color: #fff;
	border: none; border-radius: 8px;
	font-size: 14px; font-weight: 600;
	cursor: pointer; transition: opacity .15s;
}
.auth-submit:hover { opacity: .9; }
.auth-submit:disabled { opacity: .5; cursor: default; }
.auth-switch {
	margin-top: 14px; text-align: center;
	font-size: 13px; color: var(--notion-text-soft);
}
.auth-switch button {
	background: none; border: none; color: var(--notion-blue);
	font-size: 13px; font-weight: 600; cursor: pointer; padding: 0;
	border-radius: 0;
}
.auth-switch button:hover { background: none; color: var(--notion-text); }

/* ===== User bar ===== */
.user-bar {
	display: flex; align-items: center; gap: 8px;
}
.user-email {
	font-size: 13px; color: var(--notion-text-soft);
	max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ===== Share dropdown ===== */
.share-wrap { position: relative; }
.share-dropdown {
	position: absolute; top: 100%; right: 0; margin-top: 4px;
	background: var(--notion-surface);
	border: 1px solid var(--notion-border);
	border-radius: 10px;
	padding: 6px;
	min-width: 220px;
	box-shadow: 0 8px 24px rgba(0,0,0,.18);
	display: none; z-index: 1300;
}
.share-dropdown.show { display: block; }
.share-option {
	display: block; width: 100%; text-align: left;
	padding: 8px 12px; border: none; border-radius: 6px;
	background: none; font-size: 13px; color: var(--notion-text);
	cursor: pointer; transition: background .12s;
}
.share-option:hover { background: var(--notion-bg-soft); }
.share-stop { color: #c0392b; }
.share-sep { height: 1px; background: var(--notion-border-soft); margin: 4px 8px; }
.share-expiry {
	display: flex; align-items: center; gap: 8px;
	padding: 6px 12px; font-size: 12px; color: var(--notion-text-soft);
}
.share-expiry select {
	padding: 3px 6px; border: 1px solid var(--notion-border);
	border-radius: 5px; font-size: 12px;
	background: var(--notion-bg); color: var(--notion-text);
}
.share-links { padding: 0 4px; }
.share-link-entry {
	display: flex; align-items: center; gap: 6px;
	padding: 6px 8px; border-radius: 6px;
	font-size: 12px; color: var(--notion-text-soft);
	cursor: pointer;
}
.share-link-entry:hover { background: var(--notion-bg-soft); }
.share-link-info { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-link-del {
	flex: none; background: none; border: none;
	cursor: pointer; font-size: 13px; line-height: 1;
	padding: 2px 4px; border-radius: 4px;
	color: var(--notion-text-soft); opacity: .5;
	transition: opacity .15s;
}
.share-link-del:hover { opacity: 1; color: #c0392b; }
