/* Shared sizing: fluid spacing, readable limits, and full-width panels. */
:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #e9f0fa;
  background: #080e18;
  --space: clamp(10px, 1vw, 18px);
  --viewer-min: 560px;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
a { color: #9bd7ef; text-decoration: none; }
body > header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px clamp(14px, 2vw, 28px);
  padding: clamp(10px, 1vw, 16px) var(--space); flex: none;
  border-bottom: 1px solid #263348; background: #0d1725;
}
.brand, .header-title { font-size: clamp(16px, 1.4vw, 21px); font-weight: 650; line-height: 1.35; }
.brand { color: #ffd700; }
.header-title { margin: 0; letter-spacing: normal; }
body > header > a:last-child { margin-left: auto; font-size: 13px; }
body > main { flex: 1; min-width: 0; width: 100%; display: flex; flex-direction: column; padding: 10px var(--space) 8px; }
.intro p { margin: 0 0 6px; font-size: clamp(12px, 1vw, 14px); line-height: 1.5; color: #a4b5cb; }
label { color: #afbed1; font-size: 12px; }
input, select, button { font: inherit; color: #edf3fa; background: #142338; border: 1px solid #364b67; border-radius: 6px; padding: 8px; min-height: 36px; }
input:not([type=checkbox]), select { display: block; margin-top: 5px; width: 100%; min-width: 0; max-width: 100%; }
input[type=checkbox] { min-height: 0; accent-color: #ffd700; }
button { cursor: pointer; }
button:hover { border-color: #8edaca; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #ffd700; outline-offset: 3px; }
/* Filters stay compact, with the comparison option on its own bottom row. */
.filters { display: grid; grid-template-columns: minmax(180px, 1fr) repeat(3, 88px) auto; gap: 10px; align-items: end; width: min(100%, 850px); margin-top: 2px; padding: 12px; background: #101c2c; border: 1px solid #29374b; border-radius: 12px; }
.filters > label { min-width: 0; }
.filter-bottom { grid-column: 1 / -1; }
.toggle { display: inline-flex; align-items: center; gap: 5px; line-height: 1.4; }
.help, footer { font-size: 11px; color: #91a3bc; line-height: 1.5; }
.help { margin: 6px 0 4px; }
#status { margin: 3px 0 8px; font-size: 13px; color: #8edaca; overflow-wrap: anywhere; }
#syncbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 4px 0 12px; }
#syncbar span { font-size: 11px; color: #a4b5cb; max-width: 370px; }
/* Flexible rows fill the remaining screen height. Minimums allow safe scrolling. */
#panels { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(var(--viewer-min), 1fr); gap: 12px; }
#panels.comparing { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { position: relative; min-width: 0; min-height: var(--viewer-min); border: 1px solid #293a50; border-radius: 12px; overflow: hidden; background: #0c1726; container-type: inline-size; }
.panel iframe { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border: 0; }
/* Floating controls preserve a continuous canvas instead of adding a header box. */
.panel > label { position: absolute; top: 10px; left: 12px; z-index: 3; width: min(50%, 826px); max-width: calc(100% - 240px); display: block; }
.panel > label select { text-overflow: ellipsis; }
.panel-legend { position: absolute; top: 8px; right: 12px; z-index: 3; text-align: right; font-size: clamp(13px, 1.2vw, 18px); line-height: 1.7; pointer-events: none; }
footer { flex: none; margin-top: 8px; }
[hidden] { display: none !important; }
/* A comparison panel responds to its own width, not just the browser width. */
@container (max-width: 720px) {
  .panel > label { width: calc(100% - 190px); max-width: none; }
  .panel-legend { font-size: 14px; line-height: 1.6; }
}
@container (max-width: 420px) {
  .panel > label { width: calc(100% - 155px); }
  .panel-legend { font-size: 11px; line-height: 1.6; }
}
@media (max-width: 1200px) {
  #panels.comparing { grid-template-columns: minmax(0, 1fr); }
  #panels.comparing .panel { min-height: 650px; }
}
@media (max-width: 760px) {
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters > label:first-child { grid-column: 1 / -1; }
  #clear { grid-column: 1 / -1; justify-self: start; }
  :root { --viewer-min: 720px; }
}
@media (max-width: 480px) {
  :root { --viewer-min: 850px; }
  .header-title { flex-basis: 100%; order: 3; }
  .filters { gap: 8px; padding: 10px; }
  input, select, button { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }

/* Keep About and Open demo together on the right. */
#about-open {
  margin-left: auto;
}

body > header > a:last-child {
  margin-left: 0;
}

/* Responsive information dialog. */
#about-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  padding: clamp(18px, 3vw, 30px);
  color: #e9f0fa;
  background: #101c2c;
  border: 1px solid #364b67;
  border-radius: 14px;
  box-shadow: 0 20px 80px #0008;
}

#about-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.about-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.about-heading h2 {
  margin: 0;
  font-size: 23px;
}

#about-dialog h3 {
  margin: 22px 0 8px;
  font-size: 15px;
}

#about-dialog p {
  font-size: 14px;
  line-height: 1.75;
  color: #bac8db;
}

#about-dialog .about-note {
  color: #8edaca;
}
#about-open {
  font-size: 13px;
  white-space: nowrap;
}


/* One clock and one optional degree scale for both viewers. */
#syncbar{display:block;padding:12px;border:1px solid #33445b;border-radius:10px;margin-bottom:10px;background:#101c2c}
.shared-controls{display:flex;flex-wrap:wrap;align-items:end;gap:10px}
.shared-time{display:flex;align-items:center;flex-wrap:wrap;gap:12px;margin-top:10px}
.shared-time input{flex:1;min-width:150px;accent-color:#67d8d0}
#shared-status{font-size:12px;color:#a6b7cd;margin:8px 0 0}
.shared-chart-wrap{margin-top:8px}.shared-chart-wrap summary{cursor:pointer;font-size:12px;color:#a6b7cd}
#shared-chart{display:block;width:min(100%,900px);height:auto}

/* Sharing feedback wraps without widening the workspace. */
#copy-view{margin-left:auto;font-size:13px;white-space:nowrap}
#copy-view + #about-open{margin-left:0}
#copy-view:disabled{opacity:.55;cursor:default}
.share-feedback{font-size:12px;color:#a6dcd5;max-width:100%}
#share-status{margin:4px 0;overflow-wrap:anywhere}
#share-status:empty{display:none}
#share-manual{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:6px 0}
#share-link{flex:1;min-width:180px;width:auto;margin:0;font-size:12px}
