* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f5f6fa;
    color: #333;
}

/* ── Nav ──────────────────────────────────────────── */
nav {
    background: #2c3e50;
    color: white;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.nav-brand {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-logo {
    height: 32px;
    width: 32px;
    object-fit: contain;
    filter: invert(1);
    mix-blend-mode: screen;
    flex-shrink: 0;
}
.nav-logout-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.nav-link {
    color: #ccc;
    text-decoration: none;
    font-size: 0.9rem;
}
.nav-link:hover { color: white; }

.nav-id-badge {
    color: rgba(255,255,255,0.6);
    font-size: 0.78rem;
    font-weight: 400;
    white-space: nowrap;
}

/* ── Main ─────────────────────────────────────────── */
main {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

h1 {
    margin-bottom: 1.5rem;
    font-size: 1.6rem;
    color: #2c3e50;
}

/* ── Card base ────────────────────────────────────── */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.card p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.card ul {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
    display: inline-block;
    background: #2980b9;
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.btn:hover { background: #2471a3; }
.btn-primary { background: #2980b9; }
.btn-primary:hover { background: #2471a3; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.82rem; }
.btn-full { width: 100%; margin-top: 0.5rem; text-align: center; }

/* ── Forms ────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.04em;
}
.form-group input {
    padding: 0.45rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    background: white;
    width: 100%;
}
.form-group input:focus { outline: none; border-color: #2980b9; }

/* ── Alerts ───────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error { background: #fadbd8; color: #922b21; }
.alert-info  { background: #d6eaf8; color: #1a5276; }

/* ── Login page ───────────────────────────────────── */
body.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f4f6f9;
    padding: 1rem;
}
.login-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    padding: 2rem 2.5rem;
    width: 100%;
    max-width: 380px;
}
.login-brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c6fad;
    text-align: center;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.login-logo {
    height: 36px;
    width: 36px;
    object-fit: contain;
}
.login-form .form-group { margin-bottom: 1rem; }
.login-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    text-transform: none;
    letter-spacing: 0;
    color: #444;
}
.login-form input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
}

/* ── Password toggle ──────────────────────────────── */
.password-wrap { position: relative; display: flex; align-items: center; }
.password-wrap input { flex: 1; padding-right: 2.8rem; }
.pw-toggle {
    position: absolute; right: 0.6rem;
    background: none; border: none; cursor: pointer;
    color: #888; padding: 0.2rem; display: flex; align-items: center;
}
.pw-toggle:hover { color: #333; }

/* ── Back button ──────────────────────────────────── */
.back-btn {
    display: inline-block;
    margin-bottom: 1rem;
    background: none;
    border: none;
    color: #555;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}
.back-btn:hover { color: #000; }

/* ── Section title ────────────────────────────────── */
.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
}

/* ── Life timeline (home page) ────────────────────── */
.life-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.life-card {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    text-decoration: none;
    color: inherit;
    gap: 1.25rem;
    transition: box-shadow 0.15s, transform 0.15s;
}
.life-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.13);
    transform: translateY(-2px);
}

.life-card-year {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2980b9;
    min-width: 56px;
    text-align: center;
    flex-shrink: 0;
}

.life-card-body { flex: 1; min-width: 0; }

.life-card-date {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #aaa;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
}

.life-card-desc {
    font-size: 1rem;
    color: #2c3e50;
    font-weight: 500;
}

.life-card-age {
    font-size: 0.78rem;
    background: #eaf4fb;
    color: #2471a3;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.life-card-arrow {
    color: #ccc;
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* ── Detail page header ───────────────────────────── */
.detail-header {
    border-left: 4px solid #2980b9;
}
.detail-header-year {
    font-size: 2rem;
    font-weight: 700;
    color: #2980b9;
    line-height: 1;
    margin-bottom: 0.25rem;
}
.detail-header-date {
    font-size: 0.85rem;
    color: #aaa;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}
.detail-header-desc {
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.detail-header-age {
    display: inline-block;
    font-size: 0.78rem;
    background: #eaf4fb;
    color: #2471a3;
    padding: 3px 10px;
    border-radius: 12px;
}

/* ── On this day title ────────────────────────────── */
.onthisday-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #222;
    margin-bottom: 1rem;
}

/* ── Collapsible wiki groups ──────────────────────── */
.wiki-group {
    margin-top: 1.25rem;
}
.wiki-group-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.06em;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0;
    user-select: none;
}
.wiki-group-title::-webkit-details-marker { display: none; }
.wiki-group-title::before {
    content: '▾';
    font-size: 0.85rem;
    color: #aaa;
    transition: transform 0.2s;
    display: inline-block;
}
details.wiki-group:not([open]) .wiki-group-title::before {
    transform: rotate(-90deg);
}
.wiki-group-title:hover { color: #555; }

/* ── Wikipedia results ────────────────────────────── */
.wiki-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.wiki-item {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    background: white;
    border-radius: 6px;
    padding: 0.65rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    font-size: 0.9rem;
    line-height: 1.5;
}

.wiki-year {
    font-size: 0.78rem;
    font-weight: 700;
    color: #2980b9;
    min-width: 38px;
    flex-shrink: 0;
}

.wiki-badge {
    font-size: 0.7rem;
    font-weight: 600;
    background: #d5f5e3;
    color: #1e8449;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
.wiki-badge-death {
    background: #fadbd8;
    color: #922b21;
}

.wiki-item-text { color: #333; }

.chart-pos {
    font-size: 1rem;
    font-weight: 700;
    color: #2980b9;
    min-width: 28px;
    text-align: right;
    flex-shrink: 0;
}

/* ── Mobile ───────────────────────────────────────── */
@media (max-width: 600px) {
    main { padding: 0 0.75rem; margin: 1rem auto; }
    h1 { font-size: 1.25rem; }
    .life-card { padding: 0.75rem 1rem; gap: 0.75rem; }
    .life-card-year { font-size: 1.1rem; min-width: 44px; }
    .life-card-desc { font-size: 0.9rem; }
    .login-container { padding: 1.5rem 1.25rem; }
}
