/* CR Sky Tracker – Curious Research */
.crst-app {
	/* Curious Research dark palette (from the logo); the plugin also sets these inline. */
	--crst-strong: #8734bd;
	--crst-accent: #b282d1;
	--crst-accent-2: #d6c4e1;
	--crst-on-accent: #ffffff;
	--crst-bg: #150c1d;
	--crst-panel: #22122f;
	--crst-field: #0f0815;
	--crst-line: #432259;
	--crst-hover: #371b4b;
	--crst-text: #f1eaf6;
	--crst-muted: #b3a5c0;
	--crst-chart-bg: #0a0814;
	--crst-good: #5fd98a;
	--crst-fair: #ffc24d;
	--crst-bad: #ff7676;
	--crst-warn: #ffab70;
	color-scheme: dark;
	--crst-map-h: 640px;
	background: var(--crst-bg);
	color: var(--crst-text);
	border: 1px solid var(--crst-line);
	box-shadow: 0 6px 28px rgba(21, 12, 29, .35);
	border-radius: 12px;
	padding: 16px;
	font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	box-sizing: border-box;
	/* Never wider than the theme's content column, whatever the theme does. */
	width: 100%;
	max-width: 100%;
	min-width: 0;
	overflow-x: hidden;
	overflow-wrap: anywhere;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}
/* Neutralise common theme rules that widen tables, images and form fields. */
.crst-app table { margin: 0; table-layout: auto; max-width: 100%; border: 0; background: transparent; }
.crst-app th, .crst-app td { border-top: 0; border-left: 0; border-right: 0; background-color: transparent; }
.crst-app img, .crst-app canvas { max-width: 100%; }
.crst-app input, .crst-app select, .crst-app button { max-width: 100%; margin: 0; }
.crst-app h2, .crst-app h3, .crst-app h4, .crst-app h5, .crst-app p { overflow-wrap: anywhere; }
.crst-app *, .crst-app *::before, .crst-app *::after { box-sizing: border-box; }
.crst-app [hidden] { display: none !important; }
.crst-app a { color: var(--crst-accent); }
.crst-loading { padding: 40px; text-align: center; color: var(--crst-muted); }

/* Header / branding */
.crst-head { display: flex; align-items: center; gap: 18px; padding: 4px 4px 14px; border-bottom: 3px solid var(--crst-strong); margin-bottom: 14px; flex-wrap: wrap; }
.crst-logo { filter: drop-shadow(0 0 1px rgba(255, 255, 255, .35)) drop-shadow(0 0 10px rgba(178, 130, 209, .28)); height: 92px; width: auto; max-width: min(520px, 100%); object-fit: contain; display: block; }
.crst-titles { display: flex; flex-direction: column; min-width: 200px; }
.crst-app .crst-h { margin: 0; font-size: 1.45rem; color: var(--crst-accent); letter-spacing: .01em; }
.crst-sub { color: var(--crst-muted); font-size: .85rem; }

/* Controls */
.crst-controls { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto; gap: 12px; align-items: end; }
.crst-field { position: relative; min-width: 0; }
.crst-row > input { min-width: 0; flex: 1 1 auto; }
.crst-row > .crst-btn { flex: none; }
.crst-field label { display: block; font-size: .8rem; font-weight: 600; color: var(--crst-text); margin-bottom: 4px; }
.crst-field label small { font-weight: 400; color: var(--crst-muted); }
.crst-row { display: flex; gap: 6px; }
.crst-app input[type="text"], .crst-app input[type="search"], .crst-app input[type="datetime-local"], .crst-app select {
	background: var(--crst-field); color: var(--crst-text); border: 1px solid var(--crst-line); border-radius: 8px; padding: 9px 10px; font: inherit; width: 100%; min-height: 40px;
}
.crst-app input:focus, .crst-app select:focus, .crst-app button:focus-visible, .crst-canvas:focus-visible, .crst-app th:focus-visible { outline: 2px solid var(--crst-accent); outline-offset: 1px; }
.crst-btn { border: 1px solid var(--crst-line); background: var(--crst-panel); color: var(--crst-text); border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer; white-space: nowrap; min-height: 40px; }
.crst-btn:hover { border-color: var(--crst-accent); }
.crst-primary { background: var(--crst-strong); color: var(--crst-on-accent); font-weight: 700; border-color: transparent; }
.crst-primary:hover { filter: brightness(1.08); }
.crst-ghost { background: transparent; }
.crst-linkbtn { background: none; border: 0; color: var(--crst-accent); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }
.crst-suggest { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--crst-panel); border: 1px solid var(--crst-line); border-radius: 8px; max-height: 220px; overflow: auto; }
.crst-suggest li { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: .85rem; }
.crst-suggest li[data-i]:hover, .crst-suggest li[data-i]:focus { background: var(--crst-hover); }
.crst-status { min-height: 1.4em; margin: 8px 2px; font-size: .9rem; color: var(--crst-muted); }
.crst-status.crst-error { color: var(--crst-bad); }
.crst-status.crst-info { color: var(--crst-accent-2); }

