* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: #08082d;
    color: white;
    font-family: Arial, Helvetica, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

button {
    border: none;
    background: none;
    color: inherit;
    font-family: inherit;
}

.app {
    width: 100%;
    height: 100vh;
    min-height: 100vh;

    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);

    display: flex;
    flex-direction: column;

    background: #08082d;
}


/* =========================
   TOP BAR
   ========================= */

.top-bar {
    height: 88px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 55px;
}

.icon-button {
    width: 55px;
    height: 55px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 48px;
    font-weight: 300;

    cursor: pointer;
}

.close-button {
    font-size: 58px;
    line-height: 1;
}

.settings-button {
    font-size: 42px;
}

.progress {
    font-size: 30px;
    font-weight: 700;
}


/* =========================
   PROGRESS LINE
   ========================= */

.progress-line {
    width: 100%;
    height: 8px;

    background: #555b70;
}

.progress-fill {
    width: 85%;
    height: 100%;

    background: #e4e4e8;
}


/* =========================
   FORGOT / REMEMBER
   ========================= */

.result-bar {
    height: 125px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 0;
}

.count {
    width: 72px;
    height: 68px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 29px;
    font-weight: bold;

    border: 2px solid;
}

.forgot {
    color: #ffad3d;
    border-color: #ffad3d;

    border-left: none;

    border-radius: 0 34px 34px 0;
}

.remember {
    color: #48e8c0;
    border-color: #48e8c0;

    border-right: none;

    border-radius: 34px 0 0 34px;
}


/* =========================
   CARD AREA
   ========================= */

.card-area {
    flex: 1;

    display: flex;
    justify-content: center;

    padding: 0 48px;
}

.flashcard {
    width: 100%;
    max-width: 735px;

    height: 100%;

    max-height: 1280px;

    position: relative;

    background: #202143;

    border: 2px solid #31355c;
    border-radius: 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;
}


/* =========================
   CARD TEXT
   ========================= */

.card-text {
    width: 100%;
    max-height: calc(100% - 180px);
    padding: 40px;

    text-align: justify;

    font-size: clamp(28px, 4vw, 54px);
    line-height: 1.35;

    font-weight: 400;

    overflow-x: hidden;
    overflow-y: auto;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}


/* =========================
   MOBILE
   ========================= */

@media (max-width: 600px) {

    .top-bar {
        height: 75px;
        padding: 0 18px;
    }

    .progress {
        font-size: 22px;
    }

    .icon-button {
        width: 45px;
        height: 45px;
    }

    .close-button {
        font-size: 45px;
    }

    .settings-button {
        font-size: 32px;
    }

    .result-bar {
        height: 90px;
    }

    .count {
        width: 58px;
        height: 52px;

        font-size: 23px;
    }

    .card-area {
        padding: 0 20px;
    }

    .flashcard {
        border-radius: 32px;
    }

    .card-text {
        max-height: calc(100% - 120px);
        font-size: 30px;
        padding: 25px;
    }

}
/* =========================
   SCREEN SYSTEM
   ========================= */

.screen {
    width: 100%;
    height: 100%;
}

.study-screen {
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}


/* =========================
   HOME
   ========================= */

.home-screen {
    padding: 50px 25px;

    display: flex;
    flex-direction: column;
    align-items: center;

    overflow-y: auto;
}

.home-header {
    position: relative;
    width: min(100%, 600px);
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 35px;
}

.home-screen h1 {
    margin: 0;

    font-size: 32px;
    letter-spacing: 2px;
}

.home-settings-button {
    position: absolute;
    top: 0;
    right: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #464a75;
    border-radius: 8px;
    background: #202143;
    font-size: 27px;
    line-height: 1;
    cursor: pointer;
}

.home-settings-button:active {
    transform: scale(0.96);
}

.main-button {
    width: min(90%, 400px);

    padding: 18px;
    margin-bottom: 15px;

    border: 1px solid #464a75;
    border-radius: 15px;

    background: #202143;

    color: white;

    font-size: 18px;
    font-weight: bold;

    cursor: pointer;
}

.main-button:active {
    transform: scale(0.98);
}

/* =========================
   CARD LIST
   ========================= */

.card-list-container {
    width: min(90%, 600px);
}

.card-list-container h2 {
    margin-bottom: 15px;

    font-size: 18px;
}

