/* ==========================================================================
   Pincards – Styles
   ========================================================================== */
:root {
    --bg: #f6f7f9;
    --card: #ffffff;
    --text: #1a1d21;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #1a1d21;
    --star: #f4b942;
    --danger: #dc2626;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(0,0,0,.05);
    --shadow-hover: 0 8px 24px rgba(0,0,0,.10);
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

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

/* --- Topbar ---------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: rgba(246, 247, 249, .92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.logo {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.03em;
    user-select: none;
}
.logo span { color: #e86a58; }

.topbar-actions { display: flex; gap: 4px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: background .15s;
}
.icon-btn:hover { background: rgba(0,0,0,.06); }
.icon-btn.active { background: var(--accent); color: #fff; }
.icon-btn svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-btn.active svg { fill: currentColor; }

/* --- Suche & Tags ------------------------------------------------------ */
.search-bar { padding: 0 16px 8px; }
.search-bar input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    background: var(--card);
}
.search-bar input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.tag-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 16px 10px;
    scrollbar-width: none;
}
.tag-bar::-webkit-scrollbar { display: none; }

.tag-chip {
    flex: 0 0 auto;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.tag-chip:hover { background: #eceef1; }
.tag-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tag-chip .cnt { opacity: .55; margin-left: 4px; font-weight: 400; }

/* --- Board (Masonry) --------------------------------------------------- */
main { padding: 8px 16px 96px; max-width: 1400px; margin: 0 auto; }

.board { column-count: 2; column-gap: 14px; }
@media (min-width: 640px)  { .board { column-count: 3; } }
@media (min-width: 960px)  { .board { column-count: 4; } }
@media (min-width: 1280px) { .board { column-count: 5; } }

.card {
    position: relative;
    /* inline-block statt block: umgeht WebKit-Bug, bei dem Cards in
       CSS-Columns unsichtbar bleiben (nur repaint-bare Kinder sichtbar) */
    display: inline-block;
    width: 100%;
    vertical-align: top;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 14px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-hover); }

.card-media img { display: block; width: 100%; height: auto; }
.card-media.color-fallback { height: 90px; }

.card-content { padding: 12px 14px 14px; }
.card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
    word-wrap: break-word;
}
.card-excerpt {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.card-tag {
    font-size: 11px;
    color: var(--muted);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 999px;
}

/* Stern auf der Card */
.star-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 6px;
    color: rgba(0,0,0,.35);
    transition: color .15s, transform .1s;
}
.star-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linejoin: round;
}
.star-btn.faved { color: var(--star); }
.star-btn.faved svg { fill: currentColor; }
.star-btn:active { transform: scale(1.25); }

.card .star-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255,255,255,.85);
    border-radius: 999px;
    backdrop-filter: blur(4px);
}
.card .star-btn:not(.faved) { color: rgba(0,0,0,.45); }

/* --- Leerer Zustand ---------------------------------------------------- */
.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-icon { font-size: 44px; margin-bottom: 8px; }

/* --- FAB ---------------------------------------------------------------- */
.fab {
    position: fixed;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 50;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 30px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
    transition: transform .15s;
}
.fab:hover { transform: scale(1.06); }

