/* ======================================================
   Change Log – UI (Dark + Light Mode)
   (übersichtlichere Formular-Grid, hübsche Selects,
    kein Pfeil-Doppel, saubere Abstände)
   ====================================================== */

/* ---------- Theme Tokens ---------- */
:root {
    --bg: #1a1a1a;
    --surface: #1a1a1a;
    --surface-2: #1a1a1a;
    --border: #262b37;
    --text: #e6e9ef;
    --muted: #a6adbb;
    --chip: #222632;
    --chip-active: #2e3342;
    --accent: #f6b100;
    --focus: color-mix(in oklab, var(--accent) 36%, transparent);
    --green: #2fbf71;
    --blue: #3b82f6;
    --orange: #f59f00;
    --red: #e5484d;
    --cyan: #22b8cf;
    --violet: #7c3aed;
    --gray: #868e96;
    --input-bg: rgba(255, 255, 255, .04);
    --input-border: #2a3142;
    --radius: 12px;
    --shadow: 0 12px 32px rgba(0, 0, 0, .22);
    --shadow-sm: 0 6px 16px rgba(0, 0, 0, .14);
    --btn-bg: #232838;
    --btn-text: var(--text);
    --btn-border: #2c3446;
    --btn-primary-bg: var(--accent);
    --btn-primary-text: #14120a;
    --link: #8ab8ff;

    /* Select-Pfeil (SVG, currentColor) */
    --select-arrow: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='currentColor' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
}

body.light-mode {
    --bg: #f6f7fb;
    --surface: #fff;
    --surface-2: #f9fafc;
    --border: #e7e9ef;
    --text: #0b1220;
    --muted: #5b6477;
    --chip: #eef0f5;
    --chip-active: #e1e5ee;
    --input-bg: #fff;
    --input-border: #d7dbe4;
    --btn-bg: #f2f4f8;
    --btn-text: #0b1220;
    --btn-border: #d9dee8;
    --btn-primary-text: #1b1403;
    --link: #2f6ae5;
}

/* ---------- Base ---------- */
* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
    background: radial-gradient(60% 80% at 10% 0%, rgba(246, 177, 0, .06), transparent 60%), var(--bg);
    color: var(--text);
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------- Page / Header / Tools ---------- */
.cl-page {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 14px;
}

.cl-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}

.cl-title-wrap .cl-title {
    margin: 0;
    font-size: 26px;
    letter-spacing: .2px;
}

.cl-title-wrap .cl-sub {
    display: inline-block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.cl-tools {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.cl-search-wrap {
    flex: 1 1 320px;
    min-width: 240px;
}

.cl-search-wrap>input {
    width: 100%;
}

/* ---------- Inputs & Buttons ---------- */
input[type="search"],
input[type="text"],
input[type="url"],
input[type="date"],
textarea,
select {
    border-radius: 10px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    padding: 10px 12px;
    outline: none;
    font: inherit;
    transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease;
    box-shadow: none;
}

input::placeholder,
textarea::placeholder {
    color: color-mix(in oklab, var(--muted) 85%, transparent);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--focus);
}

/* Date Icon */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) opacity(.8);
}

body.light-mode input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

/* Toolzeile-Höhen */
.cl-tools input[type="search"],
.cl-tools select,
.cl-tools .btn,
.cl-tools .file-btn {
    height: 38px;
    padding: 0 12px;
    line-height: 38px;
    border-radius: var(--radius);
}

/* Schönes Select – ohne Doppel-Pfeile */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: var(--input-bg) var(--select-arrow) no-repeat right 12px center;
    background-size: 12px 12px;
    padding-right: 36px;
    color: var(--text);
}

select:disabled {
    opacity: .65;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-text);
    cursor: pointer;
    font-weight: 600;
    transition: background-color .12s ease, border-color .12s ease, transform .06s ease;
    box-shadow: none;
    user-select: none;
}

