/* Reiter „Rechnung“ (konto/einstellungen.html): feste Reihenfolge Logo, Farbe, Tabellenkopf, Vorschau.
   Farbkreise in einer Reihe, letzter Kreis „Eigene Farbe“ klappt das Farbrad (konto/js/farbrad.js) mit
   Helligkeit und Hex-Feld ruhig auf. Ab 660 px Kartenbreite läuft die Mini-Vorschau rechts mit (sticky),
   schmaler steht sie kompakt direkt unter dem Tabellenkopf. */

/* Titel immer über dem Inhalt (wie Untitled UI auf schmalen Settings-Seiten), Trennlinien bleiben */
.fr-formular .e-abschnitt { grid-template-columns: minmax(0, 1fr); gap: 14px; }
.fr-raster { display: grid; grid-template-columns: minmax(0, 1fr); }
.fr-raster + .e-abschnitt { border-top: 1px solid var(--border); }
.fr-raster > .e-abschnitt { min-width: 0; }

@container (min-width: 660px) {
  .fr-raster { grid-template-columns: minmax(0, 1fr) 216px; column-gap: 32px; }
  .fr-raster > .e-abschnitt { grid-column: 1; }
  .fr-raster > .fr-vorschau {
    grid-column: 2; grid-row: 1 / span 3; align-self: start;
    position: sticky; top: calc(var(--k-kopf-hoehe, 61px) + 16px); margin: 20px 0;
  }
  .fr-raster > .fr-vorschau .fr-blatt { aspect-ratio: 1 / 1.3; max-width: none; }
}

/* Farbkreise: eine Reihe, Tippfläche 44 px hoch und so breit wie möglich (max. 44 px), Kreis bis 32 px */
.fr-farben {
  display: grid; grid-template-columns: repeat(9, minmax(0, 44px)); gap: 0; margin: -4px -4px 0;
}
.fr-farben .e-farbe {
  position: relative; width: 100%; min-width: 0; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: none; box-shadow: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  --kreis: min(32px, calc(100% - 6px));
}
.fr-farben .e-farbe::before, .fr-farben .e-farbe::after {
  content: ''; position: absolute; left: 50%; top: 50%; translate: -50% -50%; border-radius: 50%; aspect-ratio: 1;
}
.fr-farben .e-farbe::before {
  width: var(--kreis); background: var(--farbe);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 14%, transparent);
  transition: scale .15s var(--ease);
}
.fr-farben .e-farbe::after {
  width: calc(var(--kreis) + 8px); border: 2px solid transparent; box-sizing: border-box; transition: border-color .15s;
}
.fr-farben .e-farbe:hover::before { scale: 1.06; }
.fr-farben .e-farbe[aria-pressed="true"] { box-shadow: none; }
.fr-farben .e-farbe[aria-pressed="true"]::after { border-color: var(--farbe); }
.fr-farben .e-farbe:focus-visible { outline: none; box-shadow: none; }
.fr-farben .e-farbe:focus-visible::after { border-color: var(--primary); }

