/* Steuer-App */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg: #111214;
    --box: #1d1f23;
    --line: #2e3138;
    --text: #e9eaec;
    --muted: #8c9099;
    --accent: #ff9f0a;
    --red: #ff5a5f;
}

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); }
h1, h2 { margin: 0 0 .6em; }
h2 { font-size: 1.1em; margin-top: 1.2em; }
h2:first-child { margin-top: 0; }
p { margin: 0 0 .8em; }
code { background: #000; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.muted { color: var(--muted); }
.small { font-size: .85em; }
.label { color: var(--muted); font-size: .8em; text-transform: uppercase; letter-spacing: .06em; }
.big { font-size: 1.4em; font-weight: 600; }

/* Navigation */
.top {
    position: sticky; top: 0; z-index: 5;
    background: rgba(17, 18, 20, .92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    padding-top: env(safe-area-inset-top);
}
nav { display: flex; max-width: 760px; margin: 0 auto; }
nav a {
    flex: 1; text-align: center; padding: 14px 4px;
    color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95em;
    border-bottom: 2px solid transparent;
}
nav a.active { color: var(--text); border-bottom-color: var(--accent); }

/* Ansichten umschalten */
.panel { display: none; max-width: 760px; margin: 0 auto; padding: 12px; }
body.view-grid #panel-grid,
body.view-input #panel-input,
body.view-users #panel-users,
body.view-texts #panel-texts,
body.view-settings #panel-settings,
body.view-app #panel-app { display: block; }

.box { background: var(--box); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; }

.flash { max-width: 736px; margin: 12px auto 0; padding: 10px 14px; border-radius: 10px; }
.flash.ok { background: #183a24; color: #8ee6a8; }
.error { background: #3a1818; color: #ffaaaa; padding: 10px 14px; border-radius: 10px; }

/* Formulare */
input[type=text], input[type=password], input[type=number], textarea, select {
    width: 100%; margin-top: 4px;
    background: #0c0d0f; color: var(--text);
    border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 12px; font: inherit;
}
textarea { resize: vertical; }
input[type=color] { width: 100%; height: 42px; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; background: #0c0d0f; padding: 3px; }
.form label { display: block; margin-bottom: 12px; font-size: .92em; }
.form label.check { display: flex; gap: 10px; align-items: flex-start; }
.form label.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row input { flex: 1 1 200px; margin-top: 0; }

button, .button {
    display: inline-block; border: 0; border-radius: 10px; cursor: pointer;
    background: var(--accent); color: #000; font: inherit; font-weight: 600;
    padding: 10px 16px; text-decoration: none; text-align: center;
}
button.ghost, .button.ghost { background: #2a2d33; color: var(--text); }
button.danger { color: var(--red); }

/* Login */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth .box { width: 100%; max-width: 360px; }
.auth input { margin-bottom: 10px; }
.auth button { width: 100%; }

/* Status */
.status { display: flex; gap: 16px; align-items: center; }
.status img { width: 84px; height: auto; flex: none; border-radius: 6px; }
.status button { margin-top: 10px; padding: 6px 12px; font-size: .9em; }

/* Kartenraster */
.grid { padding: 10px; }
.suit-row { display: grid; grid-template-columns: repeat(13, 1fr); gap: 4px; margin-bottom: 14px; }
.suit-row:last-child { margin-bottom: 0; }
.pick {
    background: #f3f3f3; color: #111; padding: 8px 0 6px; border-radius: 7px;
    font-weight: 700; font-size: 15px; line-height: 1.1; min-width: 0;
    display: flex; flex-direction: column; align-items: center;
    touch-action: manipulation;
}
.pick small { font-size: 13px; font-weight: 400; }
.suit-row.red .pick { color: #c8102e; }
.pick.active { background: var(--accent); color: #000; box-shadow: 0 0 0 2px #fff inset; }
.pick.sending { opacity: .5; }

@media (max-width: 600px) {
    .suit-row { grid-template-columns: repeat(7, 1fr); }
    .pick { padding: 10px 0 8px; }
}

.legend { border-collapse: collapse; margin-bottom: .8em; }
.legend td { padding: 4px 12px 4px 0; vertical-align: top; }
.legend td:first-child { font-weight: 700; font-size: 1.2em; color: var(--accent); }

/* Getarnter Rechner (Vollbild, keine Spur der App sichtbar) */
#calc {
    display: none;
    position: fixed; inset: 0; z-index: 10;
    background: #000; color: #fff;
    flex-direction: column; justify-content: flex-end;
    padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 20px);
    font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Roboto, sans-serif;
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    touch-action: manipulation;
}
body.view-calc #calc { display: flex; }
body.view-calc .top, body.view-calc .flash,
body.view-swipe .top, body.view-swipe .flash,
body.view-taps .top, body.view-taps .flash,
body.view-zones .top, body.view-zones .flash { display: none; }

.calc-dot {
    position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 14px;
    width: 5px; height: 5px; border-radius: 50%; opacity: 0; transition: opacity .2s;
}
.calc-dot.on { opacity: 1; }

.calc-display {
    text-align: right; font-size: 84px; font-weight: 300; line-height: 1.1;
    padding: 0 10px 12px; white-space: nowrap; overflow: hidden;
    max-width: 440px; width: 100%; margin: 0 auto;
}
.calc-keys {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
    max-width: 440px; width: 100%; margin: 0 auto;
}
.calc-keys button {
    aspect-ratio: 1; border-radius: 50%; padding: 0;
    background: #333; color: #fff;
    font-size: 34px; font-weight: 400;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
}
.calc-keys button:active { background: #737373; }
.calc-keys .fn { background: #a5a5a5; color: #000; font-size: 28px; }
.calc-keys .fn:active { background: #d9d9d9; }
.calc-keys .op { background: #ff9f0a; color: #fff; font-size: 40px; }
.calc-keys .op:active { background: #fcc78d; }
.calc-keys .op.active { background: #fff; color: #ff9f0a; }
.calc-keys .zero { grid-column: span 2; aspect-ratio: auto; border-radius: 999px; text-align: left; padding-left: 13%; }

/* Theme-Auswahl */
.themes { display: grid; gap: 8px; margin-bottom: 14px; }
.theme-opt { display: flex; align-items: center; gap: 10px; background: #0c0d0f; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 8px 8px; }
.theme-opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.theme-opt label { flex: 1; display: flex; align-items: center; gap: 12px; margin: 0; cursor: pointer; min-width: 0; }
.theme-opt input { position: absolute; opacity: 0; pointer-events: none; }
.theme-opt .swatch { flex: none; width: 44px; height: 44px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .15); }
.theme-opt .theme-text { display: flex; flex-direction: column; min-width: 0; }
.theme-opt small { color: var(--muted); font-size: .82em; line-height: 1.3; }
.theme-opt a { flex: none; font-size: .85em; font-weight: 600; text-decoration: none; }

/* Rechner: Löschtaste nur im Android-Stil */
.calc-keys .del { display: none; }

/* Rechner im Android-Stil (Material) */
#calc.skin-android { background: #121316; font-family: 'Google Sans', Roboto, 'Segoe UI', sans-serif; }
#calc.skin-android .calc-display { font-weight: 400; color: #e3e2e6; }
#calc.skin-android .calc-keys { gap: 12px; }
#calc.skin-android .calc-keys button { background: #2f3036; color: #e3e2e6; font-size: 30px; border-radius: 50%; }
#calc.skin-android .calc-keys button:active { border-radius: 30%; background: #45464f; }
#calc.skin-android .calc-keys .fn { background: #4a4458; color: #e8def8; font-size: 24px; }
#calc.skin-android .calc-keys .fn:first-child { background: #8c4a60; color: #ffd9e2; }
#calc.skin-android .calc-keys .op { background: #3e4759; color: #d6e3ff; font-size: 32px; }
#calc.skin-android .calc-keys .op.active { background: #d6e3ff; color: #102f60; }
#calc.skin-android .calc-keys [data-k="="] { background: #adc6ff; color: #002e69; }
#calc.skin-android .calc-keys .zero { grid-column: auto; aspect-ratio: 1; border-radius: 50%; text-align: center; padding-left: 0; }
#calc.skin-android .calc-keys .del { display: block; }
#calc.skin-android .calc-keys button { transition: border-radius .15s, background .15s; }
/* Android: 0 , ⌫ = in der letzten Reihe */
#calc.skin-android [data-k="0"] { order: 1; }
#calc.skin-android [data-k="."] { order: 2; }
#calc.skin-android .del { order: 3; }
#calc.skin-android [data-k="="] { order: 4; }

/* Auswahl der Eingabemethode */
.method h2 { margin-top: 0; }
.method p { margin-bottom: .4em; }

/* Schwarzer Bildschirm */
#stealth {
    display: none;
    position: fixed; inset: 0; z-index: 10;
    background: #000;
    touch-action: none;
    overscroll-behavior: none;
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    cursor: none;
}
body.view-swipe #stealth, body.view-taps #stealth, body.view-zones #stealth { display: block; }
body.view-swipe, body.view-taps, body.view-zones { overflow: hidden; background: #000; }

.stealth-dots {
    position: absolute; top: calc(env(safe-area-inset-top) + 10px); left: 0; right: 0;
    display: flex; justify-content: center; gap: 6px;
    opacity: 0; transition: opacity .2s; pointer-events: none;
}
.stealth-dots.on { opacity: 1; }
.stealth-dots i { width: 5px; height: 5px; border-radius: 50%; background: #1c1c1c; }
.stealth-dots.bad i { background: #2a1010; }
#stealth.practice .stealth-dots i { background: #6a6a6a; width: 8px; height: 8px; }
#stealth.practice .stealth-dots.bad i { background: #a33; }

.stealth-text {
    position: absolute; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 24px);
    text-align: center; color: #777; font-size: 17px; pointer-events: none;
}
.stealth-help { position: absolute; inset: 0; pointer-events: none; color: #555; }
.help-grid { position: absolute; inset: 0; display: grid; }
.help-grid.g2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.help-grid.g3 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); }
.help-grid span {
    border: 1px dashed #262626; display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 34px; color: #4d4d4d;
}
.help-grid small { font-size: 13px; }
.help-note, .help-compass em, .help-dial em, .help-text {
    position: absolute; left: 0; right: 0; top: 46%; text-align: center; font-style: normal; font-size: 15px; color: #555;
}
.help-note { top: auto; bottom: calc(env(safe-area-inset-bottom) + 60px); }
.help-compass span { position: absolute; font-size: 20px; color: #555; }
.help-compass .n { top: 12%; left: 50%; transform: translateX(-50%); }
.help-compass .s { bottom: 14%; left: 50%; transform: translateX(-50%); }
.help-compass .e { right: 6%; top: 50%; transform: translateY(-50%); }
.help-compass .w { left: 6%; top: 50%; transform: translateY(-50%); }
.help-dial { position: absolute; left: 50%; top: 50%; width: 92vmin; height: 92vmin; transform: translate(-50%, -50%); }
.help-dial span { position: absolute; transform: translate(-50%, -50%); font-size: 24px; color: #555; }
.help-text { line-height: 1.6; }

/* Anleitung */
.guide {
    position: fixed; inset: 0; z-index: 30;
    background: rgba(0, 0, 0, .75);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: calc(env(safe-area-inset-top) + 16px) 12px calc(env(safe-area-inset-bottom) + 16px);
}
.guide[hidden] { display: none; }
.guide-box { max-width: 560px; margin: 0 auto; background: var(--box); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.guide-box h2 { margin-top: 0; font-size: 1.3em; }
.guide-box .row { margin-top: 14px; }
.guide-practice { display: flex; gap: 10px; align-items: center; margin-top: 10px; font-size: .92em; }
.guide-practice[hidden] { display: none; }
.guide-flex { display: flex; gap: 14px; align-items: center; margin-bottom: .8em; }
.guide-flex p { margin: 0; }
.dial { width: 110px; height: 110px; flex: none; color: var(--text); font-size: 12px; fill: currentColor; }
.dial text { font-family: inherit; }
.zone-demo { flex: none; width: 96px; height: 150px; display: grid; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #000; }
.zone-demo.z2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.zone-demo.z3 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); }
.zone-demo span { border: 1px dashed #333; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 16px; font-weight: 600; }
.zone-demo span.r { color: #e5484d; }
.zone-demo small { font-size: 9px; font-weight: 400; color: var(--muted); }

/* ---------- Reiter „App“ (Digital Force App) ---------- */
.dot { width: 10px; height: 10px; border-radius: 50%; background: #444; display: inline-block; flex: none; }
.dot.online { background: #30d158; }
.dot.offline { background: var(--red); }
.app-online { margin-top: 6px; }
.app-number { font-size: 56px; text-align: center; font-variant-numeric: tabular-nums; padding: 4px 0 10px; }
.app-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.app-keypad button { font-size: 24px; padding: 14px 0; }
.app-send-status { min-height: 1.3em; margin: 10px 0 0; }
.app-send-status.ok { color: #30d158; }
.app-send-status.err { color: var(--red); }
.app-pair-code { font-size: 40px; letter-spacing: 6px; text-align: center; margin: 14px 0 6px; font-variant-numeric: tabular-nums; }
.app-pair-code.expired { opacity: .35; text-decoration: line-through; }
.app-qr { background: #fff; border-radius: 12px; padding: 8px; width: 240px; max-width: 100%; margin: 8px auto; }
.app-qr svg { display: block; width: 100%; height: auto; }
#app-pair .muted { text-align: center; }

/* Benutzerverwaltung */
details.user { border-top: 1px solid var(--line); padding: 10px 0; }
details.user:first-of-type { border-top: 0; }
details.user summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; list-style: none; }
details.user summary::-webkit-details-marker { display: none; }
details.user summary small { flex-basis: 100%; }
details.user form { margin-top: 12px; }
.badge { font-size: .72em; padding: 2px 8px; border-radius: 999px; background: #2a2d33; color: var(--muted); }
.badge.admin { background: rgba(255, 159, 10, .18); color: var(--accent); }
.auth input[type=email], .auth input[type=text] { margin-bottom: 10px; }
input[type=email] {
    width: 100%; margin-top: 4px;
    background: #0c0d0f; color: var(--text);
    border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 12px; font: inherit;
}

.legend td:first-child { white-space: nowrap; }
/* Viele Reiter: auf schmalen Handys waagerecht wischbar */
nav { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
nav::-webkit-scrollbar { display: none; }
@media (max-width: 560px) {
    nav a { flex: 1 0 auto; padding: 14px 11px; font-size: .9em; }
}
