:root {
    --coffee-dark: #3c2415;
    --coffee: #6f4e37;
    --coffee-light: #a97c50;
    --cream: #faf3e8;
    --cream-dark: #f0e4d0;
    --accent: #ff8c3c;
    --accent-dark: #e8631a;
    --accent-pink: #ff5d8f;
    --text: #3c2415;
    --muted: #8a7360;
    --danger: #c0392b;
    --success: #2f7d4f;
    --radius: 20px;
    --font-heading: "Baloo 2", "Segoe UI", sans-serif;
    --font-body: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --avatar-0: #ff6b6b;
    --avatar-1: #ff9f43;
    --avatar-2: #ffca3a;
    --avatar-3: #6bcB77;
    --avatar-4: #4dabf7;
    --avatar-5: #845ef7;
    --avatar-6: #f783ac;
    --avatar-7: #38d9a9;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: linear-gradient(180deg, var(--cream) 0%, var(--cream-dark) 100%);
    color: var(--text);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle, var(--avatar-0) 2px, transparent 2.5px),
        radial-gradient(circle, var(--avatar-4) 2px, transparent 2.5px),
        radial-gradient(circle, var(--avatar-2) 2px, transparent 2.5px),
        radial-gradient(circle, var(--avatar-6) 2px, transparent 2.5px);
    background-position: 0 0, 45px 30px, 90px 5px, 130px 60px;
    background-size: 160px 100px;
    opacity: 0.07;
    pointer-events: none;
    z-index: 0;
}

.bean {
    position: fixed;
    font-size: 2.6rem;
    opacity: 0.12;
    pointer-events: none;
    animation: float 7s ease-in-out infinite;
    z-index: 0;
}

.bean-1 { top: 8%; left: 4%; animation-delay: 0s; }
.bean-2 { top: 65%; right: 6%; font-size: 3.2rem; animation-delay: 1.5s; }
.bean-3 { bottom: 8%; left: 10%; font-size: 2rem; animation-delay: 3s; }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-18px) rotate(8deg); }
}

@media (max-width: 640px) {
    .bean { display: none; }
}

@media (max-width: 480px) {
    .timeline-item { flex-wrap: wrap; row-gap: 4px; }
    .timeline-date { flex: 1 1 100%; }
    .timeline-name { flex: 1 1 100%; }
}

.page {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px 64px;
    position: relative;
    z-index: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 700;
    margin: 0;
    color: var(--coffee-dark);
}

.admin-link {
    color: var(--coffee);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 8px 16px;
    border: 2px solid var(--coffee-light);
    border-radius: 999px;
    white-space: nowrap;
    transition: transform 0.15s ease, background 0.15s ease;
    display: inline-block;
}

.admin-link:hover { background: var(--cream-dark); transform: translateY(-2px); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.lang-switch {
    display: inline-flex;
    border: 2px solid var(--coffee-light);
    border-radius: 999px;
    overflow: hidden;
}

.lang-switch a {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--coffee);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.lang-switch a:hover { background: var(--cream-dark); }

.lang-switch a.active {
    background: var(--accent);
    color: #fff;
}

.scallop {
    height: 14px;
    margin: -8px 0 22px;
    background-image: radial-gradient(circle at 10px 0, transparent 9px, var(--accent) 9.5px);
    background-size: 20px 14px;
    background-repeat: repeat-x;
    opacity: 0.4;
    position: relative;
    z-index: 1;
}

.steam-emoji { position: relative; display: inline-block; }

.steam-emoji::before,
.steam-emoji::after {
    content: "";
    position: absolute;
    top: -6px;
    width: 5px;
    height: 12px;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    filter: blur(1.5px);
    opacity: 0;
    animation: steam-rise 2.6s ease-in-out infinite;
}

.steam-emoji::before { left: 2px; animation-delay: 0.2s; }
.steam-emoji::after { left: 14px; animation-delay: 1.3s; }

.page-header h1 .steam-emoji::before,
.page-header h1 .steam-emoji::after {
    background: rgba(111, 78, 55, 0.35);
}

@keyframes steam-rise {
    0% { transform: translateY(0) scale(1); opacity: 0; }
    35% { opacity: 0.7; }
    100% { transform: translateY(-16px) scale(1.5); opacity: 0; }
}

.sticker {
    position: absolute;
    font-size: 1.7rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
    z-index: 1;
}

.sticker-1 { top: 12px; left: 16px; animation: wiggle-1 3.2s ease-in-out infinite; }
.sticker-2 { bottom: 12px; right: 16px; animation: wiggle-2 3.6s ease-in-out infinite; }

@keyframes wiggle-1 {
    0%, 100% { transform: rotate(-16deg) translateY(0); }
    50% { transform: rotate(-6deg) translateY(-5px); }
}

@keyframes wiggle-2 {
    0%, 100% { transform: rotate(14deg) translateY(0); }
    50% { transform: rotate(22deg) translateY(-5px); }
}

.bakery-tag {
    position: absolute;
    top: -16px;
    left: 50%;
    transform-origin: top center;
    transform: translateX(-50%) rotate(-2deg);
    background: #fff;
    color: var(--accent-dark);
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    padding: 6px 16px;
    border-radius: 999px;
    box-shadow: 0 4px 10px rgba(60, 36, 21, 0.2);
    z-index: 2;
    white-space: nowrap;
    animation: tag-swing 4s ease-in-out infinite;
}

@keyframes tag-swing {
    0%, 100% { transform: translateX(-50%) rotate(-4deg); }
    50% { transform: translateX(-50%) rotate(4deg); }
}

.card-treats {
    border-top: 6px solid transparent;
    border-image: repeating-linear-gradient(90deg, var(--accent) 0 10px, var(--accent-pink) 10px 20px) 6;
}

.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: 0 2px 10px rgba(60, 36, 21, 0.08);
    margin-bottom: 20px;
}

