:root {
    --bg-1: #eef3fb;
    --bg-2: #dfe9fb;
    --surface: #ffffff;
    --surface-muted: #f7faff;
    --line: #d8e3f3;
    --text: #1f2a44;
    --muted: #64748b;
    --primary: #1a73e8;
    --primary-strong: #155fc0;
    --danger: #d93025;
    --radius-lg: 18px;
    --radius-md: 12px;
    --shadow: 0 14px 32px rgba(15, 35, 78, 0.13);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    font-family: "Manrope", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 8%, rgba(26, 115, 232, 0.19), transparent 27%),
        radial-gradient(circle at 87% 14%, rgba(15, 157, 88, 0.15), transparent 24%),
        linear-gradient(155deg, var(--bg-1), var(--bg-2));
}

.app-shell {
    min-height: 100%;
    padding: 14px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid rgba(26, 115, 232, 0.22);
    background: rgba(237, 243, 253, 0.85);
    color: var(--text);
    font-weight: 800;
    font-size: 0.85rem;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.05rem, 2vw, 1.35rem);
    letter-spacing: 0.01em;
    font-weight: 800;
}

.workspace {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 300px;
    gap: 14px;
    margin-top: 14px;
}

.sidebar,
.calendar-main {
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.sidebar {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-muted);
    padding: 12px;
}

.panel h2 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    font-weight: 700;
}

.panel.compact p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
    font-size: 0.86rem;
}

#mainCalendar {
    padding: 10px;
    min-height: calc(100vh - 150px);
}

/* FullCalendar event text formatting (status badge + better wrapping). */
.fc .fc-event-oc {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    color: inherit;
}

.fc .fc-event-oc .fc-title {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.fc .fc-status-pill {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 900;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid currentColor;
    color: inherit;
    white-space: nowrap;
    opacity: 0.9;
}

/* Keep event labels clipped to their own day cell in month grid. */
.fc .fc-daygrid-event,
.fc .fc-daygrid-dot-event,
.fc .fc-daygrid-event-harness,
.fc .fc-daygrid-event-harness-abs {
    max-width: 100%;
    overflow: hidden;
}

.fc .fc-daygrid-event .fc-event-main,
.fc .fc-daygrid-dot-event .fc-event-main {
    overflow: hidden;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 10px;
}

.field label {
    font-size: 0.81rem;
    color: var(--muted);
    font-weight: 600;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    padding: 9px 10px;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(26, 115, 232, 0.24);
    border-color: var(--primary);
}

.pill-btn,
.ghost-btn,
.danger-btn,
.create-btn,
.icon-btn {
    border: 0;
    border-radius: 999px;
    padding: 8px 13px;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
    font-weight: 700;
}

.pill-btn,
.create-btn {
    background: linear-gradient(140deg, var(--primary), #4a92f2);
    color: #ffffff;
}

.ghost-btn {
    background: #edf3fd;
    color: var(--text);
}

.danger-btn {
    background: #ffeceb;
    color: var(--danger);
}

.icon-btn {
    background: #edf3fd;
    color: var(--text);
    border-radius: 10px;
    padding: 7px 10px;
}

.pill-btn:hover,
.create-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.icon-btn:hover {
    transform: translateY(-1px);
}

.feature-list {
    list-style: disc;
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.35;
    font-size: 0.86rem;
}

.upcoming-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.calendar-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.calendar-item {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 10px;
    align-items: center;
    padding: 8px 9px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
}

.calendar-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 700;
}

.calendar-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.calendar-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.day-event-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.day-event {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    gap: 10px;
    align-items: flex-start;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    padding: 9px;
    text-align: left;
    cursor: pointer;
}

.day-event:hover {
    transform: translateY(-1px);
}

.day-event.selected {
    border-color: rgba(26, 115, 232, 0.35);
    box-shadow: 0 10px 18px rgba(26, 115, 232, 0.12);
}

.day-event h3 {
    margin: 0;
    font-size: 0.92rem;
}

.day-event p {
    margin: 2px 0 0;
    font-size: 0.81rem;
    color: var(--muted);
}

.panel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.panel-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-sm {
    padding: 7px 11px;
    font-size: 0.82rem;
}

.event-details {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    padding: 10px;
}

.event-details.empty {
    color: var(--muted);
}

.event-details h3 {
    margin: 0;
    font-size: 1.02rem;
}

.event-details .meta {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.35;
}

.event-details .meta-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    margin-left: 6px;
}