/* Layout */
.crst-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 14px; }
.crst-mapcol { display: flex; flex-direction: column; min-width: 0; background: var(--crst-bg); }
.crst-mapwrap { position: relative; height: var(--crst-map-h); border-radius: 10px; overflow: hidden; border: 1px solid var(--crst-line); background: var(--crst-field); }
.crst-mapcol:fullscreen { padding: 10px; }
.crst-mapcol:fullscreen .crst-mapwrap { height: calc(100vh - 80px); height: calc(100dvh - 80px); }
.crst-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.crst-canvas:active { cursor: grabbing; }
.crst-tip { max-width: calc(100% - 20px); white-space: normal !important; position: absolute; pointer-events: none; background: var(--crst-panel); border: 1px solid var(--crst-line); border-radius: 6px; padding: 5px 8px; font-size: .8rem; white-space: nowrap; z-index: 5; }
.crst-mapbtns { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 4px; }
.crst-mapbtns button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--crst-line); background: var(--crst-panel); color: var(--crst-text); font: 600 14px system-ui, sans-serif; cursor: pointer; }
.crst-mapbtns button:hover { border-color: var(--crst-accent); }
.crst-mapinfo { position: absolute; left: 10px; bottom: 8px; font-size: .72rem; color: #f2f2f2; background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 6px; max-width: calc(100% - 20px); }
.crst-timebar { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.crst-timebar select { width: auto; min-height: 36px; padding: 6px; }
.crst-timebar input[type="range"] { flex: 1 1 160px; min-width: 0; accent-color: var(--crst-accent); }
.crst-clock { font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--crst-text); }
.crst-live { color: var(--crst-accent-2); }

/* Bortle badge – colours follow the light-pollution map convention (dark → bright) */
.crst-bortle { display: inline-block; min-width: 22px; text-align: center; border-radius: 5px; font-weight: 800; padding: 0 5px; color: #111; }
.crst-bortle-1 { background: #7d7d7d; color: #fff; } .crst-bortle-2 { background: #3c5cff; color: #fff; } .crst-bortle-3 { background: #2ea8ff; }
.crst-bortle-4 { background: #3fcf55; } .crst-bortle-5 { background: #f4e04d; } .crst-bortle-6 { background: #ff9f3a; }
.crst-bortle-7 { background: #ff5a3a; color: #fff; } .crst-bortle-8 { background: #ffffff; box-shadow: inset 0 0 0 1px #888; } .crst-bortle-9 { background: #ffffff; outline: 2px solid #ff5a3a; }
.crst-sitectl { padding-top: 6px !important; }
.crst-sitectl select, .crst-sitectl input { width: auto !important; min-height: 30px !important; padding: 4px 6px !important; font-size: .8rem !important; margin: 3px 0; }
.crst-sitectl input { width: 130px !important; }

/* Option panels under the map */
.crst-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 10px; margin-top: 10px; align-items: start; }

/* Side panels */
.crst-side, .crst-panel, .crst-tablewrap, .crst-mapcol { min-width: 0; max-width: 100%; }
.crst-side { display: flex; flex-direction: column; gap: 10px; }
.crst-panel { background: var(--crst-panel); border: 1px solid var(--crst-line); border-radius: 10px; padding: 0 12px; }
.crst-panel > summary { cursor: pointer; padding: 10px 0; font-weight: 700; color: var(--crst-accent); list-style-position: inside; }
.crst-panel > summary small { font-weight: 400; color: var(--crst-muted); }
.crst-panel > div, .crst-panel > canvas { margin-bottom: 12px; }
.crst-check { display: flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; font-size: .88rem; }
.crst-check input { accent-color: var(--crst-accent); width: 16px; height: 16px; }
.crst-count { color: var(--crst-muted); font-style: normal; font-size: .78rem; margin-left: auto; }
.crst-muted { color: var(--crst-muted); font-size: .85rem; }
.crst-place { margin: 0 0 8px; font-weight: 600; }
.crst-place small { font-weight: 400; color: var(--crst-muted); }
.crst-kv { width: 100%; border-collapse: collapse; font-size: .82rem; table-layout: fixed; }
.crst-passtable { table-layout: auto !important; }
.crst-kv th, .crst-kv td { text-align: left; padding: 4px 4px; border-bottom: 1px solid var(--crst-line); vertical-align: top; }
.crst-kv th { color: var(--crst-muted); font-weight: 500; width: 42%; }
.crst-kv small { color: var(--crst-muted); }
.crst-kv .crst-sep th { color: var(--crst-accent); padding-top: 10px; font-weight: 700; width: auto; }
.crst-warn { color: var(--crst-warn); }
.crst-score { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; margin-bottom: 8px; background: var(--crst-field); border: 1px solid var(--crst-line); }
.crst-score > span { font: 800 1.4rem/1 system-ui, sans-serif; min-width: 44px; text-align: center; }
.crst-score small { display: block; color: var(--crst-muted); }
.crst-score-good > span { color: var(--crst-good); }
.crst-score-fair > span { color: var(--crst-fair); }
.crst-score-poor > span { color: var(--crst-bad); }
.crst-selname { margin: 0 0 6px; color: var(--crst-accent); font-size: 1.05rem; }
.crst-altchart { display: block; width: 100%; border-radius: 6px; background: var(--crst-chart-bg); }
.crst-passes h5 { margin: 8px 0 4px; font-size: .85rem; }
.crst-passtable th { width: auto; }
.crst-badge { display: inline-block; background: #ffe45c; color: #111; border-radius: 10px; padding: 0 7px; font-size: .72rem; font-weight: 700; }

/* FAA / aircraft toggle */
.crst-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; padding: 2px 0 6px; }
.crst-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.crst-switch span { width: 40px; height: 22px; border-radius: 11px; background: var(--crst-line); position: relative; transition: background .2s; flex: none; }
.crst-switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.crst-switch input:checked + span { background: var(--crst-strong); }
.crst-switch input:checked + span::after { transform: translateX(18px); }
.crst-switch input:focus-visible + span { outline: 2px solid var(--crst-accent); outline-offset: 2px; }
.crst-acnote { margin: 0 0 6px; }
.crst-acstatus { margin: 0; font-size: .8rem; color: var(--crst-accent-2); }

/* Table */
.crst-tablewrap { margin-top: 16px; background: var(--crst-panel); border: 1px solid var(--crst-line); border-radius: 10px; padding: 12px; }
.crst-tabletools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.crst-tabletools h3 { margin: 0 auto 0 0; font-size: 1.05rem; color: var(--crst-accent); }
.crst-tabletools input[type="search"] { width: 240px; flex: 1 1 200px; min-width: 0; }
.crst-tabletools select { width: auto; }
.crst-scroll { overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; max-width: 100%; max-height: 520px; border-radius: 8px; border: 1px solid var(--crst-line); }
.crst-table { width: 100%; border-collapse: collapse; font-size: .82rem; font-variant-numeric: tabular-nums; margin: 0; }
.crst-table th { position: sticky; top: 0; background: var(--crst-panel); color: var(--crst-text); text-align: left; padding: 8px; cursor: pointer; white-space: nowrap; user-select: none; border-bottom: 1px solid var(--crst-line); }
.crst-table th.crst-sorted { color: var(--crst-accent); }
.crst-table th[aria-sort="ascending"]::after { content: " ▲"; }
.crst-table th[aria-sort="descending"]::after { content: " ▼"; }
.crst-table td { padding: 6px 8px; border-bottom: 1px solid var(--crst-line); white-space: nowrap; overflow-wrap: normal; }
.crst-table td small { color: var(--crst-muted); }
.crst-table tbody tr { cursor: pointer; }
.crst-table tbody tr:hover { background: var(--crst-hover); }
.crst-table tr.crst-selrow { background: color-mix(in srgb, var(--crst-strong) 35%, transparent); }
.crst-table tr.crst-below { opacity: .55; }
.crst-name { font-weight: 600; }
.crst-info { white-space: normal !important; min-width: 200px; color: var(--crst-text); }
.crst-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: #fff; }
.crst-t-sat { background: #ffe45c; border-radius: 1px; transform: rotate(45deg); }
.crst-t-planet { background: #ff9a66; }
.crst-t-sun { background: #ffd84d; }
.crst-t-moon { background: #e8e8e0; }
.crst-t-star { background: #cad7ff; box-shadow: 0 0 0 1px #8fa0c8; }
.crst-t-drone { background: #ff6bd6; }
.crst-t-platform { background: #ffb347; }
.crst-t-aircraft { background: #4be3ff; }
.crst-tablefoot { display: flex; align-items: center; gap: 10px; margin-top: 8px; color: var(--crst-muted); font-size: .82rem; }
.crst-tnote { margin: 8px 0 0; font-size: .75rem; }
.crst-foot { margin-top: 12px; font-size: .72rem; color: var(--crst-muted); text-align: center; }

@media (max-width: 960px) {
	.crst-main { grid-template-columns: minmax(0, 1fr); }
	.crst-controls { grid-template-columns: minmax(0, 1fr); }
	.crst-field-go label { display: none; }
	.crst-field-go .crst-btn { width: 100%; }
	.crst-mapwrap { height: min(var(--crst-map-h), 78vh); height: min(var(--crst-map-h), 72svh); }
}
@media (max-width: 600px) {
	.crst-app { padding: 10px; border-radius: 8px; font-size: 14px; }
	.crst-head { gap: 8px; padding-bottom: 10px; }
	.crst-head { flex-direction: column; align-items: flex-start; }
	.crst-logo { height: auto; width: 100%; max-width: 360px; max-height: 96px; }
	.crst-titles { min-width: 0; }
	.crst-app .crst-h { font-size: 1.1rem; }
	.crst-sub { font-size: .75rem; }
	.crst-field label small { display: block; }
	.crst-mapwrap { height: auto; aspect-ratio: 1 / 1.05; max-height: 72svh; }
	.crst-mapbtns { top: 6px; right: 6px; gap: 3px; }
	.crst-mapbtns button { width: 30px; height: 30px; font-size: 12px; }
	.crst-mapinfo { font-size: .65rem; left: 6px; bottom: 4px; max-width: calc(100% - 50px); }
	.crst-timebar { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; }
	.crst-timebar input[type="range"] { grid-column: 1 / -1; grid-row: 2; width: 100%; }
	.crst-clock { font-size: .78rem; min-width: 0; }
	.crst-panel { padding: 0 10px; }
	.crst-kv th { width: 40%; }
	.crst-tablewrap { padding: 8px; }
	.crst-tabletools { gap: 6px; }
	.crst-tabletools h3 { flex: 1 1 100%; }
	.crst-tabletools input[type="search"] { flex: 1 1 100%; width: 100%; }
	.crst-tabletools select { flex: 1 1 auto; }
	.crst-scroll { max-height: 60svh; }
	.crst-table { font-size: .76rem; }
	.crst-table th, .crst-table td { padding: 5px 6px; }
	.crst-info { min-width: 160px; }
	.crst-sitectl select, .crst-sitectl input { width: 100% !important; }
	.crst-foot { font-size: .68rem; }
}
/* Touch screens in any orientation: 16px fields stop iOS Safari zooming on focus;
   bigger tap targets for map buttons. */
@media (pointer: coarse) {
	.crst-app input[type="text"], .crst-app input[type="search"], .crst-app input[type="number"], .crst-app input[type="datetime-local"], .crst-app select { font-size: 16px !important; }
}
@media (max-height: 500px) and (orientation: landscape) {
	.crst-mapwrap { height: 85svh; aspect-ratio: auto; max-height: none; }
}
@media (max-width: 360px) {
	.crst-app { padding: 6px; }
	.crst-mapbtns button[data-act="look"] { display: none; }
	.crst-btn { padding: 8px 9px; }
}
