:root {
    --text: #21303f;
    --muted: #6b7a8d;
    --border: #d9e2ec;
    --surface: rgba(255, 255, 255, 0.86);
    --surface-solid: #ffffff;
    --surface-2: #f2f6fb;
    --primary: #3a8cff;
    --primary-hover: #2b78ea;
    --danger: #ef5468;
    --danger-hover: #e13d52;
    --ok: #1f9d57;
    --shadow: 0 10px 30px rgba(40, 70, 110, 0.14);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    font-size: 14px;
    background: #e7f6ff;
}

/* Cartoon scene background — fixed, behind all content. */
.scene {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 18px; font-size: 13px; margin-top: 6px; }

button {
    font: inherit;
    cursor: pointer;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-solid);
    color: var(--text);
    padding: 8px 14px;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
button:hover { background: var(--surface-2); }
button:active { transform: translateY(1px); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-hover); }
button.ghost { background: transparent; }
button.small { padding: 6px 11px; font-size: 13px; }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger); color: #fff; }

input {
    font: inherit;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 12px;
    outline: none;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(58, 140, 255, 0.15); }

/* --- Login --- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--surface);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    padding: 34px;
    width: 100%;
    max-width: 370px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--shadow);
}
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 0; font-size: 13px; }
.login-card input, .login-card button { width: 100%; padding: 11px 12px; }

/* --- Topbar --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--surface);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 2px 14px rgba(40, 70, 110, 0.08);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
}
.brand { font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.topbar-actions #search { width: 280px; max-width: 60vw; }

main { padding: 24px; max-width: 1150px; margin: 0 auto; }

.status { min-height: 20px; margin-bottom: 12px; font-size: 13px; font-weight: 600; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

/* --- Table --- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    background: var(--surface);
    backdrop-filter: blur(6px);
    box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: rgba(242, 246, 251, 0.7); }
tbody tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { padding: 5px 10px; font-size: 13px; margin-left: 6px; }
.url-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { margin-top: 12px; }

/* Avatar thumbnail in the table */
.avatar-thumb {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: block;
}
.avatar-thumb.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 50, 75, 0.35);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
}
.modal-card {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 26px;
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 6px; font-size: 20px; }
.modal-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.modal-card label input { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* Avatar field in the modal */
.avatar-field {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 4px 0 8px;
}
.avatar-preview {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.avatar-controls { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