/* Eigene Farbe: Farbrad, bei eigener Farbe mit Punkt in der Mitte */
.fr-farben .fr-eigen::before {
  background: conic-gradient(from 90deg, #f04438, #f79009, #fac515, #17b26a, #06aed4, #2e90fa, #7a5af8, #ee46bc, #f04438);
}
.fr-farben .fr-eigen[aria-pressed="true"]::before {
  background:
    radial-gradient(circle, var(--farbe) 0 32%, #fff calc(32% + .5px) 42%, transparent calc(42% + .5px)),
    conic-gradient(from 90deg, #f04438, #f79009, #fac515, #17b26a, #06aed4, #2e90fa, #7a5af8, #ee46bc, #f04438);
}
.fr-farben .fr-eigen[aria-pressed="true"]::after,
.fr-farben .fr-eigen[aria-expanded="true"]::after { border-color: var(--text); }

/* Hex-Feld mit Farbpunkt (steht im aufgeklappten Farbrad unter der Helligkeit) */
.fr-hex { display: flex; flex-direction: column; gap: 6px; }
.fr-hex-feld { position: relative; display: block; width: 148px; max-width: 100%; }
.fr-hex-eingabe { padding-left: 40px; font-family: var(--mono); font-size: 15px; text-transform: uppercase; }
.fr-hex-punkt {
  position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 5px;
  background: var(--farbe, #1D2939); box-shadow: inset 0 0 0 1px rgb(16 24 40 / .15); pointer-events: none;
}
/* Ohne Skript (oder bevor es läuft) steht das Hex-Feld unter den Kreisen */
.fr-farbe > .fr-hex { margin-top: 12px; }

/* Farbrad: ohne Kasten, klappt weich auf (Zeilenhöhe 0fr → 1fr), zu nicht sichtbar und nicht erreichbar */
.fr-feld {
  display: grid; grid-template-rows: 0fr; visibility: hidden;
  transition: grid-template-rows .22s var(--ease), visibility 0s linear .22s;
}
.fr-feld.ist-offen { grid-template-rows: 1fr; visibility: visible; transition: grid-template-rows .22s var(--ease); }
.fr-innen {
  /* Seitlicher Puffer, damit Griff und Fokusring am Radrand nicht abgeschnitten werden */
  min-height: 0; overflow: hidden; margin: 0 -20px; padding: 0 20px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px;
  transition: padding .22s var(--ease);
}
.fr-feld.ist-offen .fr-innen { padding-block: 16px 6px; }
.fr-rad {
  position: relative; flex: none; width: 168px; aspect-ratio: 1; border-radius: 50%; cursor: crosshair; touch-action: none;
  background: radial-gradient(circle closest-side, #fff, rgb(255 255 255 / 0)), conic-gradient(from 90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  box-shadow: inset 0 0 0 1px rgb(16 24 40 / .1);
}
/* Helligkeit dunkelt das ganze Rad ab, damit es zur gewählten Farbe passt */
.fr-rad::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: #000; opacity: var(--fr-dunkel, 0); pointer-events: none; }
.fr-griff {
  position: absolute; z-index: 1; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%;
  border: 3px solid #fff; background: var(--fr-farbe, transparent); cursor: grab;
  box-shadow: 0 0 0 1px rgb(16 24 40 / .3), 0 2px 6px rgb(16 24 40 / .3);
}
/* Unsichtbare Tippfläche 44 px um den Griff */
.fr-griff::before { content: ''; position: absolute; inset: -11px; border-radius: 50%; }
.fr-griff:focus-visible { outline: none; box-shadow: 0 0 0 1px rgb(16 24 40 / .3), 0 0 0 5px var(--primary); }
.fr-seite { flex: 1 1 200px; min-width: 0; max-width: 280px; display: flex; flex-direction: column; gap: 14px; }
.fr-hell {
  --fr-hell-bis: #fff; -webkit-appearance: none; appearance: none; width: 100%; height: 12px; margin: 14px 0 12px; border-radius: 99px; cursor: pointer;
  background: linear-gradient(to right, #000, var(--fr-hell-bis)); box-shadow: inset 0 0 0 1px rgb(16 24 40 / .12);
}
.fr-hell::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 1px rgb(16 24 40 / .25), 0 2px 6px rgb(16 24 40 / .3); }
.fr-hell::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 1px rgb(16 24 40 / .25), 0 2px 6px rgb(16 24 40 / .3); }
.fr-hell:focus-visible { outline: none; box-shadow: inset 0 0 0 1px rgb(16 24 40 / .12), var(--ring); }
.fr-hell-feld { gap: 0; }

/* Tabellenkopf als Segment */
.fr-segment {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; justify-self: start; align-self: start; gap: 2px; padding: 3px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2);
}
.fr-segment-teil {
  display: flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 20px; border-radius: 6px;
  font-size: 14px; font-weight: 600; color: var(--text-3); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.fr-segment-teil:hover { color: var(--text); }
.fr-segment-teil:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.fr-segment-teil:has(input:focus-visible) { box-shadow: var(--ring); }

/* Mini-Vorschau: immer hell wie das echte Blatt. Am Handy kompakt (höchstens 220 px hoch) */
.fr-vorschau {
  min-width: 0; margin: 0 0 20px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px 16px 16px; border-radius: var(--radius-lg); background: var(--surface-2);
  border: 1px solid var(--border);
}
.fr-vorschau-text { align-self: stretch; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--text-3); }
.fr-blatt {
  --fr-titel: #1D2939; --fr-kopf-grund: #1D2939; --fr-kopf-schrift: #fff; --fr-kopf-linie: transparent;
  --fr-gesamt-grund: #E8EAEB; --fr-gesamt-schrift: #1D2939;
  width: 100%; max-width: 220px; max-height: 172px; display: flex; flex-direction: column; gap: 5px; padding: 14px 12px 14px;
  overflow: hidden; background: #fff; color: #344054; color-scheme: light; border-radius: 4px;
  box-shadow: 0 0 0 1px rgb(16 24 40 / .06), 0 4px 10px -2px rgb(16 24 40 / .1);
  font-size: 8px; line-height: 1.2; font-variant-numeric: tabular-nums;
}
.fr-blatt-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-height: 20px; }
.fr-blatt-titel { font-size: 13px; font-weight: 700; letter-spacing: -.01em; color: var(--fr-titel); transition: color .15s; }
.fr-blatt-logo { display: flex; justify-content: flex-end; max-width: 64px; height: 22px; }
.fr-blatt-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fr-blatt-adresse { display: flex; flex-direction: column; gap: 3px; margin: 2px 0 6px; }
.fr-blatt-adresse i, .fr-blatt-posten i, .fr-blatt-fuss i { display: block; height: 4px; border-radius: 2px; background: #E4E7EC; }
.fr-blatt-adresse i:first-child { width: 42%; }
.fr-blatt-adresse i:last-child { width: 30%; }
.fr-blatt-zeile { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 5px; white-space: nowrap; }
.fr-blatt-tabkopf {
  background: var(--fr-kopf-grund); color: var(--fr-kopf-schrift); font-weight: 600; border-radius: 1px;
  box-shadow: inset 0 -1.5px 0 var(--fr-kopf-linie); transition: background-color .15s, color .15s;
}
.fr-blatt-posten { padding-block: 6px; border-bottom: 1px solid #EAECF0; }
.fr-blatt-posten i:first-child { width: 55%; }
.fr-blatt-posten i:last-child { width: 20%; }
.fr-blatt-gesamt {
  margin: 4px 0 0 32%; background: var(--fr-gesamt-grund); color: var(--fr-gesamt-schrift); font-weight: 700;
  transition: background-color .15s, color .15s;
}
/* Fußzeile nur auf dem großen Blatt (Desktop), unten angesetzt */
.fr-blatt-fuss { display: none; gap: 6px; margin-top: auto; padding-top: 8px; border-top: 1px solid #EAECF0; }
.fr-blatt-fuss i { flex: 1; height: 3px; }
@container (min-width: 660px) {
  .fr-raster > .fr-vorschau .fr-blatt { max-height: none; }
  .fr-raster > .fr-vorschau .fr-blatt-fuss { display: flex; }
}

/* Schmal: Rad und Regler bleiben nebeneinander, damit die Vorschau darunter nah bleibt.
   Das Rad wächst mit der Kartenbreite (bei 390 px Bildschirm etwa 150 px, höchstens 176 px). */
@container (max-width: 659.98px) {
  .fr-innen { flex-wrap: nowrap; align-items: center; gap: 16px; }
  .fr-rad { width: clamp(120px, 48cqw, 176px); }
  .fr-seite { flex: 1 1 0; max-width: none; gap: 10px; }
  .fr-hex-feld { width: 100%; max-width: 148px; }
  .fr-hex-eingabe { padding-left: 36px; font-size: 14px; }
  .fr-hex-punkt { left: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .fr-farben .e-farbe::before, .fr-blatt *, .fr-feld, .fr-feld.ist-offen, .fr-innen { transition: none; }
}