.btn:hover {
    background: color-mix(in oklab, var(--btn-bg) 85%, #000 15%);
    border-color: color-mix(in oklab, var(--btn-border) 70%, #000 30%);
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--focus);
}

.btn.primary {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border-color: color-mix(in oklab, var(--btn-primary-bg) 60%, #000 40%);
}

.btn.primary:hover {
    background: color-mix(in oklab, var(--btn-primary-bg) 85%, #000 15%);
    border-color: color-mix(in oklab, var(--btn-primary-bg) 55%, #000 45%);
}

.btn.primary:active {
    background: color-mix(in oklab, var(--btn-primary-bg) 75%, #000 25%);
}

.btn.outline {
    background: transparent;
    border-color: var(--btn-border);
}

.btn.danger {
    background: #b23;
    color: #fff;
    border-color: #a12;
}

.btn.danger:hover {
    background: #a02233;
    border-color: #8f1f2e;
}

.file-btn {
    position: relative;
    overflow: hidden;
}

.file-btn input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ---------- List & Cards ---------- */
.cl-list {
    display: grid;
    gap: 12px;
}

.cl-empty {
    display: grid;
    place-items: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    color: var(--muted);
    background: color-mix(in oklab, var(--surface) 92%, black 8%);
}

body.light-mode .cl-empty {
    background: color-mix(in oklab, var(--surface) 92%, white 8%);
}

.cl-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: grid;
    gap: 8px;
    transition: border-color .12s ease, transform .06s ease, background-color .12s ease;
}

.cl-card:hover {
    border-color: color-mix(in oklab, var(--border) 65%, var(--accent) 35%);
    background: color-mix(in oklab, var(--surface) 94%, var(--accent) 6%);
}

.cl-top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
}

.cl-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    color: #fff;
}

.badge.added {
    background: var(--green);
}

.badge.changed {
    background: var(--orange);
}

.badge.fixed {
    background: var(--blue);
}

.badge.removed {
    background: var(--red);
}

.badge.security {
    background: var(--cyan);
}

.badge.note {
    background: var(--gray);
}

.badge.breaking {
    background: var(--violet);
}

.cl-version {
    font-weight: 800;
    letter-spacing: .2px;
}

.cl-date {
    color: var(--muted);
    font-size: 12px;
}

.cl-title-line {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: .2px;
}

.cl-details {
    color: var(--text);
}

.cl-details p {
    margin: .4em 0;
}

.cl-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: var(--chip);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11px;
}

.tag:hover {
    background: var(--chip-active);
}

.cl-actions {
    display: flex;
    gap: 8px;
}

.cl-actions .btn {
    height: 30px;
    padding: 0 10px;
}

/* ---------- Modal ---------- */
#cl-modal::backdrop {
    background: rgba(0, 0, 0, .55);
}

/* zentriert & responsiv */
#cl-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: none;
    border-radius: 16px;
    padding: 0;
    width: min(880px, 94vw);
    max-height: 90vh;
    background: var(--surface-2);
    color: var(--text);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin: 0;
}

.cl-form {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100%;
    max-height: 90vh;
}

.cl-form-head {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 8px;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.cl-form-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 900;
}

/* X-Button */
.icon-btn {
    --size: 34px;
    width: var(--size);
    height: var(--size);
    border-radius: 10px;
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-text);
    display: inline-grid;
    place-items: center;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease, transform .06s ease;
    box-shadow: none;
}

.icon-btn::before {
    content: "✕";
}

.icon-btn:hover {
    background: color-mix(in oklab, var(--btn-bg) 85%, #000 15%);
    border-color: color-mix(in oklab, var(--btn-border) 70%, #000 30%);
}

.icon-btn:active {
    transform: translateY(1px);
}

.icon-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--focus);
}

/* Body scrollt */
.cl-form-body {
    padding: 12px;
    overflow: auto;
}

/* Fallback für vorhandenes Markup */
.cl-form>.grid,
.cl-form>.ctrl,
.cl-form>.wide {
    padding: 12px;
}

/* ---------- Formular-Layout – übersichtlich ---------- */

/* Grundabstände & Label-Stil */
.ctrl {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ctrl>span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .2px;
}

.cl-form input,
.cl-form select,
.cl-form textarea {
    width: 100%;
}

/* Basisgrid: 2 Spalten auf Tablet, 3 Spalten auf Desktop */
.cl-form>.grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
}