.card h2 {
    font-family: var(--font-heading);
    margin-top: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--coffee-dark);
}

.card h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    margin: 18px 0 8px;
    color: var(--coffee-dark);
}

.load-more {
    text-align: center;
    margin: -4px 0 24px;
}

.calendar-box {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--cream-dark);
}

.calendar-copy-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.calendar-copy-row input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--cream-dark);
    border-radius: 8px;
    font-size: 0.8rem;
    background: var(--cream);
    color: var(--muted);
}

.filter-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.filter-form select { flex: 1; min-width: 160px; }

.pending-requests { border: 2px solid var(--accent); }
.open-requests { border: 2px dashed #845ef7; }

.request-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--cream-dark);
    flex-wrap: wrap;
}

.request-row:last-child { border-bottom: none; }

.request-actions { display: flex; gap: 8px; flex-shrink: 0; }
.request-actions button { padding: 6px 14px; }

.swap-request-box, .my-requests-box {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--cream-dark);
}

.swap-request-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.swap-request-form label {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    color: var(--muted);
    gap: 4px;
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

.swap-request-form input[type="text"] { flex: 1; min-width: 150px; }

.my-requests-list { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.my-requests-list li { padding: 6px 0; border-bottom: 1px solid var(--cream-dark); }
.my-requests-list li:last-child { border-bottom: none; }

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

.current-card {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-pink) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 36px 24px;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: 0 12px 28px rgba(232, 99, 26, 0.35);
    position: relative;
    animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.current-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 34px rgba(232, 99, 26, 0.42);
}

.current-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at 15% 20%, rgba(255,255,255,0.18) 0, transparent 45%),
                radial-gradient(circle at 85% 80%, rgba(255,255,255,0.14) 0, transparent 40%);
    pointer-events: none;
}

