* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0 0 88px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    background: #f4f1e8;
    color: #203425;
}

body.page-input {
    padding-bottom: 176px;
}

.page {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 18px 14px 32px;
}

.header {
    margin-bottom: 16px;
}

.app-title {
    margin: 0;
    font-size: 26px;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.sub {
    margin: 4px 0 0;
    color: #6b705c;
    font-size: 13px;
    font-weight: 700;
}

.card {
    width: 100%;
    background: #ffffff;
    border-radius: 22px;
    padding: 18px 14px;
    margin-bottom: 14px;
    box-shadow: 0 8px 24px rgba(32, 52, 37, 0.10);
    overflow: hidden;
}

.card.menu-open-card {
    overflow: visible;
}

.date-card {
    padding: 14px;
}

.section-title {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 900;
}

.error {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #fdecec;
    color: #9f1d1d;
    font-weight: 800;
    font-size: 14px;
}

label {
    display: block;
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 900;
    color: #4d5a43;
}

input,
textarea,
select {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #d5d0c3;
    border-radius: 14px;
    background: #fffdf8;
    color: #203425;
    font-size: 16px;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

input[type="date"] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

textarea {
    min-height: 88px;
    resize: vertical;
    line-height: 1.6;
}

.field {
    margin-bottom: 14px;
    min-width: 0;
}

.field:last-child {
    margin-bottom: 0;
}

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

.button,
.save-button {
    width: 100%;
    border: none;
    background: #203425;
    color: #ffffff;
    font-weight: 900;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button {
    min-height: 46px;
    padding: 0 18px;
    border-radius: 14px;
    font-size: 15px;
}

.save-button {
    min-height: 56px;
    border-radius: 18px;
    font-size: 17px;
    box-shadow: 0 8px 18px rgba(32, 52, 37, 0.22);
}

/* auth */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 22px;
    padding: 28px 24px;
    box-shadow: 0 12px 32px rgba(32, 52, 37, 0.16);
}

.auth-title {
    margin: 0 0 8px;
    font-size: 26px;
    line-height: 1.3;
    text-align: center;
    font-weight: 900;
}

.auth-lead {
    margin: 0 0 24px;
    text-align: center;
    color: #6b705c;
    font-size: 14px;
}

.auth-link {
    margin-top: 18px;
    text-align: center;
    font-size: 14px;
}

.auth-link a {
    color: #203425;
    font-weight: 800;
    text-decoration: none;
}

.auth-button {
    width: 100%;
    min-height: 52px;
    margin-top: 24px;
    border: none;
    border-radius: 16px;
    background: #203425;
    color: #ffffff;
    font-size: 16px;
    font-weight: 900;
    cursor: pointer;
}

/* input.php */

.tab-card {
    padding: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
}

.tab-button {
    min-height: 44px;
    border: 1px solid #d5d0c3;
    border-radius: 999px;
    background: #f8f6f0;
    color: #6b705c;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
}

.tab-button.active {
    border-color: #203425;
    background: #203425;
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(32, 52, 37, 0.18);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.assist-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 900;
    color: #6b705c;
}

.assist-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.assist-button,
.add-button,
.remove-row-button {
    border: 1px solid #d5d0c3;
    border-radius: 999px;
    background: #f8f6f0;
    color: #203425;
    font-weight: 900;
    cursor: pointer;
}

.assist-button {
    padding: 9px 13px;
    font-size: 13px;
}

.rows {
    display: grid;
    gap: 10px;
}

.item-card {
    position: relative;
    display: grid;
    gap: 10px;
    padding: 13px;
    border: 1px solid #e2ddd1;
    border-radius: 18px;
    background: #fffdf8;
}

.item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 28px;
}

.item-title {
    font-size: 13px;
    font-weight: 900;
    color: #6b705c;
}

.food-card .item-body {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(86px, 0.7fr);
    gap: 8px;
}

.exercise-card .item-body {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(70px, 0.6fr) minmax(78px, 0.65fr) minmax(78px, 0.65fr);
    gap: 8px;
}

.remove-row-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    background: #ffffff;
    color: #8a4b3a;
}