.folder-list {
    display: grid;
    gap: 10px;
}

.folder-list-item {
    width: 100%;
    min-height: 68px;
    padding: 14px 16px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    border: 1px solid #31355c;
    border-radius: 10px;
    background: #202143;
    color: white;
    text-align: left;
    cursor: pointer;
}

.folder-icon {
    font-size: 22px;
}

.folder-name {
    overflow-wrap: anywhere;
    font-size: 16px;
    font-weight: 700;
}

.folder-count {
    color: #bfc4dc;
    font-size: 13px;
    white-space: nowrap;
}

.empty-folder-state {
    padding: 24px 12px;
    color: #bfc4dc;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
}

#newFolderButton {
    width: 100%;
    margin-top: 12px;
}

.folder-name-input {
    width: 100%;
    min-height: 52px;
    padding: 14px;
    border: 1px solid #464a75;
    border-radius: 10px;
    outline: none;
    background: #202143;
    color: white;
    font: inherit;
}

.folder-name-input:focus {
    border-color: #777cff;
}

.folder-detail-screen {
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.folder-detail-header {
    flex: 0 0 70px;
}

.folder-detail-header h2 {
    min-width: 0;
    overflow-wrap: anywhere;
}

.folder-menu-anchor {
    position: relative;
    flex: 0 0 auto;
    margin-left: auto;
}

.folder-menu-trigger {
    width: 44px;
    height: 44px;
    border: 1px solid #464a75;
    border-radius: 8px;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.folder-menu {
    position: absolute;
    z-index: 5;
    top: calc(100% + 6px);
    right: 0;
    width: 190px;
    padding: 6px;
    border: 1px solid #464a75;
    border-radius: 8px;
    background: #202143;
    box-shadow: 0 10px 28px rgb(0 0 0 / 30%);
}

.folder-menu button {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
}

.folder-menu button:hover {
    background: #31355c;
}

.folder-menu .menu-danger {
    color: #ff8796;
}

.folder-modal {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgb(0 0 0 / 68%);
}

.folder-modal-content {
    width: min(100%, 420px);
    padding: 24px;
    border: 1px solid #464a75;
    border-radius: 10px;
    background: #202143;
    box-shadow: 0 18px 48px rgb(0 0 0 / 35%);
}

.folder-modal-content h2 {
    margin-bottom: 14px;
    font-size: 20px;
}

.folder-modal-content p {
    color: #d4d6e5;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-line;
}

.folder-modal-content .folder-name-input {
    margin-top: 16px;
}

.folder-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 24px;
}

.folder-modal-actions.single-action {
    grid-template-columns: 1fr;
}

.folder-modal-button {
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid #555b8a;
    border-radius: 8px;
    background: transparent;
    color: white;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.folder-modal-danger {
    border-color: #b82c42;
    background: #b82c42;
    color: white;
}

.settings-container > h3 {
    margin-bottom: 6px;
    font-size: 18px;
}

.settings-container .save-button {
    margin-top: 10px;
}

.settings-action-button {
    width: 100%;
    margin-top: 12px;
}

.install-settings-section {
    margin-top: 30px;
    padding-top: 24px;
    border-top: 1px solid #31355c;
}

.install-settings-section > h3 {
    font-size: 18px;
}

.install-settings-section > p {
    margin-top: 10px;
    color: #bfc4dc;
    font-size: 14px;
    line-height: 1.5;
}

.install-settings-section .settings-action-button {
    margin-top: 16px;
}

.folder-detail-actions {
    width: min(100%, 650px);
    margin: 18px auto 20px;
}

.folder-card-count {
    margin-bottom: 12px;
    color: #bfc4dc;
    font-size: 13px;
    font-weight: 700;
}

.folder-action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.folder-action-buttons .main-button {
    width: 100%;
    margin: 0;
    padding: 14px 10px;
    font-size: 15px;
}

.folder-cards-container {
    width: min(100%, 650px);
    margin: 0 auto;
}

.folder-card-list {
    display: grid;
    gap: 10px;
}

.card-list-item {
    width: 100%;

    padding: 18px;
    margin-bottom: 10px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;

    background: #202143;

    border: 1px solid #31355c;
    border-radius: 15px;

    color: white;

    text-align: left;

    font-size: 16px;
}

.card-list-front {
    min-width: 0;
    overflow-wrap: anywhere;
}

.card-list-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 8px;
}

.card-view-button {
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid #555b8a;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.card-menu-anchor {
    position: relative;
    flex: 0 0 auto;
}

.card-menu-trigger {
    width: 36px;
    height: 36px;
    font-size: 24px;
}

.card-menu {
    width: 150px;
}

/* =========================
   ADD CARD
   ========================= */

.add-screen {
    padding: 20px;

    overflow-y: auto;
}

.form-header {
    height: 70px;

    display: flex;
    align-items: center;

    gap: 20px;
}

.single-card-screen {
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.single-card-header {
    flex: 0 0 70px;
}

.single-card-header h2 {
    min-width: 0;
    overflow-wrap: anywhere;
}

.single-card-screen .card-area {
    min-height: 0;
}

.form-header h2 {
    font-size: 22px;
}

.back-button {
    font-size: 34px;

    cursor: pointer;
}

.form-container {
    width: min(100%, 650px);

    margin: 30px auto;
}

.form-container label {
    display: block;

    margin: 20px 0 8px;

    font-size: 14px;
    font-weight: bold;
}

.form-container textarea {
    width: 100%;
    min-height: 130px;

    padding: 15px;

    resize: vertical;

    border: 1px solid #464a75;
    border-radius: 15px;

    outline: none;

    background: #202143;
    color: white;

    font-size: 17px;
    font-family: inherit;
}

.form-container textarea:focus {
    border-color: #777cff;
}

.save-button {
    width: 100%;

    margin-top: 30px;
    padding: 17px;

    border-radius: 15px;

    background: #31355c;
    color: white;

    font-size: 18px;
    font-weight: bold;

    cursor: pointer;
}

.save-button:active {
    transform: scale(0.98);
}

/* =========================
   STUDY CARD INTERACTION
========================= */

.flashcard {
    cursor: pointer;

    -webkit-tap-highlight-color: transparent;

    will-change: transform, opacity;
    transition:
        transform 0.28s cubic-bezier(0.2, 0.8, 0.3, 1),
        opacity 0.28s ease;
}

.flashcard::after {
    position: absolute;
    top: 28px;
    z-index: 1;
    padding: 8px 14px;
    border: 3px solid currentColor;
    border-radius: 8px;
    font-size: clamp(18px, 3vw, 30px);
    font-weight: 800;
    letter-spacing: 2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s ease;
}

.flashcard.swipe-forgot::after,
.flashcard.swipe-remember::after {
    opacity: 1;
}

.flashcard.swipe-forgot::after {
    left: 28px;
    color: #ffad3d;
    content: "FORGOT";
    transform: rotate(-8deg);
}

.flashcard.swipe-remember::after {
    right: 28px;
    color: #48e8c0;
    content: "REMEMBER";
    transform: rotate(8deg);
}

.flashcard.is-dragging {
    transition: none;
}

.flashcard:active {
    transform: scale(0.985);
}

.card-text {
    transition:
        opacity 0.15s ease,
        transform 0.15s ease;
}

.card-text.flip-animation {
    opacity: 0;
    transform: scale(0.96);
}

/* =====================================================
   SWIPE CONTROL
===================================================== */

.flashcard {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* =====================================================
   STUDY COMPLETE
===================================================== */

.study-complete {
    position: absolute;

    inset: 0;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    text-align: center;

    padding: 25px;

    box-sizing: border-box;
}


.study-complete.hidden {
    display: none;
}


.complete-title {
    font-size: 24px;

    font-weight: 700;

    letter-spacing: 1px;

    margin-bottom: 10px;
}


.complete-subtitle {
    font-size: 14px;

    opacity: 0.7;

    margin-bottom: 8px;
}

.repeat-button {
    width: min(100%, 220px);
    min-height: 46px;
    margin-top: 18px;
    border: 0;
    border-radius: 8px;
    background: white;
    color: #111;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}


.done-button {
    min-height: 42px;
    margin-top: 8px;
    border: 1px solid #555b8a;

    border-radius: 8px;

    padding: 11px 30px;

    font-size: 14px;

    font-weight: 600;

    cursor: pointer;

    background: transparent;

    color: white;

    -webkit-tap-highlight-color: transparent;
}


.done-button:active {
    transform: scale(0.96);
}