/* Großes, strukturiertes Layout ab 880px */
@media (min-width: 880px) {
    .cl-form>.grid {
        grid-template-columns: repeat(3, minmax(180px, 1fr));
        align-items: start;
    }

    /* Reihen anordnen nach der aktuellen Feld-Reihenfolge:
     1 Version, 2 Date, 3 Type, 4 Breaking, 5 Title, 6 Details,
     7 Title_en, 8 Details_en, 9 Tags, 10 Link */
    .cl-form>.grid>.ctrl:nth-of-type(1) {
        grid-column: 1 / span 2;
    }

    /* Version */
    .cl-form>.grid>.ctrl:nth-of-type(2) {
        grid-column: 3;
    }

    /* Date  */
    .cl-form>.grid>.ctrl:nth-of-type(3) {
        grid-column: 1 / span 2;
    }

    /* Type  */
    .cl-form>.grid>.ctrl:nth-of-type(4) {
        grid-column: 3;
    }

    /* Breaking */
    .cl-form>.grid>.ctrl:nth-of-type(5) {
        grid-column: 1 / -1;
    }

    /* Title */
    .cl-form>.grid>.ctrl:nth-of-type(6) {
        grid-column: 1 / -1;
    }

    /* Details */
    .cl-form>.grid>.ctrl:nth-of-type(7) {
        grid-column: 1 / -1;
    }

    /* Title_en */
    .cl-form>.grid>.ctrl:nth-of-type(8) {
        grid-column: 1 / -1;
    }

    /* Details_en */
    .cl-form>.grid>.ctrl:nth-of-type(9) {
        grid-column: 1 / span 2;
    }

    /* Tags */
    .cl-form>.grid>.ctrl:nth-of-type(10) {
        grid-column: 3;
    }

    /* Link */
}

/* Footer */
.cl-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
    background: var(--surface-2);
    z-index: 2;
}

/* ---------- Utilities ---------- */
.muted {
    color: var(--muted);
}

.spacer {
    flex: 1 1 auto;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    .cl-header {
        grid-template-columns: 1fr;
    }

    .cl-tools {
        justify-content: flex-start;
    }

    #cl-modal {
        width: 96vw;
    }
}

/* === FIX: Select-Pfeil & helle Inputs im Light-Mode ===================== */

/* 1) Einheitliches Select – ohne Doppel-/Muster-Pfeile in allen Browsern */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    /* Farbe & Rahmen explizit setzen */
    background-color: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--input-border);

    /* eigener Pfeil (1x), klar positioniert */
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 12px;

    /* Platz für den Pfeil rechts */
    padding-right: 36px;

    /* keine Schatten/UA-Artifacts */
    box-shadow: none;
    background-clip: padding-box;
}

/* Windows/IE-Edge alter Pfeil weg */
select::-ms-expand {
    display: none;
}

/* Firefox: sorgt dafür, dass Text normal gezeichnet wird */
select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 var(--text);
}

/* 2) Textareas & Inputs: keine UA-Pattern, saubere Farben */
input[type="text"],
input[type="url"],
input[type="search"],
input[type="date"],
textarea {
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--input-bg) !important;
    color: var(--text) !important;
    border: 1px solid var(--input-border) !important;
    box-shadow: none !important;
    background-image: none !important;
    /* verhindert graue UA-Pattern in Light */
}

/* 3) Spezifische Light-Mode-Hardening (weiß, keine Muster) */
body.light-mode input[type="text"],
body.light-mode input[type="url"],
body.light-mode input[type="search"],
body.light-mode input[type="date"],
body.light-mode textarea,
body.light-mode select {
    background-color: #ffffff !important;
    color: #0b1220 !important;
    border-color: #d7dbe4 !important;
    background-image: none !important;
    /* Basis */
}

/* …aber beim Select wollen wir unseren eigenen Pfeil behalten */
body.light-mode select {
    background-image: var(--select-arrow) !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px 12px !important;
}

/* Fokus konsistent (keine Browser-Glows) */
input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--focus) !important;
}

/* Date-Picker-Icon im Dark-Mode invertieren, im Light-Mode normal */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) opacity(.8);
}

body.light-mode input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

/* ===== ChangeLog – Hinweisbanner für 401/403 ===== */
#cl-banner-host {
    margin: 0 0 8px 0;
}

.cl-banner {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: color-mix(in oklab, var(--surface-2) 85%, #f59f00 15%);
    color: var(--text);
}

body.light-mode .cl-banner {
    background: color-mix(in oklab, #fff 85%, #f59f00 15%);
    border-color: #ead6a3;
}

.cl-banner-text {
    font-size: 14px;
    line-height: 1.35;
}

.cl-banner-link {
    justify-self: start;
    font-weight: 700;
    text-decoration: underline;
}

.cl-banner-close {
    justify-self: end;
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-text);
    border-radius: 8px;
    width: 28px;
    height: 28px;
    line-height: 1;
    cursor: pointer;
}

.cl-banner-close:hover {
    background: color-mix(in oklab, var(--btn-bg) 85%, #000 15%);
}