@keyframes pop-in {
    0% { transform: scale(0.9) translateY(10px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.current-emoji { font-size: 2.6rem; margin-bottom: 4px; margin-top: 10px; }

.current-name {
    font-family: var(--font-heading);
    font-size: 2.4rem;
    font-weight: 800;
    margin: 10px 0 8px;
    position: relative;
    text-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.current-name.holiday { font-size: 1.5rem; font-family: var(--font-body); font-weight: 700; }

.current-date { font-size: 0.95rem; opacity: 0.92; position: relative; }

.swap-note {
    font-size: 0.85rem;
    background: rgba(255,255,255,0.2);
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    margin-bottom: 10px;
    position: relative;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-family: var(--font-heading);
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.avatar-lg {
    width: 84px;
    height: 84px;
    font-size: 1.8rem;
    margin: 0 auto;
    border: 3px solid rgba(255,255,255,0.6);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    position: relative;
    animation: avatar-breathe 3s ease-in-out infinite;
}

@keyframes avatar-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

.avatar-sm {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
}

.avatar-holiday { background: var(--cream-dark); }

.avatar-c0 { background: var(--avatar-0); }
.avatar-c1 { background: var(--avatar-1); }
.avatar-c2 { background: var(--avatar-2); color: #5c4400; }
.avatar-c3 { background: var(--avatar-3); }
.avatar-c4 { background: var(--avatar-4); }
.avatar-c5 { background: var(--avatar-5); }
.avatar-c6 { background: var(--avatar-6); }
.avatar-c7 { background: var(--avatar-7); }

.timeline { list-style: none; margin: 0; padding: 0; }

.timeline-item {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 6px 14px;
    padding: 12px 8px;
    border-bottom: 1px solid var(--cream-dark);
    border-radius: 10px;
    transition: background 0.15s ease, transform 0.15s ease;
    animation: item-in 0.4s ease both;
}

.timeline-item:nth-child(1) { animation-delay: 0.05s; }
.timeline-item:nth-child(2) { animation-delay: 0.1s; }
.timeline-item:nth-child(3) { animation-delay: 0.15s; }
.timeline-item:nth-child(4) { animation-delay: 0.2s; }
.timeline-item:nth-child(5) { animation-delay: 0.25s; }
.timeline-item:nth-child(6) { animation-delay: 0.3s; }
.timeline-item:nth-child(7) { animation-delay: 0.35s; }
.timeline-item:nth-child(8) { animation-delay: 0.4s; }

@keyframes item-in {
    from { opacity: 0; transform: translateX(14px); }
    to { opacity: 1; transform: translateX(0); }
}

.timeline-item:hover { background: var(--cream-dark); transform: translateX(2px); }

.timeline-item:last-child { border-bottom: none; }

.timeline-date {
    color: var(--muted);
    font-size: 0.9rem;
    flex: 0 0 140px;
    line-height: 1.3;
}

.timeline-name {
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.timeline-item.is-skip .timeline-name { color: var(--muted); font-weight: 600; }

.timeline-birthday {
    flex: 1 1 100%;
    background: linear-gradient(135deg, #845ef7 0%, #f783ac 100%);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
    padding: 6px 12px;
    border-radius: 999px;
    box-shadow: 0 3px 8px rgba(132, 94, 247, 0.3);
}

.badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-pink) 100%);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    vertical-align: middle;
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 140, 60, 0.45); }
    50% { box-shadow: 0 0 0 5px rgba(255, 140, 60, 0); }
}

.badge-birthday {
    background: linear-gradient(135deg, #845ef7 0%, #f783ac 100%);
    animation: none;
}

.birthday-note { background: rgba(255,255,255,0.25); }

/* Admin */

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.flash-success { background: #e5f4ea; color: var(--success); }
.flash-error { background: #fbe9e7; color: var(--danger); }

.login-card { max-width: 340px; margin: 40px auto; }

form label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 12px;
}

form label input {
    display: block;
    width: 100%;
    margin-top: 4px;
}

input[type="text"], input[type="password"], input[type="date"], input[type="email"], select {
    padding: 8px 10px;
    border: 1px solid var(--cream-dark);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--cream);
    color: var(--text);
}

button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.12s ease, background 0.15s ease;
}

button:hover { background: var(--accent-dark); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { background: var(--cream-dark); color: var(--muted); cursor: not-allowed; }
button.danger { background: var(--danger); }
button.danger:hover { background: #96281b; }

.admin-grid, .home-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.home-grid { margin-bottom: 20px; }
.home-grid .card { margin-bottom: 0; }
.home-grid-col { display: flex; flex-direction: column; gap: 12px; }

.full-width { grid-column: 1 / -1; }

@media (max-width: 720px) {
    .admin-grid, .home-grid { grid-template-columns: 1fr; }
}

.colleague-list { list-style: none; margin: 0 0 16px; padding: 0; }

.colleague-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--cream-dark);
}

.colleague-name {
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.colleague-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.colleague-actions button { padding: 4px 10px; }

.inline-form { display: inline-block; margin: 0; }

.inline-form-row { display: flex; gap: 10px; align-items: center; }

.birthday-form { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.birthday-form button { padding: 4px 8px; }

.add-form { display: flex; gap: 10px; flex-wrap: wrap; }
.add-form input[type="text"] { flex: 1; min-width: 140px; }

input[type="date"] {
    width: 150px;
    padding: 6px 8px;
    font-size: 0.85rem;
}

.hint { color: var(--muted); font-size: 0.8rem; }

.overrides-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.overrides-table th, .overrides-table td {
    text-align: left;
    padding: 8px 6px;
    border-bottom: 1px solid var(--cream-dark);
    vertical-align: middle;
}

.overrides-table tr.is-skip { color: var(--muted); }

.override-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.override-actions form { display: flex; gap: 6px; align-items: center; }
.override-actions button { padding: 5px 10px; font-size: 0.8rem; }
.override-actions select { padding: 5px; font-size: 0.8rem; }

.logout-form { text-align: right; margin-top: 8px; }
.logout-form button { background: var(--coffee); }
.logout-form button:hover { background: var(--coffee-dark); }

@media (prefers-reduced-motion: reduce) {
    .bean,
    .sticker-1,
    .sticker-2,
    .bakery-tag,
    .avatar-lg,
    .badge,
    .timeline-item,
    .current-card,
    .steam-emoji::before,
    .steam-emoji::after {
        animation: none !important;
    }
}

@media (prefers-color-scheme: dark) {
    body { background: linear-gradient(180deg, #241812 0%, #1a120c 100%); color: #f0e4d0; }
    .card, .login-card { background: #2c1f16; box-shadow: 0 2px 10px rgba(0,0,0,0.4); }
    .card h2, .page-header h1 { color: #f0e4d0; }
    input, select { background: #241812; color: #f0e4d0; border-color: #4a3626; }
    .timeline-item, .colleague-list li, .overrides-table th, .overrides-table td { border-color: #4a3626; }
    .timeline-item:hover { background: #3a2a1c; }
    .admin-link { color: #f0e4d0; border-color: #6f4e37; }
    .lang-switch { border-color: #6f4e37; }
    .lang-switch a { color: #f0e4d0; }
    .bean { opacity: 0.08; }
}
