*{
    box-sizing: border-box;
    margin: 0;
}

:root {
    /*color palette */
    --accent: #4D4B39;
    --bg-color: #F5F7F0;
    --text-color: #4D4B39;
  }

body {
    font-family: "TW Cen MT", "Jost", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* mode colour palette*/
body.dark-mode {
    --bg-color: #283647;
    --text-color: #E8E4DC;
    --accent: #C45674;
}
body.dark-mode .session-item {
    background: rgba(47, 63, 82, 0.9);
}
body.dark-mode #settingsContent {
    background-color: #2F3F52;
}
body.dark-mode #sleepCatPicture{
    filter: brightness(0.8);
}

#topButtons {
    position: absolute;
    top: 0.7rem;
    right: 0.5rem;
}

#timerLabel{
    font-family: "Caveat", sans-serif;
    font-size: 2.8rem;
    letter-spacing: -0.02em;
    margin: 1rem;
    margin-top: 2rem;
}

#timer{
    font-variant-numeric: tabular-nums;
    font-size: 3rem;
    margin: 1rem;
}

#timer.resetting {
    animation: timerReset 0.3s ease;
}

#best{
    font-family: "Caveat", sans-serif;
    font-size: 1.5rem;
    padding: 1rem 0.6rem 0.2rem;
    text-align: left;
    margin-top: 2rem;
}

button {
    font-family: "TW Cen MT", "Jost", sans-serif;
    font-size: 1rem;
    border: none;
    padding: 0.2rem 0.5rem;
    align-items: center;
    border-radius: 0.5rem;
    background-color: transparent;
    vertical-align: middle;
    color: var(--text-color);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

button:not(:disabled):not(#settingsClose):not(#darkModeToggle):not(#settingsOpen):hover {
    transform: scale(1.05);
}

@media (hover: none) {
    button:hover {
        transform: none !important;
        background-color: transparent !important;
    }
}

button:disabled {
    opacity: 0.3;
    background-color: transparent;
}

#start, #stop, #save, #reset {
    border: 1.5px solid var(--accent);
    background-color: transparent;
    padding: 0.3rem 0.9rem;
}

#save {
    opacity: 0;
    width: 0;
    padding: 0;
    overflow: hidden;
    border: none;
    transition: opacity 0.2s ease, width 0.2s ease, padding 0.2s ease;
}

#save.visible {
    opacity: 1;
    width: 4rem;
    padding: 0.3rem 0.9rem;
    border: 1.5px solid var(--accent);
}

#start:hover, #start:active {
    background-color: rgba(114, 251, 224, 0.3);
}
#stop:hover, #stop:active {
    background-color: rgba(252, 154, 68, 0.3);
}
#reset:hover, #reset:active {
    background-color: rgba(245, 201, 201, 0.3);
}
#save:hover, #save:active {
    background-color: rgba(64, 245, 181, 0.3);
}

body.dark-mode #start:hover, body.dark-mode #start:active {
    background-color: rgba(114, 251, 224, 0.15);
}
body.dark-mode #stop:hover, body.dark-mode #stop:active {
    background-color: rgba(252, 154, 68, 0.15);
}
body.dark-mode #reset:hover, body.dark-mode #reset:active {
    background-color: rgba(245, 201, 201, 0.15);
}
body.dark-mode #save:hover, body.dark-mode #save:active {
    background-color: rgba(64, 245, 181, 0.15);
}

#sessionList {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.4s ease;
    opacity: 1;
    overflow-y: auto;
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

#sessionList.disappearing {
    animation: listDisappear 0.3s ease forwards;
}

#sessionList::-webkit-scrollbar {
    display: none;
}

#sessionList.collapsed {
    max-height: 0;
    opacity: 0;
}

.session-item {
    font-size: .9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0.8rem;
    background: rgba(255,255,255,0.9);
    border-radius: 0.8rem;
    border: 1px outset rgb(from var(--accent) r g b / 20%);
    vertical-align: middle;
    padding: 0.6rem 0.8rem;
}

.session-item.new {
    animation: sessionFadeIn 0.3s ease;
}

.session-item button {
    width: 24px;
    height: 24px;
    line-height: 1;
    padding: 0;
}

#sessionToggle {
    font-size: 0.7rem;
    margin: 1rem;
}

#settingsModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    overflow-y: auto;
    padding-top: 0;
    transition: padding-top 0.3s ease;
}

/* Sliding up animation when clicking the timerlabelinput */
#settingsModal:has(#timerLabelInput:focus) {
    padding-top: 8rem;
}

/* But don't do the sliding-up animation on small screens */
@media (max-width: 600px) {
    #settingsModal:has(#timerLabelInput:focus) {
        padding-top: 0;
    }
}

#settingsModal.animating {
    animation: slideIn 0.25s ease forwards;
}

#settingsModal.closing {
    animation: fadeOut 0.25s ease forwards;
}

#settingsContent {
    background-color: var(--bg-color);
    margin: 2rem auto;
    width: 400px;
    max-width: 80%;
    border-radius: 1rem;
    text-align: left;
    position: relative;
    padding: 2rem 2rem 2rem;
}

#settingsHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

#settingsContent button:not(#settingsClose):not(#confirmYes):not(#confirmNo) {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.8rem;
    border: 1.5px solid var(--accent);
    border-radius: 0.5rem;
}

#settingsContent button:not(#settingsClose):hover,
#settingsContent button:not(#settingsClose):active {
    background-color: rgba(61, 53, 48, 0.08);
}

body.dark-mode #settingsContent button:not(#settingsClose):hover,
body.dark-mode #settingsContent button:not(#settingsClose):active {
    background-color: rgba(232, 228, 220, 0.08);
}

#timerLabelInput {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1.5px solid var(--accent);
    border-radius: 0.5rem;
    font-family: "TW Cen MT", "Jost", sans-serif;
    font-size: 1rem;
    background-color: transparent;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    border-color: var(--accent);
    border-style: dashed;
}

#timerLabelInput:hover {
    outline: none;
    border-color: var(--accent);
    border-style: solid;
    background-color: rgba(232, 228, 220, 0.08);
}

#about {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem 0rem;
    border-top: 1px solid rgba(61,53,48,0.15);
    font-size: 1rem;
    color: var(--text-color);
}

h2{
    font-family: "Caveat";
    font-size: 2rem;
}

#hardReset {
    border-color: #a84444 !important;
    margin-top: 1rem;
    width: 100% !important;
}

#hardReset:hover {
    background-color: rgba(168, 68, 68, 0.3) !important;
}

#confirmModal {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(61,53,48,0.15);
}

#confirmButtons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

#confirmYes, #confirmNo {
    flex: 0.8;
    border: 1.5px solid var(--accent);
    border-radius: 0.5rem;
}

#sleepCatPicture {
    position: relative;
    text-align: center;
    margin-top: 2rem;
    width: 300px;
    z-index: -1;
}

@media (min-width: 600px) {
    #sleepCatPicture {
        position: fixed;
        bottom: 1rem;
        left: 1rem;
        width: 350px;
        z-index: -1;
    }
}

#runCatPicture {
    position: fixed;
    bottom: 1rem;
    width: 300px;
    z-index: -1;
}

@media (min-width: 600px) {
    #runCatPicture {
        position: fixed;
        bottom: 1rem;
        width: 350px;
        z-index: -1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes timerReset {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes sessionFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes listDisappear {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(10px); }
}
