/* =========================================================================
   Screenshots — ganztags. UI-System (Tagwerk-Linie)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

/* ---------- Design Tokens ---------- */
:root {
    --brand: #ae0037;
    --brand-dim: #8a002b;
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-500: #2563eb;
    --primary-600: #1d4ed8;
    --primary-700: #1e40af;

    --success-50: #e7f4ee;
    --success-100: #c2e3d2;
    --success-500: #1f8a6a;
    --success-600: #1a7559;
    --success-900: #0e3f30;

    --warning-50: #fdf8f0;
    --warning-100: #f7ebd1;
    --warning-500: #c97b00;
    --warning-600: #a86700;

    --danger-50: #fdf2f3;
    --danger-100: #fae1e4;
    --danger-500: #d7263d;
    --danger-600: #b61f33;
    --danger-700: #93192a;

    --amber-50: #fffbeb;
    --amber-900: #78350f;

    --bg: #f8f9fa;
    --surface: #ffffff;
    --surface-2: #f3f4f6;
    --surface-3: #f9fafb;
    --border: #e5e7eb;
    --border-soft: #f3f4f6;
    --text: #1f2937;
    --text-strong: #111827;
    --text-soft: #4b5563;
    --text-muted: #6b7280;
    --text-dim: #9ca3af;

    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
    --shadow-md: 0 4px 8px -2px rgba(17, 24, 39, 0.08), 0 2px 4px -2px rgba(17, 24, 39, 0.04);
    --shadow-lg: 0 12px 24px -8px rgba(17, 24, 39, 0.16);

    --sidebar-w: 16rem;
    --topbar-h: 3.5rem;
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 10px;
    --radius-pill: 9999px;

    --font-sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

html.dark {
    --bg: #111827;
    --surface: #1f2937;
    --surface-2: #1f2937;
    --surface-3: #111827;
    --border: #374151;
    --border-soft: #374151;
    --text: #f9fafb;
    --text-strong: #f9fafb;
    --text-soft: #d1d5db;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, 0.6);
}

/* ---------- Reset / Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    transition: background-color 0.2s ease, color 0.2s ease;
    min-height: 100dvh;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    color: var(--text-strong);
    font-weight: 700;
    line-height: 1.25;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }

p { margin: 0; }

a { color: var(--primary-500); text-decoration: none; }
a:hover { color: var(--primary-600); }

img { max-width: 100%; height: auto; }

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

/* ---------- App Layout ---------- */
.app-shell { display: flex; min-height: 100dvh; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30;
    display: none;
}

.sidebar-backdrop.is-open { display: block; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100dvh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}

html.dark .sidebar { background: var(--bg); }

.sidebar.is-open { transform: translateX(0); }

@media (min-width: 768px) {
    .sidebar { transform: translateX(0); }
}

.sidebar__head {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .sidebar__head { height: 4rem; }
}

.sidebar__logo {
    color: var(--brand);
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

html.dark .sidebar__logo { color: #ffffff; }

.sidebar__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-strong);
    flex: 1;
}

.sidebar__close {
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.sidebar__close:hover { color: var(--text-strong); }

@media (min-width: 768px) {
    .sidebar__close { display: none; }
}

.sidebar__body { flex: 1; overflow-y: auto; padding: 1rem; }

.nav-section + .nav-section { margin-top: 1.5rem; }

.nav-section__title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-soft);
    border-radius: var(--radius);
    border-left: 4px solid transparent;
    transition: background 0.12s ease, color 0.12s ease;
}

.nav-link:hover { background: var(--border); color: var(--text-strong); }

.nav-link .nav-icon {
    color: var(--text-muted);
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.nav-link.is-active {
    background: var(--border);
    color: var(--text-strong);
    border-left-color: var(--primary-500);
}

.nav-link.is-active .nav-icon { color: var(--primary-500); }

.sidebar__foot {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    background: var(--border);
    border-radius: var(--radius);
    padding: 0.25rem;
    gap: 0.125rem;
}

.theme-toggle__btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0;
    color: var(--text-muted);
    border-radius: 5px;
    transition: background 0.12s ease, color 0.12s ease;
}

.theme-toggle__btn:hover { color: var(--text-strong); }

.theme-toggle__btn.is-active {
    background: var(--surface);
    color: var(--text-strong);
    box-shadow: var(--shadow-sm);
}

.theme-toggle__btn svg { width: 1rem; height: 1rem; }

/* Main content area */
.main-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

@media (min-width: 768px) {
    .main-column { margin-left: var(--sidebar-w); }
}

.topbar {
    display: flex;
    align-items: center;
    height: var(--topbar-h);
    padding: 0 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
    .topbar { display: none; }
}

.topbar__menu {
    padding: 0.5rem;
    margin-left: -0.25rem;
    color: var(--text-muted);
    border-radius: var(--radius);
}

.topbar__menu:hover { color: var(--text-strong); }
.topbar__menu svg { width: 1.5rem; height: 1.5rem; }

.topbar__logo {
    color: var(--brand);
    width: 1.25rem;
    height: 1.25rem;
    margin-left: 0.75rem;
    margin-right: 0.5rem;
}

html.dark .topbar__logo { color: #ffffff; }

.topbar__title { font-size: 1rem; font-weight: 700; color: var(--text-strong); }

.main {
    flex: 1;
    padding: 1rem;
    padding-top: calc(var(--topbar-h) + 1rem);
    max-width: 100%;
}

@media (min-width: 768px) {
    .main { padding: 2rem; }
}

@media (min-width: 1024px) {
    .main { padding: 3rem; }
}

.container { max-width: 1200px; margin: 0 auto; }

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.page-header__title { font-size: 1.5rem; font-weight: 700; color: var(--text-strong); }
.page-header__subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }

.page-header__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card > :last-child { margin-bottom: 0; }

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-strong);
    margin-bottom: 1rem;
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: -0.75rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.card-header .card-title { margin-bottom: 0; }

@media (max-width: 767px) {
    .card { padding: 1rem; }
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text-strong);
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover { background: var(--surface-2); }
.btn:disabled,
.btn[disabled] { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

.btn svg { width: 1rem; height: 1rem; }

.btn-primary {
    background: var(--primary-500);
    border-color: var(--primary-500);
    color: #ffffff;
}

.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #ffffff; }

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-strong);
}

.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; box-shadow: none; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text-strong); background: var(--surface-2); }

.btn--sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }

/* ---------- Notices ---------- */
.notice {
    background: var(--primary-50);
    color: var(--primary-700);
    border: 1px solid var(--primary-100);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

html.dark .notice {
    background: rgba(37, 99, 235, 0.12);
    border-color: rgba(37, 99, 235, 0.25);
    color: #bfdbfe;
}

.notice.success {
    background: var(--success-50);
    color: var(--success-900);
    border-color: var(--success-100);
}

html.dark .notice.success {
    background: rgba(31, 138, 106, 0.15);
    border-color: rgba(31, 138, 106, 0.35);
    color: #86efac;
}

.notice.error {
    background: var(--danger-50);
    color: var(--danger-700);
    border-color: var(--danger-100);
}

html.dark .notice.error {
    background: rgba(215, 38, 61, 0.15);
    border-color: rgba(215, 38, 61, 0.35);
    color: #fca5a5;
}

.notice.warning {
    background: var(--warning-50);
    color: var(--warning-600);
    border-color: var(--warning-100);
}

/* ---------- Tables ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

thead tr th {
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-top: 1px solid var(--border-soft);
    transition: background 0.12s ease;
}

tbody tr:first-child { border-top: 0; }
tbody tr:hover { background: var(--surface-3); }

tbody td {
    padding: 0.875rem 1.25rem;
    font-size: 0.875rem;
    color: var(--text);
    vertical-align: top;
}

td.right, th.right { text-align: right; }

.table-wrap {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

@media (max-width: 767px) {
    .table-wrap { overflow-x: auto; display: block; }
    table { min-width: 540px; }
}

/* ---------- Forms ---------- */
.form-control {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-soft);
}

input[type="text"],
input[type="number"],
input[type="url"],
select,
textarea {
    width: 100%;
    font: inherit;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

html.dark input[type="text"],
html.dark input[type="number"],
html.dark input[type="url"],
html.dark select,
html.dark textarea {
    background: #374151;
    border-color: #4b5563;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

select { cursor: pointer; }

input::placeholder,
textarea::placeholder { color: var(--text-dim); }

textarea.url-input {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    min-height: 10rem;
    resize: vertical;
    line-height: 1.7;
}

/* Options grid below the textarea */
.options-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
    align-items: end;
    margin-top: 1rem;
}

@media (min-width: 640px) {
    .options-grid { grid-template-columns: repeat(3, 1fr); }
}

.options-toggle {
    margin-top: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.options-toggle:hover { color: var(--text-strong); }

/* ---------- Badges / Status ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    background: var(--primary-50);
    color: var(--primary-700);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    border: 1px solid var(--primary-100);
}

html.dark .badge {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.3);
    color: #bfdbfe;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.625rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-mono);
    white-space: nowrap;
}

.status-pill--pending { background: var(--surface-2); color: var(--text-muted); }
.status-pill--running { background: var(--primary-50); color: var(--primary-700); }
.status-pill--ok { background: var(--success-50); color: var(--success-900); }
.status-pill--error { background: var(--danger-50); color: var(--danger-700); }

html.dark .status-pill--pending { background: rgba(156, 163, 175, 0.15); color: #d1d5db; }
html.dark .status-pill--running { background: rgba(37, 99, 235, 0.2); color: #bfdbfe; }
html.dark .status-pill--ok { background: rgba(31, 138, 106, 0.2); color: #86efac; }
html.dark .status-pill--error { background: rgba(215, 38, 61, 0.2); color: #fca5a5; }

.status-pill--running::before {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

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

/* ---------- Progress bar ---------- */
.progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress__bar {
    flex: 1;
    height: 0.5rem;
    background: var(--surface-2);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

html.dark .progress__bar { background: var(--border); }

.progress__fill {
    height: 100%;
    background: var(--primary-500);
    border-radius: var(--radius-pill);
    transition: width 0.3s ease;
    min-width: 0;
}

.progress__label {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ---------- URL result list ---------- */
.url-row td:first-child {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    word-break: break-all;
}

.url-row .error-text {
    display: block;
    font-size: 0.75rem;
    color: var(--danger-500);
    margin-top: 0.25rem;
    font-family: var(--font-sans);
}

/* ---------- Gallery ---------- */
.gallery {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .gallery { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .gallery { grid-template-columns: repeat(3, 1fr); }
}

.shot-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.shot-card__img {
    display: block;
    width: 100%;
    height: 16rem;
    object-fit: cover;
    object-position: top;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.shot-card__body {
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
}

.shot-card__name {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Utilities ---------- */
.muted { color: var(--text-muted); }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.stack > * + * { margin-top: 1rem; }

.cluster {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.cluster--end { justify-content: flex-end; }
