.ftk-app,
.ftk-login-box,
.ftk-access-denied,
.ftk-login-status,
.ftk-profile-box {
    box-sizing: border-box;
    margin: 24px auto;
    font-size: 16px;
}

/*
 * Der Kalender darf sich unabhängig von einer schmalen Theme-Inhaltsspalte
 * bis auf 1280 Pixel verbreitern, bleibt aber stets innerhalb des Viewports.
 */
.ftk-app {
    position: relative;
    left: 50%;
    width: min(1280px, calc(100vw - 24px));
    max-width: 1280px;
    margin-right: 0;
    margin-left: 0;
    transform: translateX(-50%);
}

.ftk-login-box,
.ftk-access-denied,
.ftk-login-status,
.ftk-profile-box {
    width: calc(100% - 24px);
    max-width: 1280px;
}

.ftk-app *,
.ftk-login-box *,
.ftk-profile-box *,
.ftk-modal,
.ftk-modal * {
    box-sizing: border-box;
}

.ftk-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 12px 16px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    background: #fff;
}

.ftk-topbar-separator {
    margin: 0 5px;
}

.ftk-user-links {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.ftk-profile-link,
.ftk-logout-link {
    white-space: nowrap;
}

.ftk-calendar {
    width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 18px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    background: #fff;
}

.ftk-calendar .fc {
    width: 100%;
    min-width: 0;
}

.ftk-calendar .fc .fc-view-harness {
    max-width: 100%;
}

.ftk-calendar .fc .fc-scroller {
    -webkit-overflow-scrolling: touch;
}

.ftk-notice,
.ftk-form-error,
.ftk-access-denied {
    margin: 12px 0;
    padding: 12px 14px;
    border-left: 4px solid #d63638;
    background: #fcf0f1;
}

.ftk-notice {
    border-left-color: #2271b1;
    background: #f0f6fc;
}

.ftk-login-box {
    max-width: 480px;
    padding: 24px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    background: #fff;
}

.ftk-login-box h2 {
    margin-top: 0;
}

.ftk-field {
    margin-bottom: 16px;
}

.ftk-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.ftk-field input[type="text"],
.ftk-field input[type="password"],
.ftk-field input[type="email"],
.ftk-field input[type="date"],
.ftk-field input[type="datetime-local"],
.ftk-field input[type="time"],
.ftk-field select,
.ftk-field textarea {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    background: #fff;
    color: #1d2327;
    font: inherit;
}

.ftk-field textarea {
    resize: vertical;
}

.ftk-field small {
    display: block;
    margin-top: 5px;
    color: #646970;
}

.ftk-checkbox-field label,
.ftk-reminder-toggle,
.ftk-login-options label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 400;
}

.ftk-fields-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.ftk-time-field[hidden] {
    display: none !important;
}

.ftk-login-options {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.ftk-button {
    min-height: 40px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
}

.ftk-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.ftk-button-primary {
    border-color: #2271b1;
    background: #2271b1;
    color: #fff;
}

.ftk-button-secondary {
    border-color: #8c8f94;
    background: #f6f7f7;
    color: #2c3338;
}

.ftk-button-danger {
    border-color: #d63638;
    background: #d63638;
    color: #fff;
}


.ftk-profile-box {
    max-width: 760px;
    padding: 24px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    background: #fff;
}

.ftk-profile-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.ftk-profile-heading h2 {
    margin: 0 0 6px;
}

.ftk-profile-heading p {
    margin: 0;
    color: #50575e;
}

.ftk-profile-notice {
    margin-bottom: 20px;
    padding: 12px 14px;
    border-left: 4px solid #d63638;
    background: #fcf0f1;
}

.ftk-profile-notice.is-success {
    border-left-color: #00a32a;
    background: #edfaef;
}

.ftk-profile-password {
    margin: 4px 0 20px;
    padding: 16px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
}

.ftk-profile-password legend {
    padding: 0 6px;
    font-weight: 600;
}

.ftk-profile-help {
    margin-top: 0;
    color: #646970;
    font-size: 14px;
}

.ftk-profile-box .ftk-button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.ftk-modal[hidden] {
    display: none;
}

.ftk-modal {
    position: fixed;
    z-index: 2147483000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding-top: calc(var(--ftk-modal-viewport-top, 0px) + var(--ftk-modal-top-offset, 0px) + env(safe-area-inset-top, 0px) + 10px);
    padding-right: calc(env(safe-area-inset-right, 0px) + 10px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    padding-left: calc(env(safe-area-inset-left, 0px) + 10px);
    overscroll-behavior: contain;
}

.ftk-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.ftk-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(680px, 100%);
    max-height: calc(var(--ftk-modal-viewport-height, 100vh) - var(--ftk-modal-viewport-top, 0px) - var(--ftk-modal-top-offset, 0px) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 20px);
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px;
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 14px 50px rgba(0, 0, 0, 0.25);
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.ftk-modal-dialog h2 {
    margin-top: 0;
    padding-right: 36px;
}

.ftk-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: 0;
    background: transparent;
    color: #50575e;
    cursor: pointer;
    font-size: 30px;
    line-height: 1;
}

.ftk-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.ftk-actions-spacer {
    flex: 1;
}

.ftk-event-meta {
    padding: 10px 12px;
    border-radius: 4px;
    background: #f6f7f7;
    color: #50575e;
    font-size: 13px;
}

.ftk-calendar .fc .fc-toolbar-title {
    font-size: clamp(1.15rem, 2vw, 1.6rem);
}

.ftk-calendar .fc .fc-button {
    text-transform: none;
}

.ftk-calendar .fc .fc-fullDayToggle-button[hidden] {
    display: none !important;
}

.ftk-calendar .fc .fc-toolbar {
    gap: 12px;
}

.ftk-calendar .fc .fc-toolbar-chunk {
    min-width: 0;
}

.ftk-event-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    white-space: normal;
    line-height: 1.2;
}

