/* Holz-Bild-Rendering: dunkles Design, nicht reines Schwarz */

:root {
    --bg: #16181d;
    --surface: #1e2127;
    --surface-2: #23262d;
    --border: #2e323b;
    --border-strong: #3a3f4a;
    --text: #e6e8ec;
    --muted: #9aa1ac;
    --accent: #2bb6c4;
    --accent-hover: #38c9d7;
    --accent-ink: #06222a;
    --danger: #e0796b;
    --ok: #7fc8a0;
    --radius: 10px;
    --shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
    --maxw: 1280px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* hidden-Attribut verbindlich: schlaegt explizite display-Angaben (.overlay, #app,
   .preview, .spinner-wrap). Ohne dies blieben per hidden ausgeblendete Elemente sichtbar. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.02rem; margin: 0 0 .7rem; font-weight: 600; letter-spacing: .01em; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--danger); }

/* ---------- Login ---------- */
.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(1200px 600px at 50% -10%, #20242c 0%, var(--bg) 60%);
    padding: 1.5rem;
    z-index: 50;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.6rem;
    display: flex;
    flex-direction: column;
    gap: .8rem;
}

/* ---------- Layout ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .8rem 1.2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand { font-weight: 600; font-size: 1.05rem; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }

.grid {
    flex: 1;
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 1.2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
    align-items: start;
}

.col { display: flex; flex-direction: column; gap: 1.2rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
}

/* ---------- Dropzone ---------- */
.dropzone {
    position: relative;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    overflow: hidden;
}

.dropzone:hover,
.dropzone:focus-visible { border-color: var(--accent); outline: none; }

.dropzone.dragover {
    border-color: var(--accent);
    background: #1c2a2d;
}

.drop-inner { color: var(--muted); padding: 1.5rem; }
.drop-inner svg { color: var(--accent); margin-bottom: .4rem; }
.drop-inner p { margin: .3rem 0; }

.preview {
    display: block;
    max-width: 100%;
    max-height: 60vh;
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: 6px;
}

.meta { margin: .55rem 0 0; min-height: 1.1em; }

/* ---------- Textarea ---------- */
textarea {
    width: 100%;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: .7rem .8rem;
    font-family: var(--font);
    font-size: .95rem;
    line-height: 1.45;
    resize: vertical;
    margin-bottom: .8rem;
}

textarea:focus { outline: none; border-color: var(--accent); }

input[type="password"] {
    width: 100%;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: .65rem .8rem;
    font-size: .95rem;
}
input[type="password"]:focus { outline: none; border-color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
    appearance: none;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    padding: .6rem 1.1rem;
    border-radius: 8px;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s;
}

.btn:hover:not(:disabled) { border-color: var(--accent); }

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    width: 100%;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn.ghost { background: transparent; }
.btn.ghost.small { padding: .45rem .8rem; font-weight: 500; color: var(--muted); }

.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-row { display: flex; gap: .7rem; }
.btn-row .btn { flex: 1; }

/* ---------- Badge ---------- */
.badge {
    font-size: .75rem;
    padding: .25rem .55rem;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--muted);
}
.badge.mock { color: var(--accent); border-color: var(--accent); }

/* ---------- Ergebnisbereich ---------- */
.result-card { display: flex; flex-direction: column; }

.result-area {
    position: relative;
    min-height: 320px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .8rem;
}

.placeholder { text-align: center; }

.spinner-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .7rem;
    background: rgba(22, 24, 29, 0.72);
    border-radius: 8px;
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Infobar ---------- */
.infobar {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: .55rem 1.2rem;
    position: sticky;
    bottom: 0;
}

#infoText {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 3.2rem;
    transform: translateX(-50%);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: .7rem 1.1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 90vw;
    z-index: 40;
}
.toast.err { border-color: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .grid { grid-template-columns: 1fr; }
    .preview { max-height: 50vh; }
}
