/* CCU Planner: Design von Crew Alert. Hell: „Gerät“, Dunkel: Aegis. */

:root {
    --casing: #c9d1d6;
    --plate: #e4e9ec;
    --plate-edge: #ffffff;
    --plate-shadow: 0 1px 0 #00000022, 0 6px 14px -10px #1d232766;
    --ink: #1d2327;
    --mist: #5d6a72;
    --glass: #0f2a33;
    --glass-edge: #ffffff14;
    --readout: #bff3ff;
    --readlabel: #7fb3c2;
    --signal: #ff8a3d;
    --signal-hover: #ff9a57;
    --signal-ink: #1d1208;
    --nav-on: #1d2327;
    --nav-on-ink: #e4e9ec;
    --highlight: #1d2327;
    --rule: #0000001a;
    --field: #f4f7f8;
    --field-line: #9aa7af;
    --disabled: #b6bfc5;
    --disabled-ink: #5d6a72;
    --ok: #1f8a4c;
    --busy: #a8690f;
    --bad: #c2412d;
    --chart: #d4572a;
    --planned: #f0b840;
    --owned: #1f8a4c;
    --cal-sale: #f08a3c;
    --cal-patch: #3b82d6;
    --cal-ingame: #2f9e5a;
    --cal-other: #8b6cc9;
    --r: 4px;

    --display: "Big Shoulders Text", "Bahnschrift", "Segoe UI", sans-serif;
    --body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --casing: #1d242b;
    --plate: #262f38;
    --plate-edge: #ffffff0f;
    --plate-shadow: inset 0 0 0 1px #ffffff0f;
    --ink: #e3e8ec;
    --mist: #8796a3;
    --glass: #0d1216;
    --glass-edge: #ffffff12;
    --readout: #f2f5f7;
    --readlabel: #7d8e9b;
    --signal: #d23c32;
    --signal-hover: #e0483d;
    --signal-ink: #ffffff;
    --nav-on: #e3e8ec;
    --nav-on-ink: #1d242b;
    --highlight: #e3e8ec;
    --rule: #ffffff12;
    --field: #1a2128;
    --field-line: #3b4855;
    --disabled: #323d48;
    --disabled-ink: #8796a3;
    --ok: #4cc38a;
    --busy: #e0b341;
    --bad: #f0a33c;
    --chart: #e0683b;
    --planned: #e0b341;
    --owned: #4cc38a;
    --cal-sale: #ff9a57;
    --cal-patch: #5aa9ff;
    --cal-ingame: #4cc38a;
    --cal-other: #a98be0;
    --r: 2px;

    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    min-height: 100vh;
    background: var(--casing);
    color: var(--ink);
    font-family: var(--body);
    font-size: 16px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: underline; text-decoration-color: var(--mist); text-underline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { a:hover { text-decoration-color: var(--ink); } }

h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.1; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px 32px; }
.wrap.wide { max-width: none; }