.event-details .meta-link:hover {
    text-decoration: underline;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 900;
    border: 1px solid rgba(100, 116, 139, 0.28);
    background: rgba(226, 232, 240, 0.65);
    color: #1f2a44;
    white-space: nowrap;
}

.status-pill[data-kind="event"] {
    background: rgba(26, 115, 232, 0.12);
    border-color: rgba(26, 115, 232, 0.25);
}

.status-pill[data-kind="note"] {
    background: rgba(15, 157, 88, 0.10);
    border-color: rgba(15, 157, 88, 0.22);
}

.notes-block {
    margin-top: 12px;
}

.notes-head h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
}

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.note-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    padding: 9px;
}

.note-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.note-when {
    color: var(--muted);
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-item p {
    margin: 0;
    color: var(--text);
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.note-item .note-meta {
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 0.78rem;
}

.note-item .note-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.note-composer {
    margin-top: 10px;
    border: 1px dashed rgba(100, 116, 139, 0.45);
    border-radius: 12px;
    padding: 10px;
    background: rgba(237, 243, 253, 0.65);
}

.note-composer.hidden {
    display: none;
}

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

.agenda-item {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 10px;
    align-items: flex-start;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    padding: 9px;
}

.agenda-item h3 {
    margin: 0;
    font-size: 0.92rem;
}

.agenda-item p {
    margin: 2px 0 0;
    font-size: 0.81rem;
    color: var(--muted);
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
}

.empty-text {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

kbd {
    border: 1px solid #b4c8e9;
    border-bottom-width: 2px;
    border-radius: 6px;
    background: #ffffff;
    padding: 1px 5px;
    font-size: 0.76rem;
}

.fc-theme-standard td,
.fc-theme-standard th,
.fc-theme-standard .fc-scrollgrid {
    border-color: #d8e3f3;
}

.fc .fc-toolbar-title {
    font-size: 1.1rem;
    font-weight: 800;
}

.fc .fc-button-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active,
.fc .fc-button-primary:hover {
    background: var(--primary-strong);
    border-color: var(--primary-strong);
}

.fc .fc-timegrid-slot {
    height: 2.25em;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 17, 42, 0.44);
}

.modal-card {
    position: relative;
    width: min(760px, 94vw);
    max-height: 92vh;
    overflow: auto;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: #ffffff;
    box-shadow: 0 22px 44px rgba(5, 17, 42, 0.32);
}

.modal-header {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

#eventForm {
    padding: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.span-2 {
    grid-column: span 2;
}

.field.inline {
    margin-top: 0;
}

.field.inline label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text);
}

.inline-input {
    display: grid;
    grid-template-columns: 90px auto;
    align-items: center;
    gap: 8px;
}

.inline-input span {
    color: var(--muted);
    font-size: 0.84rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 120;
    transform: translateX(-50%);
    background: #142442;
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(5, 17, 42, 0.24);
}

.toast.error {
    background: #8c211a;
}

.toast.hidden {
    display: none;
}

.mobile-only {
    display: none;
}

@media (max-width: 1100px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    #mainCalendar {
        min-height: 60vh;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar-right {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .mobile-only {
        display: none !important;
    }

    .sidebar {
        position: static;
        width: auto;
        overflow: visible;
        transform: none !important;
        z-index: auto;
    }
}

@media (max-width: 760px) {
    .topbar {
        flex-wrap: wrap;
    }

    .topbar-right {
        width: 100%;
        gap: 8px;
    }

    .topbar-right .pill-btn,
    .topbar-right .ghost-btn {
        flex: 1 1 auto;
        text-align: center;
    }

    .user-pill {
        max-width: 100%;
        width: 100%;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }
}
