/* SPDX-License-Identifier: GPL-3.0-or-later
   Orbitfish – Copyright (C) 2026 Jan-Maurice Dahlmanns (Bugfish) */
:root {
  --bg: #07090e; --panel: #0e131c; --panel2: #141b27; --line: #222c3d; --line2: #2d3a51;
  --text: #dfe6f2; --dim: #8c99b2; --dim2: #5f6c85; --acc: #ff5707; --acc2: #ff8a4c;
  --ok: #7fd48a; --warn: #f2c14e; --err: #ff6b7a; --blue: #7aa2f7;
  --r: 6px; --fs: 13px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: var(--fs)/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--acc2); }
.grow { flex: 1; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- top bar */
#top { position: fixed; inset: 0 0 auto 0; height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 10px; background: linear-gradient(#0d121b, #0a0e15); border-bottom: 1px solid var(--line); z-index: 20; }
.exit { color: var(--dim); text-decoration: none; padding: 5px 8px; border-radius: var(--r); white-space: nowrap; }
.exit:hover { color: var(--text); background: var(--panel2); }
.brand { letter-spacing: 0.18em; font-size: 14px; white-space: nowrap; }
.brand b { color: var(--acc); }
.brand small { letter-spacing: 0.05em; color: var(--dim); font-size: 11px; margin-left: 6px; }
.menus { display: flex; gap: 2px; }
.menus button, .clock button { background: transparent; border: 1px solid transparent; border-radius: var(--r); padding: 5px 9px; cursor: pointer; }
.menus button:hover, .clock button:hover { background: var(--panel2); border-color: var(--line); }
.clock { display: flex; align-items: center; gap: 2px; }
#clock-date { font-variant-numeric: tabular-nums; min-width: 175px; font-weight: 600; }
#clock-rate { color: var(--dim); min-width: 70px; text-align: center; font-size: 12px; }
#t-now { border-color: var(--line2) !important; }
.menu-pop { position: fixed; z-index: 60; background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--r); padding: 5px; min-width: 240px; box-shadow: 0 8px 30px #000a; display: flex; flex-direction: column; }
.menu-pop button { text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 4px; cursor: pointer; }
.menu-pop button:hover { background: #1f2939; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.menu-pop .chk { padding: 5px 8px; }

/* ---------------------------------------------------------------- layout */
#main { position: fixed; inset: 44px 0 24px 0; display: flex; }
#panel { width: 390px; min-width: 300px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 10; }
#tabs { display: flex; border-bottom: 1px solid var(--line); }
#tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 4px; cursor: pointer; color: var(--dim); }
#tabs button.on { color: var(--text); border-bottom-color: var(--acc); }
.tabbody { flex: 1; overflow: auto; padding: 10px 12px 40px; scrollbar-width: thin; }
#stage { position: relative; flex: 1; min-width: 0; }
#view { position: absolute; inset: 0; width: 100%; height: calc(100% - 64px); display: block; cursor: grab; touch-action: none; }
#view:active { cursor: grabbing; }
body.picking #view { cursor: crosshair; }
#labels { position: absolute; inset: 0 0 64px 0; overflow: hidden; pointer-events: none; }
#focusbar { position: absolute; left: 10px; top: 10px; z-index: 5; display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; background: #0b0f17d9; border: 1px solid var(--line2); border-radius: 8px; box-shadow: 0 4px 18px #0008; max-width: calc(100% - 70px); }
#focusbar span { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
#focusbar select { background: #0a0e15; border: 1px solid var(--line2); border-radius: 4px; padding: 4px 6px; min-width: 0; max-width: 220px; }
#focusbar button { background: var(--panel2); border: 1px solid var(--line2); border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 12px; }
#focusbar button:hover, #focusbar select:hover { border-color: #3d4d6b; }
#timeline { position: absolute; left: 0; right: 0; bottom: 0; height: 64px; width: 100%; background: #0b0f17; border-top: 1px solid var(--line); cursor: ew-resize; }
#inspector { width: 300px; background: var(--panel); border-left: 1px solid var(--line); overflow: auto; padding: 10px 12px; scrollbar-width: thin; }
#status { position: fixed; inset: auto 0 0 0; height: 24px; display: flex; align-items: center; gap: 14px; padding: 0 10px; background: #090c12; border-top: 1px solid var(--line); color: var(--dim2); font-size: 11px; z-index: 20; white-space: nowrap; overflow: hidden; }
#status a { color: var(--dim); text-decoration: none; }
#status a:hover { color: var(--text); }
#status-eph.approx { color: var(--warn); }
.only-small { display: none; }

/* ---------------------------------------------------------------- labels */
.lbl { position: absolute; left: 0; top: 0; font-size: 11px; color: #c8d3e6; white-space: nowrap; text-shadow: 0 0 3px #000, 0 0 6px #000; padding: 1px 3px; will-change: transform; }
.lbl.k-planet, .lbl.k-star { font-size: 12px; color: #eef3fb; font-weight: 600; }
.lbl.k-moon { color: #9fb0c9; }
.lbl.k-asteroid, .lbl.k-comet, .lbl.k-dwarf { color: #8796ad; font-size: 10.5px; }
.lbl.craft { color: var(--c, #ffb347); font-weight: 600; }
.lbl.sel { color: #fff; background: #ff57072e; border-radius: 3px; }

/* ---------------------------------------------------------------- panels */
.ph { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; }
.ph h3, .ph h4 { margin: 0; }
h3 { font-size: 14px; letter-spacing: 0.02em; }
h4 { font-size: 12px; margin: 14px 0 6px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
h4 small { text-transform: none; letter-spacing: 0; color: var(--dim2); font-weight: normal; }
.hint { color: var(--dim); font-size: 12px; margin: 6px 0; }
.tag { font-size: 11px; color: var(--dim); background: var(--panel2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 10px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.btn { background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--r); padding: 6px 10px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3d4d6b; background: #1a2232; }
.btn.primary { background: #ff57071f; border-color: #ff5707a0; color: #ffd2bd; }
.btn.primary:hover { background: #ff570738; }
.btn.danger { border-color: #ff6b7a66; color: #ffb3bb; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn.mini, button.mini { padding: 1px 6px; font-size: 11px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 4px; cursor: pointer; }
.btn.icon { padding: 1px 6px; background: transparent; border-color: transparent; color: var(--dim); }
.btn.icon:hover { color: var(--text); border-color: var(--line2); }
.btnrow { display: flex; gap: 6px; margin: 8px 0; align-items: center; }
.btnrow.wrap { flex-wrap: wrap; }
.fld { display: flex; flex-direction: column; gap: 3px; margin: 4px 0; min-width: 0; }
.fl { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi { display: flex; align-items: center; gap: 4px; min-width: 0; }
.fi em { font-style: normal; color: var(--dim2); font-size: 11px; white-space: nowrap; }
.fld input, .fld select, input[type=search], .addleg { width: 100%; min-width: 0; background: #0a0e15; border: 1px solid var(--line2); border-radius: 4px; padding: 5px 6px; }
.fld input:focus, .fld select:focus, input[type=search]:focus { outline: none; border-color: var(--acc); }
input[type=color] { padding: 0 2px !important; height: 28px; }
input[type=search] { margin-bottom: 8px; }
.chk { display: flex; align-items: center; gap: 6px; margin: 5px 0; cursor: pointer; font-size: 12.5px; }
.row2, .row3 { display: grid; gap: 8px; align-items: end; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
.row3.pl { grid-template-columns: 1.6fr 1fr auto; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; background: #0a0e15; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; margin: 8px 0; }
.stats div { display: flex; flex-direction: column; min-width: 0; }
.stats span { font-size: 10.5px; color: var(--dim); }
.stats b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats .ok b { color: var(--ok); } .stats .warn b { color: var(--warn); } .stats .err b { color: var(--err); }
.bar { height: 5px; background: #1b2433; border-radius: 3px; overflow: hidden; margin: 4px 0; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff5707, #ffb347); }
.msg { font-size: 12px; padding: 5px 8px; border-radius: 4px; margin: 4px 0; background: #101722; border-left: 3px solid var(--blue); }
.msg.err { border-left-color: var(--err); color: #ffc7cd; background: #2a1016; }
.msg.warn { border-left-color: var(--warn); color: #f6e2ad; background: #262011; }
.msg.ok { border-left-color: var(--ok); }
details.sect { border: 1px solid var(--line); border-radius: var(--r); padding: 4px 10px; margin: 8px 0; background: #0b1018; }
details.sect > summary { cursor: pointer; padding: 4px 0; color: var(--dim); }
details.sect[open] > summary { margin-bottom: 4px; }

/* missions */
.mlist { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.mrow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r); cursor: pointer; border: 1px solid transparent; }
.mrow:hover { background: var(--panel2); }
.mrow.sel { background: #18202e; border-color: var(--line2); }
.mname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st { font-weight: bold; width: 16px; text-align: center; }
.st.ok { color: var(--ok); } .st.warn { color: var(--warn); } .st.err { color: var(--err); }
.eye { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 0 3px; }
.eye:hover { color: var(--text); }
.eye.off { color: var(--dim2); }
.med { border-top: 1px solid var(--line); padding-top: 8px; }
.mhead { grid-template-columns: 1fr 70px; }
.tanks { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 8px; }
.tank { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; font-size: 11.5px; }
.tank span { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tank em { font-style: normal; font-variant-numeric: tabular-nums; color: var(--text); }
.tank.off { opacity: 0.55; }
.legs { display: flex; flex-direction: column; gap: 6px; }
.leg { border: 1px solid var(--line); border-radius: var(--r); background: #0b1018; }
.leg.sel { border-color: #3a4a66; }
.lhead { display: flex; align-items: center; gap: 6px; padding: 6px 6px 4px 8px; cursor: pointer; }
.li { color: var(--dim2); font-size: 11px; width: 16px; }
.licon { width: 18px; text-align: center; }
.lt { font-weight: 600; white-space: nowrap; }
.lsum { color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lstatus { padding: 0 10px 6px 34px; font-size: 12px; border-left: 3px solid transparent; }
.lstatus.ok { border-left-color: #7fd48a55; } .lstatus.warn { border-left-color: var(--warn); } .lstatus.err { border-left-color: var(--err); } .lstatus.blocked { opacity: 0.5; }
.lline { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--dim); }
.lline b { color: var(--text); }
.burn { color: var(--dim); font-size: 11.5px; }
.lbody { padding: 4px 10px 10px; border-top: 1px dashed var(--line); }
.addleg { width: auto; }

/* craft editor */
.craft-ed .stats { grid-template-columns: 1fr 1fr; }
.stage-card { border: 1px solid var(--line); border-radius: var(--r); padding: 6px 8px; margin: 6px 0; background: #0a0e15; }
.sc-head { display: flex; align-items: center; gap: 6px; }
.sc-name { flex: 1; min-width: 0; background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 3px 5px; font-weight: 600; }
.sc-name:hover, .sc-name:focus { border-color: var(--line2); outline: none; }

/* bodies */
.blist { display: flex; flex-direction: column; }
.brow { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; cursor: pointer; }
.brow:hover, .brow:focus { background: var(--panel2); outline: none; }
.brow.sel { background: #18202e; }
.brow.moon { padding-left: 26px; }
.brow em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--dim2); }
.brow.small span { color: #b5c0d3; }

/* transfer */
.pork { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r); cursor: crosshair; display: block; margin: 6px 0; }
.prog { font-size: 11.5px; color: var(--dim); min-height: 16px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; color: var(--dim); font-weight: normal; border-bottom: 1px solid var(--line); padding: 3px 4px; }
.tbl td { padding: 3px 4px; border-bottom: 1px solid #161d29; }

/* inspector */
.ititle { display: flex; align-items: center; gap: 8px; }
.ititle h3 { margin: 4px 0; font-size: 16px; }
.isub { color: var(--dim); font-size: 12px; margin-bottom: 4px; }
.idesc { color: #b9c4d6; font-size: 12.5px; }
.itable dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 12px; }
.itable dt { color: var(--dim); }
.itable dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.events { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; }
.ev { display: grid; grid-template-columns: 112px 1fr; gap: 6px; padding: 3px 4px; border-radius: 4px; cursor: pointer; }
.ev:hover { background: var(--panel2); }
.ev span { color: var(--dim); font-variant-numeric: tabular-nums; }
.ev b { font-weight: normal; }

/* modal & toasts */
.modal-back { position: fixed; inset: 0; background: #0009; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; width: min(460px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px #000c; }
.modal.wide { width: min(680px, 100%); }
.mh { display: flex; align-items: center; padding: 12px 16px 6px; }
.mh h2 { margin: 0; font-size: 16px; flex: 1; }
.mh .x { background: none; border: 0; font-size: 22px; color: var(--dim); cursor: pointer; }
.mb { padding: 6px 16px 10px; overflow: auto; }
.mf { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.help ul { padding-left: 18px; margin: 4px 0; }
.help li { margin: 3px 0; }
.help p { color: #c6cfdd; }
.toasts { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 70; pointer-events: none; }
.toast { background: #182133; border: 1px solid var(--line2); padding: 8px 14px; border-radius: 8px; box-shadow: 0 6px 20px #0008; transition: opacity .4s, transform .4s; max-width: 80vw; }
.toast.ok { border-color: #7fd48a88; } .toast.warn { border-color: #f2c14e88; } .toast.err { border-color: #ff6b7a99; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* boot & drop */
.boot { position: fixed; inset: 0; z-index: 80; background: radial-gradient(circle at 50% 40%, #121a29, #05070b 70%); display: flex; align-items: center; justify-content: center; }
.boot-inner { width: min(420px, 86vw); text-align: center; }
.brand.big { font-size: 30px; letter-spacing: 0.28em; margin-bottom: 18px; }
.boot .bar { height: 4px; }
.boot .bar i { transition: width .4s; }
#boot-text { color: var(--dim); font-size: 12.5px; }
.drop-hint { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; font-size: 18px; background: #ff570722; border: 3px dashed var(--acc); z-index: 90; pointer-events: none; }
body.dropping .drop-hint { display: flex; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 1180px) { #inspector { width: 260px; } #panel { width: 350px; } .brand small { display: none; } }
@media (max-width: 900px) {
  .only-small { display: inline-block; }
  #panel { position: absolute; left: 0; top: 0; bottom: 0; width: min(420px, 100%); transform: translateX(calc(-100% + 0px)); transition: transform .25s; box-shadow: 8px 0 30px #0009; }
  #tabs { position: relative; }
  body:not(.panel-open) #panel { transform: translateX(-100%); }
  body.panel-open #panel { transform: none; }
  #panel #tabs { position: fixed; left: 0; top: 44px; width: min(420px, 100%); background: var(--panel); z-index: 11; }
  body:not(.panel-open) #panel #tabs { width: auto; right: 0; background: #0e131ce6; border-bottom: 1px solid var(--line); }
  body:not(.panel-open) #panel-close { display: none; }
  .tabbody { margin-top: 38px; }
  #stage { margin-top: 38px; }
  #inspector { position: absolute; right: 0; top: 38px; bottom: 64px; width: min(320px, 90%); transform: translateX(100%); transition: transform .25s; z-index: 9; box-shadow: -8px 0 30px #0009; }
  body.insp-open #inspector { transform: none; }
  #insp-toggle { position: absolute; right: 10px; top: 10px; z-index: 5; background: #0e131ccc; border: 1px solid var(--line2); border-radius: 50%; width: 34px; height: 34px; cursor: pointer; }
  #clock-date { min-width: 0; font-size: 12px; }
  #clock-rate, .menus #m-help { display: none; }
  .exit { padding: 5px 4px; }
}
@media (max-width: 560px) {
  .brand { display: none; }
  #top { gap: 4px; padding: 0 6px; }
  #status-fps, #status a:not(:first-of-type) { display: none; }
  #status-eph { overflow: hidden; text-overflow: ellipsis; }
  .row3 { grid-template-columns: 1fr 1fr; }
}