/* --- Modals -------------------------------------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(20, 22, 26, .55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fade-in .18s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal[hidden] { display: none; }

.modal-card {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 92dvh;
    overflow-y: auto;
    background: var(--card);
    border-radius: 20px 20px 0 0;
    animation: slide-up .22s ease;
}
@keyframes slide-up { from { transform: translateY(24px); opacity: 0; } }

@media (min-width: 680px) {
    .modal { align-items: center; padding: 24px; }
    .modal-card { border-radius: 20px; max-height: 88dvh; }
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 999px;
    background: rgba(255,255,255,.9);
    box-shadow: var(--shadow);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--text);
}

.modal-body {
    padding: 20px;
    /* Lange Wörter/URLs umbrechen statt überlaufen */
    overflow-wrap: break-word;
    word-break: break-word;
}
.modal-body h2 {
    margin: 0 0 4px;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

/* Detail-Ansicht */
.view-hero { width: 100%; }
.view-hero img { display: block; width: 100%; height: auto; border-radius: 20px 20px 0 0; }
.view-hero.color-fallback { height: 110px; border-radius: 20px 20px 0 0; }

.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.view-head h2 { flex: 1; }

.view-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.view-tags .card-tag { font-size: 12px; padding: 3px 10px; cursor: pointer; }

.view-body { margin-top: 14px; }
.view-meta { margin-top: 16px; font-size: 12px; color: var(--muted); }

.view-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Formatierter Text */
.rich-text { font-size: 15px; overflow-wrap: anywhere; }
.rich-text a { word-break: break-all; }
.rich-text p { margin: 0 0 10px; }
.rich-text a { color: #2563eb; }
.rich-text ul, .rich-text ol { margin: 0 0 10px; padding-left: 22px; }
.rich-text blockquote {
    margin: 0 0 10px;
    padding: 4px 14px;
    border-left: 3px solid var(--border);
    color: var(--muted);
}
.rich-text h3 { font-size: 16px; margin: 14px 0 6px; }

/* --- Formular ------------------------------------------------------------- */
.field-label { display: block; font-size: 13px; font-weight: 600; margin: 16px 0 6px; }
.field-hint { font-weight: 400; color: var(--muted); }

.text-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    background: #fff;
}
.text-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Quill anpassen */
#editorWrap .ql-toolbar {
    border-radius: 10px 10px 0 0;
    border-color: var(--border);
    font-family: var(--font);
}
#editorWrap .ql-container {
    border-radius: 0 0 10px 10px;
    border-color: var(--border);
    font-family: var(--font);
    font-size: 15px;
    min-height: 130px;
}

.image-field { margin-top: 2px; }

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 26px 16px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.dropzone svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.dropzone strong { color: var(--text); }
.dropzone:hover,
.dropzone:focus-visible { border-color: #c3c8cf; }
.dropzone.dragover {
    border-color: var(--accent);
    background: #eef1f5;
    color: var(--text);
}

.image-preview {
    position: relative;
    display: inline-block;
    max-width: 100%;
}
.image-preview img {
    display: block;
    max-width: 100%;
    max-height: 220px;
    border-radius: 12px;
}
.preview-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 999px;
    background: rgba(20, 22, 26, .65);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background .15s;
}
.preview-remove:hover { background: rgba(220, 38, 38, .85); }

.form-error {
    margin-top: 14px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: var(--danger);
    font-size: 14px;
}

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

/* --- Buttons ---------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 20px;
    border: 0;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity .15s, background .15s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: .88; }
.btn-secondary { background: #eceef1; color: var(--text); }
.btn-secondary:hover { background: #e2e5e9; }
.btn-danger { background: #fef2f2; color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-block { width: 100%; }

/* --- Login ------------------------------------------------------------------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 360px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px 28px;
    text-align: center;
}
.login-box .logo { font-size: 28px; }
.login-sub { margin: 4px 0 24px; color: var(--muted); font-size: 14px; }
.login-input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    text-align: center;
}
.login-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login-error {
    margin-bottom: 14px;
    padding: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: var(--danger);
    font-size: 14px;
}

body.modal-open { overflow: hidden; }

/* --- Userverwaltung ----------------------------------------------------- */
.admin-main { max-width: 640px; }
.admin-title { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin: 8px 0 20px; }

.admin-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.admin-card h2 { font-size: 17px; margin: 0 0 6px; letter-spacing: -0.01em; }
.admin-hint { font-size: 13px; color: var(--muted); }
p.admin-hint { margin: 0 0 16px; }

.admin-notice, .admin-error {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
}
.admin-notice { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.admin-error  { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }

.invite-list, .user-list { list-style: none; margin: 16px 0 0; padding: 0; }
.invite-list li, .user-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 0;
    border-top: 1px solid var(--border);
}
.invite-info { flex: 1; min-width: 220px; }
.invite-link { font-size: 13px; margin-bottom: 4px; }
.invite-actions { display: flex; gap: 8px; }

.user-info { display: flex; flex-direction: column; gap: 2px; }
.user-info strong { font-size: 15px; }
.badge {
    display: inline-block;
    width: fit-content;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
}