.add-button {
    width: 100%;
    min-height: 46px;
    margin-top: 12px;
    padding: 10px 12px;
    font-size: 14px;
}

.save-area {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 74px;
    z-index: 30;
    padding: 10px 14px;
    background: rgba(244, 241, 232, 0.94);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(213, 208, 195, 0.9);
}

.save-area-inner {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}

/* record.php */

.date-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.date-field {
    min-width: 0;
}

.category-block {
    margin-top: 18px;
}

.category-title {
    margin: 0 0 8px;
    padding: 9px 12px;
    border-radius: 14px;
    background: #e8eadf;
    color: #203425;
    font-size: 17px;
    font-weight: 900;
}

.log-list {
    border: 1px solid #e1dccc;
    border-radius: 18px;
    overflow: visible;
    background: #fbfaf5;
}

.log-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 8px;
    align-items: center;
    padding: 13px 10px 13px 14px;
    border-bottom: 1px solid #e8e3d4;
}

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

.item {
    font-size: 17px;
    font-weight: 900;
    line-height: 1.4;
    word-break: break-word;
}

.detail {
    margin-top: 4px;
    color: #5f675a;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.log-menu {
    position: relative;
    justify-self: end;
}

.log-menu summary {
    list-style: none;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: #e8eadf;
    color: #203425;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
}

.log-menu summary::-webkit-details-marker {
    display: none;
}

.menu-actions {
    position: absolute;
    right: 0;
    top: 40px;
    z-index: 10;
    min-width: 100px;
    padding: 8px;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(32, 52, 37, 0.20);
    display: grid;
    gap: 8px;
}

.edit-link,
.delete-button {
    width: 100%;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
}

.edit-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #203425;
    color: #ffffff;
    text-decoration: none;
}

.delete-button {
    border: 1px solid #b84a4a;
    background: #fff7f7;
    color: #9f1d1d;
}

.empty {
    color: #6b705c;
    font-weight: 800;
    line-height: 1.7;
}

/* edit.php */

.back-link {
    display: block;
    margin-top: 16px;
    text-align: center;
    color: #6b705c;
    font-size: 14px;
    font-weight: 900;
    text-decoration: none;
}

/* export.php */

.note {
    margin: 12px 0 0;
    color: #6b705c;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.7;
}

/* footer */

.footer-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 253, 248, 0.96);
    border-top: 1px solid #d5d0c3;
    backdrop-filter: blur(8px);
    z-index: 40;
}

.footer-inner {
    max-width: 760px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}

.footer-link {
    display: block;
    padding: 12px 4px 14px;
    text-align: center;
    color: #6b705c;
    text-decoration: none;
    font-size: 13px;
    font-weight: 900;
}

.footer-link.active {
    color: #203425;
}

/* utility */

.mt-12 {
    margin-top: 12px;
}

/* responsive */

@media (min-width: 561px) {
    .date-form {
        grid-template-columns: minmax(0, 1fr) 120px;
        align-items: end;
    }
}

@media (max-width: 560px) {
    body.page-input {
        padding-bottom: 176px;
    }

    .page {
        padding: 14px 10px 28px;
    }

    .card {
        padding: 14px 12px;
        border-radius: 20px;
    }

    .auth-page {
        padding: 18px;
    }

    .auth-card {
        padding: 24px 20px;
    }

    .date-card,
    .tab-card {
        padding: 10px;
    }

    .tabs {
        gap: 6px;
    }

    .tab-button {
        min-height: 42px;
        font-size: 13px;
    }

    .food-card .item-body {
        grid-template-columns: minmax(0, 1.45fr) minmax(74px, 0.6fr);
    }

    .exercise-card .item-body {
        grid-template-columns: minmax(0, 1.25fr) minmax(66px, 0.55fr) minmax(76px, 0.6fr);
    }

    .exercise-card .distance-field {
        grid-column: 1 / 4;
    }

    input,
    textarea,
    select {
        min-height: 42px;
        padding: 8px 9px;
        font-size: 16px;
    }

    .save-area {
        bottom: 73px;
        padding: 9px 10px;
    }

    .save-button {
        min-height: 52px;
    }

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