.head { padding: 20px 0 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.title { font-size: 38px; margin: 0; letter-spacing: 0.01em; }
.title a { text-decoration: none; }
.subtitle { color: var(--mist); font-size: 15px; margin: 2px 0 0; }
.who { color: var(--mist); font-size: 15px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.who strong { color: var(--ink); font-weight: 600; }
/* „Weitere Tools“ über „SC-Kalender“, beide gleich breit */
.who-stack { display: flex; flex-direction: column; gap: 4px; }
.who-stack .btn { width: 100%; }

/* Fenster „Weitere Tools“ */
dialog.tools { width: min(440px, calc(100vw - 32px)); padding: 14px 16px 16px; border: 0; border-radius: var(--r); background: var(--plate); color: var(--ink); box-shadow: 0 12px 40px #00000088; }
dialog.tools::backdrop { background: #00000088; }
.tools-empty { margin: 12px 0 0; }
.tools-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.tools-list a { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--field-line); color: var(--ink); text-decoration: none; }
.tools-list .muted { font-size: 14px; }
@media (hover: hover) and (pointer: fine) { .tools-list a:hover { background: var(--rule); } }

/* Twitch-Knopf: Farbe von Twitch, nicht die Signalfarbe, er führt aus der Seite heraus */
.twitch {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: calc(var(--r) - 1px);
    background: #9146ff; color: #fff; font-weight: 600; font-size: 15px; text-decoration: none;
}
@media (hover: hover) and (pointer: fine) { .twitch:hover { background: #a970ff; } }
.twitch:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }

.theme-toggle {
    position: relative; display: inline-flex; align-items: center; justify-content: space-between;
    width: 64px; height: 30px; padding: 0 8px; border-radius: 15px; cursor: pointer;
    background: var(--glass); border: 0; box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 3px 8px #00000066;
    color: var(--readlabel); font-size: 14px;
}
.theme-toggle .knob {
    position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
    background: var(--plate); box-shadow: 0 1px 2px #00000066; transition: transform 0.2s ease;
}
:root[data-theme="dark"] .theme-toggle .knob { transform: translateX(34px); }
.theme-toggle:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }

nav.tabs {
    display: flex; flex-wrap: wrap; gap: 2px; width: max-content; max-width: 100%;
    margin-bottom: 16px; padding: 3px; background: var(--plate); border-radius: var(--r);
    box-shadow: var(--plate-shadow);
}
nav.tabs a { padding: 6px 13px; border-radius: calc(var(--r) - 1px); color: var(--mist); text-decoration: none; font-weight: 500; }
@media (hover: hover) and (pointer: fine) { nav.tabs a:hover { color: var(--ink); } }
nav.tabs a.active { background: var(--nav-on); color: var(--nav-on-ink); }

.card {
    position: relative; padding: 18px 20px; margin-bottom: 14px;
    background: var(--plate); border-radius: var(--r);
    box-shadow: inset 0 1px 0 var(--plate-edge), var(--plate-shadow);
}
.card h2 { font-size: 26px; margin: 0 0 6px; }
.muted { color: var(--mist); }

:root[data-theme="dark"] .card { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%); }

.screen {
    margin-top: 12px; padding: 12px 14px; border-radius: calc(var(--r) - 1px);
    background: var(--glass); color: var(--readout);
    box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 10px 30px #00000066;
}
.screen.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px 16px; }
.screen .k { font-size: 12px; color: var(--readlabel); }
.screen .v { font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.1; color: var(--readout); overflow-wrap: anywhere; }

/* Knöpfe: einzige Stelle mit der Signalfarbe */
.btn { background: var(--signal); color: var(--signal-ink); }
.btn {
    display: inline-block; font-family: var(--body); font-size: 15px; font-weight: 600;
    padding: 9px 16px; border: 0; border-radius: calc(var(--r) - 1px);
    cursor: pointer; text-decoration: none; text-align: center;
}
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--signal-hover); text-decoration: none; } }
.btn.secondary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--field-line); }
@media (hover: hover) and (pointer: fine) { .btn.secondary:hover { background: var(--rule); } }
.btn.small { font-size: 13px; padding: 4px 10px; }
/* Gefährliche Aktion (z. B. Kette leeren): rot umrandet, füllt sich beim Darüberfahren */
.btn.secondary.danger { color: var(--missing, var(--bad)); box-shadow: inset 0 0 0 1px var(--missing, var(--bad)); }
@media (hover: hover) and (pointer: fine) { .btn.secondary.danger:hover { background: var(--missing, var(--bad)); color: #fff; } }
.btn:disabled, .btn.secondary:disabled { background: var(--disabled); color: var(--disabled-ink); box-shadow: none; cursor: not-allowed; }

form.inline { display: inline; }

input[type=number], input[type=text], input[type=search], select {
    font-family: var(--body); font-size: 15px; padding: 8px 10px; max-width: 100%;
    background: var(--field); color: var(--ink); border: 1px solid var(--field-line); border-radius: calc(var(--r) - 1px);
}
input[type=file] { font-family: var(--body); font-size: 15px; max-width: 100%; }
input:focus, select:focus { outline: 2px solid var(--highlight); outline-offset: 1px; }
label { font-size: 14px; color: var(--mist); }
code { font-size: 0.92em; background: var(--rule); padding: 1px 5px; border-radius: 3px; }

.flash {
    background: var(--plate); border-radius: var(--r); padding: 12px 16px; margin-bottom: 14px;
    box-shadow: inset 4px 0 0 var(--busy), var(--plate-shadow);
}
.flash.ok { box-shadow: inset 4px 0 0 var(--ok), var(--plate-shadow); }

.foot {
    margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--rule);
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    color: var(--mist); font-size: 13px;
}

/* Feedback-Fenster, auf jeder Seite verfügbar */
dialog.feedback { width: min(440px, calc(100vw - 32px)); padding: 16px 18px; border: 0; border-radius: var(--r); background: var(--plate); color: var(--ink); box-shadow: 0 12px 40px #00000088; }
dialog.feedback::backdrop { background: #00000088; }
dialog.feedback h2 { margin: 0; font-size: 20px; }
dialog.feedback p { margin: 0; }
dialog.feedback textarea { width: 100%; resize: vertical; font: inherit; }
dialog.feedback .row.end { display: flex; justify-content: flex-end; gap: 8px; }

/* SC-Kalender: Pop-up aus dem Kopf */
/* Oben verankert statt mittig: Sonst springt das Fenster beim Blättern, wenn die Monate verschieden hoch sind. */
dialog.calendar { width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: max(16px, 6vh) auto auto; overflow: auto; padding: 14px 16px 16px; border: 0; border-radius: var(--r); background: var(--plate); color: var(--ink); box-shadow: 0 12px 40px #00000088; }
dialog.calendar::backdrop { background: #00000088; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-head h2 { margin: 0; font: 700 20px/1.1 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.cal-review { margin-left: auto; }
/* Umschalter Sale-Rückblick | Patch-Historie */
.switch-head { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; justify-content: space-between; }
.switch-head h2 { margin: 0; }
.review-switch { display: inline-flex; border: 1px solid var(--field-line); border-radius: 8px; overflow: hidden; }
.review-switch a { padding: 6px 12px; font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; }
.review-switch a.on { background: var(--nav-on); color: var(--nav-on-ink); }
@media (hover: hover) and (pointer: fine) { .review-switch a:not(.on):hover { background: var(--rule); } }
.cal-link + .cal-link { margin-left: 12px; }
.cal-close { border: 0; background: transparent; color: var(--mist); font-size: 18px; line-height: 1; padding: 4px 6px; cursor: pointer; border-radius: var(--r); }
@media (hover: hover) and (pointer: fine) { .cal-close:hover { color: var(--ink); background: var(--rule); } }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 12px; padding: 0 0 10px; list-style: none; border-bottom: 1px solid var(--rule); font-size: 12px; color: var(--mist); }
.cal-legend li { display: flex; align-items: center; gap: 6px; }
.cal-swatch { display: inline-block; width: 18px; height: 10px; border-radius: 2px; background: var(--c); }
.cal-swatch.guessed { --c: var(--mist); background: repeating-linear-gradient(135deg, var(--c) 0 3px, transparent 3px 6px); border: 1.5px dashed var(--c); }
.kind-sale { --c: var(--cal-sale); }
.kind-patch { --c: var(--cal-patch); }
.kind-ingame { --c: var(--cal-ingame); }
.kind-other { --c: var(--cal-other); }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-nav strong { font: 700 16px var(--display); letter-spacing: .03em; }
.cal-step { width: 30px; height: 26px; border: 1px solid var(--field-line); border-radius: var(--r); background: transparent; color: var(--ink); font-size: 16px; line-height: 1; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .cal-step:hover { background: var(--rule); } }
.cal-msg { margin: 0 0 6px; font-size: 13px; }
.cal-msg:empty { display: none; }
.cal-weekdays, .cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekdays div { padding: 2px 0; text-align: center; font-size: 11px; color: var(--mist); }
.cal-week { grid-auto-rows: min-content; row-gap: 2px; min-height: 56px; padding-bottom: 4px; border-top: 1px solid var(--rule); }
.cal-day { grid-row: 1; padding: 3px 4px 1px; font-size: 11px; }
.cal-day.out { opacity: .4; }
.cal-day.today span { display: inline-block; min-width: 18px; padding: 0 4px; border-radius: 999px; background: var(--ink); color: var(--plate); font-weight: 700; text-align: center; }
.cal-bar {
    min-width: 0; height: 18px; margin: 0 1px; padding: 0 5px; border: 0; border-radius: 3px;
    background: var(--c); color: #10161a; font: 600 11px/18px var(--body); text-align: left;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.cal-bar.guessed { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 38%, transparent) 0 5px, color-mix(in srgb, var(--c) 12%, transparent) 5px 10px); border: 1.5px dashed var(--c); color: var(--ink); line-height: 15px; }
.cal-bar.cont-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-bar.cont-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-bar.on, .cal-bar:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.cal-detail { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule); font-size: 13px; }
.cal-detail h3 { margin: 4px 0 2px; font: 600 15px/1.25 var(--body); overflow-wrap: anywhere; }
.cal-kind { display: flex; align-items: center; gap: 6px; color: var(--mist); font-size: 12px; }
.cal-dot { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.cal-tag { padding: 0 5px; border: 1px dashed var(--mist); border-radius: 3px; font-size: 11px; }
.cal-when { color: var(--mist); }
.cal-note { margin: 6px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.cal-link { display: inline-block; margin-top: 6px; }

/* Sprache: Flaggen im Kopf. Angemeldet eine Flagge, darunter gleitet die andere heraus; auf der Startseite beide nebeneinander. */
.flag { display: block; width: 30px; height: 18px; border-radius: 2px; box-shadow: 0 0 0 1px var(--rule); }
.lang { position: relative; }
.lang-current, .lang-menu a, .lang-both a {
    display: block; padding: 5px; border: 0; border-radius: var(--r); background: transparent; cursor: pointer; line-height: 0;
}
@media (hover: hover) and (pointer: fine) { .lang-current:hover, .lang-menu a:hover, .lang-both a:hover { background: var(--rule); } }
.lang-current:focus-visible, .lang-menu a:focus-visible, .lang-both a:focus-visible { outline: 2px solid var(--highlight); outline-offset: 1px; }
.lang-menu {
    position: absolute; left: 0; top: 100%; z-index: 30; margin-top: 4px; padding: 2px;
    background: var(--plate); border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--rule), var(--plate-shadow);
    opacity: 0; transform: translateY(-8px); clip-path: inset(0 0 100% 0); visibility: hidden;
    transition: opacity .18s ease, transform .22s cubic-bezier(.2, .8, .2, 1), clip-path .22s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .22s;
}
.lang.open .lang-menu { opacity: 1; transform: none; clip-path: inset(0 0 0 0); visibility: visible; transition-delay: 0s; }
.lang-both { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--field-line); }
.lang-both a { opacity: .45; filter: saturate(.4); transition: opacity .15s ease, filter .15s ease; }
.lang-both a.on { opacity: 1; filter: none; background: var(--rule); }
@media (hover: hover) and (pointer: fine) { .lang-both a:hover { opacity: 1; filter: none; } }
@media (prefers-reduced-motion: reduce) { .lang-menu { transition: none; } }
.rsi-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }

/* Daten löschen: zwei Teil-Löschungen, darunter „Alles löschen“ deutlich abgesetzt */
.delete-option { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; padding: 12px 0; border-top: 1px solid var(--rule); }
.delete-option > div { flex: 1 1 320px; }
.delete-option h3, .delete-all h3 { margin: 0 0 4px; }
.delete-option p { margin: 0; }
.delete-all { margin-top: 14px; padding: 14px 16px; border: 2px solid var(--danger); border-radius: var(--r); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.delete-all h3 { color: var(--danger); }
.btn.danger-solid { background: var(--danger); color: #fff; }
@media (hover: hover) and (pointer: fine) { .btn.danger-solid:hover { background: color-mix(in srgb, var(--danger) 80%, #000); } }
:root { --danger: #c62828; }
:root[data-theme="dark"] { --danger: #ef4f4f; }
.delete-option .btn.secondary.danger { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
@media (hover: hover) and (pointer: fine) { .delete-option .btn.secondary.danger:hover { background: var(--danger); color: #fff; } }

/* Geteilte Links: Liste in Konto und im Teilen-Fenster */
.share-btn svg { vertical-align: -2px; }
.share-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.share-row a { overflow-wrap: anywhere; flex: 1 1 220px; min-width: 0; }
.share-row .share-label { font-weight: 600; }
dialog.share-dialog { width: min(520px, calc(100vw - 32px)); max-width: none; }
dialog.share-dialog h3 { margin: 14px 0 4px; font-size: 14px; }
dialog.share-dialog label.check { display: flex; align-items: center; gap: 8px; }
dialog.share-dialog label.check input { width: auto; margin: 0; }
dialog.share-dialog select { display: block; margin-top: 4px; }

/* ---- Handy und PWA (iPhone) ---- */
html {
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}
body { min-height: 100dvh; }
/* Als App vom Home-Bildschirm läuft die Seite bis unter Statusleiste und Dynamic Island; der Inhalt hält Abstand */
.wrap {
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-bottom: max(32px, calc(16px + env(safe-area-inset-bottom, 0px)));
}
button, a, [role="button"], summary, label { touch-action: manipulation; }
button, .btn, nav.tabs a, summary { -webkit-user-select: none; user-select: none; }
.btn:active, .cal-step:active, .cal-close:active { filter: brightness(0.92); }
/* Unter 16 px zoomt Safari beim Antippen eines Felds in die Seite und nicht wieder heraus */
@media (pointer: coarse) {
    input, select, textarea { font-size: 16px !important; }
}
/* Als App: Statusleiste (weiße Schrift) bekommt einen festen dunklen Streifen, Inhalt scrollt darunter durch */
@media (display-mode: standalone) {
    body::before {
        content: ""; position: fixed; z-index: 100; top: 0; left: 0; right: 0;
        height: env(safe-area-inset-top, 0px); background: #1d2327; pointer-events: none;
    }
    :root[data-theme="dark"] body::before { background: var(--casing); }
}
