:root {
    color-scheme: light;
    --bg: #f5f1e8;
    --panel: #fffaf2;
    --ink: #231f20;
    --muted: #6d6258;
    --line: #d6c7b5;
    --accent: #1f6f78;
    --accent-strong: #134b56;
    --danger: #b0402f;
    --shadow: 0 18px 40px rgba(35, 31, 32, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top right, rgba(31, 111, 120, 0.15), transparent 35%),
        linear-gradient(180deg, #f7f2ea 0%, #f1e9dc 100%);
}

a {
    color: inherit;
}

.shell {
    width: min(1480px, calc(100% - 32px));
    margin: 24px auto 40px;
}

.site-head {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.site-logo {
    display: block;
    width: 120px;
    max-width: 100%;
    height: auto;
}

.panel {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 250, 242, 0.95);
    box-shadow: var(--shadow);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

button,
select,
input {
    font: inherit;
}

button,
.button-link {
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
}

.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 14px;
}

.icon-link.plain-icon {
    width: auto;
    height: auto;
    padding: 4px;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
}

.icon-link.plain-icon:hover {
    background: transparent;
    color: var(--accent-strong);
}

.icon-link svg {
    width: 22px;
    height: 22px;
}

.auth-only[hidden] {
    display: none;
}

button.secondary,
.button-link.secondary {
    background: #e5dccf;
    color: var(--ink);
}

button.danger {
    background: var(--danger);
}

button.table-action {
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 0.86rem;
}

button:disabled {
    cursor: wait;
    opacity: 0.75;
}

select,
input {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
}

.status-line {
    min-height: 24px;
    color: var(--muted);
}

#quick-search {
    min-width: min(280px, 100%);
}

.calendar-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.calendar-search {
    min-width: min(280px, 100%);
}

#calendar {
    min-height: 700px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(35, 31, 32, 0.55);
}

.modal.open {
    display: grid;
}

.modal-card {
    position: relative;
    z-index: 2001;
    width: min(100%, 520px);
    padding: 20px;
    border-radius: 18px;
    background: #fffaf2;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.modal-card h2 {
    margin-top: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.detail-block {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.detail-notes {
    margin-top: 8px;
    min-height: 72px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--line);
    white-space: pre-wrap;
    line-height: 1.45;
}

.detail-label {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.tabulator {
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: #fffaf2;
}

.tabulator .tabulator-header {
    background: #e9dfd0;
    border-bottom: 1px solid var(--line);
}

.tabulator .tabulator-col,
.tabulator .tabulator-cell {
    padding-left: 6px;
    padding-right: 6px;
    font-size: 0.92rem;
}

.tabulator .tabulator-col-title {
    font-size: 0.9rem;
}

.tabulator .tabulator-tableholder {
    background: #fffaf2;
}

.tabulator .tabulator-footer,
.tabulator .tabulator-row {
    background: transparent;
}

.tabulator .tabulator-row.tabulator-row-even {
    background: rgba(255, 250, 242, 0.7);
}

.tabulator .tabulator-row.row-past,
.tabulator .tabulator-row.row-past.tabulator-row-even {
    background: rgba(109, 98, 88, 0.08);
}

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

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 0.9rem;
}

.calendar-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.filter-pill {
    border: 0;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    background: #e5dccf;
    color: var(--muted);
}

.filter-pill.active {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.filter-pill[data-filter="all"].active {
    background: rgba(166, 120, 32, 0.16);
    color: #7c5713;
}

.filter-pill[data-filter="public"].active {
    background: rgba(48, 132, 70, 0.16);
    color: #245f32;
}

.filter-pill[data-filter="internal"].active {
    background: rgba(42, 102, 186, 0.14);
    color: #1f4d91;
}

.event-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.event-chip.public {
    background: rgba(48, 132, 70, 0.16);
    color: #245f32;
}

.event-chip.internal {
    background: rgba(42, 102, 186, 0.14);
    color: #1f4d91;
}

.event-chip.both {
    background: rgba(166, 120, 32, 0.16);
    color: #7c5713;
}

.visibility-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
}

.visibility-badge.none {
    background: rgba(176, 64, 47, 0.14);
    color: var(--danger);
}

.visibility-badge.public {
    background: rgba(48, 132, 70, 0.16);
    color: #245f32;
}

.visibility-badge.internal {
    background: rgba(42, 102, 186, 0.14);
    color: #1f4d91;
}

.visibility-badge.both {
    background: rgba(166, 120, 32, 0.16);
    color: #7c5713;
}

.event-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.event-inline span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.notes-preview {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: pre-wrap;
    line-height: 1.35;
    max-height: calc(1.35em * 2);
}

.head-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(35, 31, 32, 0.55);
}

.editor-dialog {
    width: min(100%, 760px);
    padding: 18px;
    border-radius: 18px;
    background: #fffaf2;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.editor-head {
    margin-bottom: 12px;
}

.editor-textarea {
    width: 100%;
    min-height: 260px;
    resize: vertical;
    font: inherit;
    line-height: 1.45;
}

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

@media (max-width: 800px) {
    .shell {
        width: min(100%, calc(100% - 20px));
        margin: 10px auto 24px;
    }

    .panel {
        padding: 16px;
        border-radius: 16px;
    }

    .site-head {
        margin-bottom: 14px;
    }

    .site-logo {
        max-width: 100%;
    }
}