.ftk-event-title-text {
    order: 1;
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-weight: 600;
}

.ftk-event-time-text {
    order: 2;
    margin-top: 2px;
    overflow: visible;
    white-space: normal;
    font-size: 0.9em;
}

.ftk-calendar .fc .fc-event-main,
.ftk-calendar .fc .fc-event-main-frame,
.ftk-calendar .fc .fc-daygrid-event-harness,
.ftk-calendar .fc .fc-daygrid-event {
    min-width: 0;
}

.ftk-reminder-field {
    padding: 12px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    background: #f6f7f7;
}

.ftk-reminder-toggle {
    margin-bottom: 10px;
}

.ftk-reminder-options {
    display: grid;
    grid-template-columns: minmax(180px, auto) minmax(190px, 1fr);
    align-items: center;
    gap: 10px;
}

.ftk-reminder-options label {
    margin: 0;
}

.ftk-reminder-options.is-disabled {
    opacity: 0.55;
}

@media (max-width: 1024px) {
    .ftk-calendar .fc .fc-toolbar {
        flex-wrap: wrap;
    }
}

@media (max-width: 720px) {
    .ftk-fields-row,
    .ftk-reminder-options {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .ftk-topbar,
    .ftk-login-options,
    .ftk-profile-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .ftk-user-links {
        width: 100%;
    }

    .ftk-app {
        width: calc(100vw - 12px);
    }

    .ftk-calendar {
        padding: 8px;
    }

    /*
     * Die Wochenansicht behält auf Smartphones lesbare Tagesspalten und kann
     * innerhalb des Kalenders horizontal per Touch bewegt werden.
     */
    .ftk-calendar.ftk-week-view .fc .fc-view-harness {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-gutter: stable;
    }

    .ftk-calendar.ftk-week-view .fc .fc-timeGridWeek-view {
        min-width: 760px;
    }

    .ftk-calendar .fc .fc-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .ftk-calendar .fc .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }

    .ftk-actions {
        flex-wrap: wrap;
    }

    .ftk-actions-spacer {
        display: none;
    }
}

@media (max-width: 480px) {
    .ftk-app {
        width: calc(100vw - 8px);
        margin-top: 8px;
        margin-bottom: 8px;
    }

    .ftk-topbar {
        gap: 8px;
        margin-bottom: 8px;
        padding: 10px;
        font-size: 14px;
    }

    .ftk-calendar {
        padding: 5px;
        border-radius: 4px;
    }

    .ftk-calendar .fc .fc-toolbar-title {
        font-size: 1.05rem;
        line-height: 1.25;
        text-align: center;
    }

    .ftk-calendar .fc .fc-button {
        padding: 0.38em 0.58em;
        font-size: 0.84em;
    }

    .ftk-calendar .fc .fc-col-header-cell-cushion,
    .ftk-calendar .fc .fc-daygrid-day-number {
        padding: 3px 2px;
        font-size: 11px;
    }

    .ftk-calendar .fc .fc-daygrid-event,
    .ftk-calendar .fc .fc-timegrid-event {
        font-size: 11px;
    }

    .ftk-calendar .fc .fc-daygrid-day-events {
        margin: 0 1px;
    }

    .ftk-modal {
        align-items: flex-start;
        padding-top: calc(var(--ftk-modal-viewport-top, 0px) + var(--ftk-modal-top-offset, 0px) + env(safe-area-inset-top, 0px) + 6px);
        padding-right: calc(env(safe-area-inset-right, 0px) + 6px);
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
        padding-left: calc(env(safe-area-inset-left, 0px) + 6px);
    }

    .ftk-modal-dialog {
        width: 100%;
        max-height: calc(var(--ftk-modal-viewport-height, 100vh) - var(--ftk-modal-viewport-top, 0px) - var(--ftk-modal-top-offset, 0px) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 12px);
        margin: 0;
        padding: 18px 14px;
    }

    .ftk-modal-dialog h2 {
        margin-bottom: 18px;
        font-size: 1.35rem;
        line-height: 1.25;
    }

    .ftk-actions .ftk-button {
        flex: 1 1 auto;
    }
}

.ftk-subscription-box {
    max-width: 900px;
}

.ftk-subscription-warning {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-left: 4px solid #dba617;
    background: #fcf9e8;
}

.ftk-subscription-card {
    margin: 18px 0;
    padding: 18px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    background: #f9f9f9;
}

.ftk-subscription-card h3 {
    margin-top: 0;
}

.ftk-subscription-card label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.ftk-subscription-card input[type="url"] {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    background: #fff;
    font: inherit;
}

.ftk-url-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.ftk-url-row .ftk-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    white-space: nowrap;
}

@media screen and (max-width: 680px) {
    .ftk-url-row {
        grid-template-columns: 1fr;
    }

    .ftk-url-row .ftk-button {
        width: 100%;
    }

    .ftk-subscription-box .ftk-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .ftk-subscription-box .ftk-actions-spacer {
        display: none;
    }
}
