:root {
    color-scheme: light dark;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e0e2e7;
    --text: #1c1e21;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --radius: 10px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161a;
        --surface: #1e2128;
        --border: #2c303a;
        --text: #edeef0;
        --text-muted: #9aa0aa;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 360px;
    text-align: center;
}
.login-card h1 { font-size: 1.3rem; margin-bottom: 8px; }
.login-card p { color: var(--text-muted); margin-bottom: 24px; }

.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; flex-direction: column; }
.topbar-title h1 { font-size: 1.1rem; margin: 0; }
.feed-link { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.feed-link code { background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.feed-link a { color: var(--primary); }
.feed-warning { color: var(--danger); }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 0.9rem; }

.content { max-width: 1100px; margin: 0 auto; padding: 24px 28px 60px; }

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}
.toolbar input[type="search"] {
    flex: 1;
    max-width: 320px;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.card-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    background:
        linear-gradient(45deg, #00000010 25%, transparent 25%, transparent 75%, #00000010 75%),
        linear-gradient(45deg, #00000010 25%, transparent 25%, transparent 75%, #00000010 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.card-image img { width: 100%; height: 100%; object-fit: contain; }
.card-name { font-weight: 600; }
.card-aliases {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 1.2em;
}
.chip {
    font-size: 0.72rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 8px;
    color: var(--text-muted);
}
.card-actions { display: flex; gap: 8px; margin-top: auto; }
.card-actions .btn { flex: 1; padding: 6px 10px; font-size: 0.85rem; text-align: center; }

.empty-state { text-align: center; color: var(--text-muted); margin-top: 60px; }

dialog {
    border: none;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 24px;
    max-width: 420px;
    width: 90vw;
}
dialog::backdrop { background: rgba(0,0,0,0.5); }
dialog h2 { margin-top: 0; font-size: 1.1rem; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field small { color: var(--text-muted); font-weight: 400; }
.field input[type="text"] {
    padding: 9px 11px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

.alias-list { display: flex; flex-wrap: wrap; gap: 6px; }
.alias-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 6px 3px 10px;
    font-size: 0.82rem;
}
.alias-chip button {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    padding: 2px 4px;
}
.alias-input-row { display: flex; gap: 8px; }
.alias-input-row input {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.upload-zone.dragover { border-color: var(--primary); color: var(--primary); }
.upload-zone img {
    max-width: 140px;
    max-height: 140px;
    display: block;
    margin: 0 auto 10px;
}

.form-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: -8px;
}

.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
