/* ==============================================================================
   style.css - Aussehen wie LedPreResistor 2.5.2 (Entwurf A «Labor 2», dunkel)
   Farben aus uTheme.pas, Masse aus uMain.lfm / LayoutLeft (96 dpi = 1 px)
   ============================================================================== */
:root {
  --window: #1E2228;      /* clrWindow */
  --panel: #23272E;       /* clrPanel */
  --deep: #15181C;        /* clrDeep */
  --bar: #16191D;         /* clrBar */
  --border: #333A42;      /* clrBorder */
  --edit-border: #45505C; /* clrEditBorder */
  --text: #DFE3E8;        /* clrText */
  --bright: #FFFFFF;      /* clrTextBright */
  --dim: #7F8A96;         /* clrTextDim */
  --soft: #9AA4AE;        /* clrTextSoft */
  --accent: #5AA9FF;      /* clrAccent */
  --line: #C9D1DA;        /* clrLine */
  --ok: #3DDC84;  --ok-back: #10301E;
  --warn: #FFCC33; --warn-back: #3A3110;
  --error: #FF5C5C; --error-back: #3A1414;
  --rw-back: #1A1D22;
  --mode-on: #1D4F86;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", "DejaVu Sans Mono", Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--window); color: var(--text); }
body { font: 12px/1.25 var(--font); -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

#app { display: flex; flex-direction: column; min-height: 640px; min-height: max(640px, 100dvh); }

/* ===== Reiterzeile ===== */
.tabs { flex: 0 0 34px; display: flex; align-items: stretch; justify-content: space-between;
  background: var(--window); border-bottom: 1px solid var(--border); padding-left: 16px; }
.tab-list { display: flex; gap: 2px; padding-top: 6px; overflow-x: auto; scrollbar-width: none; }
.tab-list::-webkit-scrollbar { display: none; }
.tab { border: 1px solid transparent; border-bottom: 0; background: none; color: var(--soft);
  padding: 0 16px; white-space: nowrap; font-size: 12px; position: relative; margin-bottom: -1px; }
.tab.on { background: var(--panel); border-color: var(--border); color: var(--bright); }
.tab.on::before { content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 2px; background: var(--accent); }
.tab:focus-visible, .ico:focus-visible, .lang button:focus-visible, .rw-toggle:focus-visible,
.rw-copy:focus-visible, .mode button:focus-visible, .kofi:focus-visible { outline: 1px dotted var(--soft); outline-offset: -3px; }
.tab-icons { display: flex; align-items: center; gap: 6px; padding: 0 12px 0 8px; }
.ico { width: 26px; height: 26px; border: 1px solid transparent; border-radius: 8px; background: none;
  color: var(--text); display: grid; place-items: center; padding: 0; }
.ico svg { width: 16px; height: 16px; }
.ico:hover { background: var(--panel); border-color: var(--border); color: var(--bright); }
.lang { display: flex; border: 1px solid var(--border); border-radius: 6px; padding: 2px; gap: 2px; height: 22px; }
.lang button { border: 0; background: none; color: var(--soft); font-size: 11px; padding: 0 6px; border-radius: 4px; }
.lang button.on { background: var(--mode-on); color: var(--bright); }

/* ===== Hauptbereich ===== */
.main { flex: 1 1 auto; display: flex; min-height: 0; }
.left { flex: 0 0 270px; width: 270px; background: var(--panel); overflow: visible;
  padding: 0 17px 16px 16px; display: flex; flex-direction: column; }
.right { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; padding: 16px 16px 8px 16px; gap: 10px; }
.schem { flex: 1 1 auto; min-height: 200px; background: var(--deep); border: 1px solid var(--border); position: relative; }
.schem svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cards { flex: 0 0 112px; display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }
.cards.res { grid-template-columns: 1.15fr 1fr 1fr 1fr; }

/* ===== Linke Spalte ===== */
.head { color: var(--dim); font-size: 10.7px; letter-spacing: .04em; text-transform: uppercase; margin: 12px 0 3px; }
#leftRows > .head:first-child { margin-top: 12px; }
.row { display: grid; grid-template-columns: 124px 113px; column-gap: 0; margin-top: 6px; }
.row.full { grid-template-columns: 237px; }
.row.three { grid-template-columns: 82px 82px 73px; }
.field label { display: block; color: var(--text); height: 15px; line-height: 15px; margin-bottom: 3px; white-space: nowrap;
  overflow: hidden; text-overflow: clip; }
.field .in { display: flex; align-items: center; gap: 4px; height: 24px; }
.field input.num { width: 92px; height: 24px; background: var(--deep); color: var(--bright); border: 1px solid var(--edit-border);
  font: 13.3px var(--mono); padding: 0 4px; border-radius: 0; outline: none; }
.row > .field:nth-child(2) input.num { width: 84px; }
.field.t input.num { width: 52px; }
.field input.num:focus { border-color: var(--accent); }
.field input.num:disabled { color: var(--dim); background: #1A1D21; }
.unit { color: var(--dim); font-size: 12px; white-space: nowrap; }
select { height: 24px; background: var(--deep); color: var(--bright); border: 1px solid var(--edit-border); border-radius: 0;
  padding: 0 22px 0 6px; outline: none; appearance: none; -webkit-appearance: none; width: 237px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%),
    linear-gradient(var(--edit-border), var(--edit-border));
  background-position: calc(100% - 12px) 10px, calc(100% - 8px) 10px, calc(100% - 20px) 3px;
  background-size: 4px 4px, 4px 4px, 1px 16px; background-repeat: no-repeat; }
select:focus { border-color: var(--accent); }
select option { background: var(--deep); color: var(--bright); }
select.series { width: 113px; }
#fSeries.k select.series { width: 116px; }
.in.color { position: relative; }
.in.color select { padding-left: 24px; }
.dot { position: absolute; left: 7px; top: 7px; width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--edit-border);
  pointer-events: none; }
.mode { display: grid; grid-template-columns: 1fr 1fr; width: 237px; height: 24px; border: 1px solid var(--edit-border); }
.mode button { border: 0; background: var(--deep); color: var(--soft); font-size: 12px; padding: 0; }
.mode button.on { background: var(--mode-on); color: var(--bright); }
.check, .field label.check { display: flex; margin-bottom: 0; overflow: visible; align-items: center; gap: 6px; height: 22px; cursor: pointer; color: var(--text); user-select: none; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box { width: 14px; height: 14px; flex: 0 0 14px; border: 1px solid var(--edit-border); background: var(--deep); position: relative; }
.check input:checked + .box { background: var(--mode-on); border-color: var(--accent); }
.check input:checked + .box::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;
  border: solid var(--bright); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.check input:focus-visible + .box { outline: 1px dotted var(--soft); outline-offset: 2px; }
.row.check-row { margin-top: 8px; }

.preview { position: relative; flex: 1 1 auto; min-height: 250px; width: 237px; background: var(--deep); margin-top: 2px; }
.preview canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.blinkfreq { position: absolute; left: 8px; top: 6px; pointer-events: none; display: none; }
.blinkfreq .t { color: var(--dim); font-size: 10.7px; }
.blinkfreq .v { color: var(--accent); font-size: 18.7px; font-weight: 700; line-height: 1.2; }
.blinkinfo { display: none; color: var(--soft); font-size: 10.7px; padding: 8px 0 0 8px; width: 237px; min-height: 28px; }
.mode-blink .blinkinfo { display: block; }

/* ===== Karten ===== */
.card { background: var(--panel); border: 1px solid var(--border); padding: 10px; overflow: hidden; position: relative; min-width: 0; }
.card .ct { color: var(--dim); font-size: 10.7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .cv { color: var(--bright); font-size: 20px; font-weight: 700; white-space: nowrap; margin-top: 2px; line-height: 1.3; }
.card .cs { color: var(--soft); font-size: 10.7px; line-height: 1.3; margin-top: 1px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.card .res { position: absolute; left: 10px; top: 54px; height: 15px; max-width: calc(100% - 20px); }
.card .res svg { display: block; height: 100%; max-width: 100%; }
.card .rings { position: absolute; left: 10px; right: 10px; bottom: 10px; color: var(--soft); font-size: 10.7px; line-height: 1.3; }
.card .bar { position: absolute; left: 10px; right: 10px; bottom: 10px; height: 6px; background: var(--deep); }
.card .bar i { position: absolute; left: 0; top: 0; bottom: 0; }
.card .bar b { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--dim); }
.card .wave { position: absolute; left: 10px; right: 10px; bottom: 10px; height: 16px; }
.card .wave svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* ===== Statuszeile ===== */
.status { flex: 0 0 26px; display: flex; background: var(--bar); border-top: 1px solid var(--border); min-width: 0; }
.status-main { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; padding: 0 6px 0 10px; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 19px; padding: 0 6px 0 4px; border: 1px solid; white-space: nowrap; flex: 0 0 auto; }
.chip:empty, .chip.notext .txt { display: none; }
.chip-ico { width: 12px; height: 12px; display: inline-block; }
.chip-ico svg { display: block; width: 12px; height: 12px; }
.status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; color: var(--text); }
.kofi { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding: 0 14px 0 10px; margin: 2px 4px 2px 0; border-radius: 13px;
  background: #23272E; color: var(--bright); font-weight: 700; text-decoration: none; white-space: nowrap; }
.kofi:hover { background: #2C323A; }
.kofi img, .kofi svg { width: 16px; height: 16px; }

/* ===== Rechenweg ===== */
.rechenweg { flex: 0 0 auto; margin: 8px 16px 12px; background: var(--rw-back); border: 1px solid var(--border); }
.rw-head { height: 28px; display: flex; align-items: center; gap: 12px; padding-right: 8px; min-width: 0; }
.rw-toggle { border: 0; background: none; display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 0 0 10px; color: var(--text); flex: 0 0 auto; }
.tri { width: 0; height: 0; border-left: 5px solid var(--text); border-top: 4px solid transparent; border-bottom: 4px solid transparent; margin: 0 1px 0 2px; }
.rechenweg.open .tri { border-top: 5px solid var(--text); border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 0; margin: 0 0 0 0; }
.rw-hint { flex: 1 1 auto; text-align: right; color: var(--soft); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rw-copy { flex: 0 0 auto; height: 20px; border: 1px solid var(--border); border-radius: 4px; background: var(--panel); color: var(--text); padding: 0 10px; min-width: 76px; }
.rw-copy.done { color: var(--ok); }
.rw-body { display: none; border-top: 1px solid var(--border); padding: 6px 14px 8px 14px; font-size: 12px; }
.rechenweg.open .rw-body { display: block; }
.rw-line { display: grid; grid-template-columns: 26px 1fr; min-height: 23px; align-items: start; padding-top: 3px; }
.rw-line .n { color: var(--accent); }
.rw-line .f { color: var(--text); }
.rw-err { color: var(--error); padding: 3px 0; }
.rw-legend { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; margin-top: 4px; line-height: 19px; }
.rw-legend .lt { color: var(--accent); }
b.bb { color: var(--bright); }
sub { font-size: 75%; line-height: 0; vertical-align: -0.25em; }

/* ===== Info-Fenster und Tooltip ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal[hidden] { display: none; }
.dialog { background: var(--panel); border: 1px solid var(--border); width: min(460px, calc(100vw - 32px)); max-width: 100%; color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.dlg-title { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text); }
.dlg-body { display: flex; gap: 20px; padding: 20px 20px 8px; }
.dlg-text { white-space: pre-line; color: var(--bright); font-size: 13px; line-height: 1.4; }
.dlg-foot { display: flex; justify-content: flex-end; padding: 8px 20px 16px; }
.dlg-foot button { width: 84px; height: 28px; background: var(--deep); border: 1px solid var(--edit-border); color: var(--bright); }
.tip { position: fixed; z-index: 20; background: #2B3138; color: var(--text); border: 1px solid var(--border); padding: 3px 7px; font-size: 11px;
  pointer-events: none; white-space: nowrap; }
.tip[hidden] { display: none; }

/* ===== Handy und schmale Fenster ===== */
@media (max-width: 760px) {
  #app { height: auto; min-height: 100vh; }
  .tabs { flex-wrap: wrap; padding-left: 8px; height: auto; flex-basis: auto; }
  .tab-list { flex: 1 1 100%; order: 2; height: 34px; }
  .tab { padding: 0 12px; }
  .tab-icons { order: 1; flex: 1 1 100%; justify-content: flex-end; height: 34px; }
  .main { flex-direction: column; }
  .left { flex: none; width: auto; overflow: visible; padding: 0 16px 8px; }
  .row { grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .row.full { grid-template-columns: 1fr; }
  .row.three { grid-template-columns: 1fr 1fr 1fr; column-gap: 8px; }
  .field input.num, .row > .field:nth-child(2) input.num, .field.t input.num { width: 100%; min-width: 0; height: 32px; font-size: 16px; }
  .field .in { height: 32px; }
  select, select.series, #fSeries.k select.series, .mode { width: 100%; height: 32px; font-size: 15px; }
  select { background-position: calc(100% - 12px) 14px, calc(100% - 8px) 14px, calc(100% - 20px) 6px; background-size: 4px 4px, 4px 4px, 1px 20px; }
  .dot { top: 11px; }
  .mode button { font-size: 14px; }
  .preview { width: 100%; min-height: 0; height: 240px; flex: none; }
  .blinkinfo { width: auto; }
  .right { padding: 8px 16px; }
  .schem { flex: none; min-height: 0; aspect-ratio: 460 / 260; }
  .schem.wide { aspect-ratio: 600 / 330; }
  .cards, .cards.res { flex: none; grid-template-columns: 1fr 1fr; grid-auto-rows: 112px; }
  .status { flex-wrap: wrap; height: auto; flex-basis: auto; padding: 4px 0; }
  .status-main { flex: 1 1 100%; flex-wrap: wrap; padding: 2px 10px; }
  .status-text { white-space: normal; }
  .kofi { margin: 6px 10px 2px auto; height: 28px; }
  .rechenweg { margin: 8px 8px 16px; }
  .rw-head { height: auto; min-height: 32px; flex-wrap: wrap; }
  .rw-hint { order: 3; flex: 1 1 100%; white-space: normal; text-align: left; padding: 0 10px 6px; overflow: visible; }
  .rw-copy { margin-left: auto; height: 26px; }
  .rw-body { overflow-x: auto; }
}

/* schmale PC-Fenster und Tablets quer: Karten 2 × 2, damit kein Titel abgeschnitten wird */
@media (min-width: 761px) and (max-width: 980px) {
  .cards, .cards.res { flex: 0 0 auto; grid-template-columns: 1fr 1fr; grid-auto-rows: 112px; }
}
/* sehr schmale Handys: Reiter enger, damit alle drei Platz haben */
@media (max-width: 380px) {
  .tab { padding: 0 7px; font-size: 11.5px; }
  .tabs { padding-left: 4px; }
}

/* Touch-Geräte (Tablet, Handy): kein Tooltip, darum Statuszeile und Hinweis
   umbrechen statt mit «…» kürzen; Sprachknöpfe gross genug zum Tippen */
@media (hover: none) {
  .status { height: auto; flex-basis: auto; padding: 4px 0; }
  .status-text { white-space: normal; }
  .rw-head { height: auto; min-height: 28px; flex-wrap: wrap; }
  .rw-hint { white-space: normal; overflow: visible; }
  .lang { height: auto; }
  .lang button { min-height: 28px; padding: 0 10px; font-size: 12px; }
}
