
html {
    background: #000000;
    height: 100%;
}

:root {
    --system-background: #000000;
    --system-raised: #0a0a0a;
    --label-primary: #e0e0e0;
    --label-secondary: #999;
    --label-tertiary: #666;
    --fill-primary: #1a1a1a;
    --fill-secondary: #252525;
    --separator: rgba(255, 255, 255, 0.08);
    --separator-thin: rgba(255, 255, 255, 0.06);
    --border-strong: #1a1a1a;

}

body {
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr min(700px, 45%) 1fr;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    scrollbar-width: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.progression-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0 0.75rem;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    z-index: 10;
    background: #000000;
    overflow: hidden;
}

.progression-days {
    display: flex;
    gap: 0.25rem;
    transition:
        transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.12s ease;
}

.progression-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition:
        background 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    border: none;
    color: #666;
    font-family: inherit;
    outline: none;
    min-width: 48px;
}

.progression-day:hover {
    background: #0a0a0a;
    color: #999;
}

.progression-day.selected {
    background: #1a1a1a;
    color: #e0e0e0;
}

.progression-day.today .progression-date-num {
    color: #fff;
    font-weight: 500;
}

.progression-day-name {
    font-size: 0.6rem;
    font-weight: 400;
    text-transform: uppercase;
}

.progression-date-num {
    font-size: 0.85rem;
    font-weight: 400;
}

.progression-nav {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition:
        color 0.2s ease,
        background 0.2s ease;
    outline: none;
}

.progression-nav:hover {
    color: #e0e0e0;
    background: #1a1a1a;
}

.progression-nav:active {
    transform: scale(0.95);
}

.progression-nav:disabled {
    opacity: 0.2;
    pointer-events: none;
}

.container {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    padding-top: 2rem;
    padding-bottom: 2rem;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.habit-list {
    width: 100%;
    max-width: 100%;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #333 #1a1a1a;
    position: relative;
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 5%,
        black 95%,
        transparent 100%
    );
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 5%,
        black 95%,
        transparent 100%
    );
}

.habit-list-inner {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    display: flex;
    flex-direction: column;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.habit-list-inner:empty::before {
    content: "No habits yet";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    text-align: center;
    color: #666;
    font-size: 0.95rem;
    font-weight: 300;
}

.habit-list::-webkit-scrollbar {
    display: none;
}

.habit-list::-webkit-scrollbar-track {
    background: transparent;
}

.habit-list::-webkit-scrollbar-thumb {
    background-color: transparent;
}

input,
textarea {
    transition:
        color 0.2s ease,
        border-color 0.2s ease;
}

.habit-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid #1a1a1a;
    transition:
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        padding-left 0.3s ease;
    position: relative;
    width: 90%;
    margin: 0 auto;
}

.habit-item-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
    transition: opacity 0.2s ease;
}

.habit-item.adding {
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.habit-item.removing {
    animation: slideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.habit-item.dragging {
    opacity: 0.4;
}

.habit-item.reordering {
    opacity: 0.9;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    background: #1a1a1a;
    border-radius: 8px;
    transition:
        box-shadow 0.2s ease,
        background 0.2s ease;
}

body.dragging-in-progress,
body.dragging-in-progress * {
    user-select: none;
}

.habit-item:hover .habit-title {
    padding-left: 0.5rem;
}

.habit-item:hover .delete-button,
.habit-item:hover .pause-button {
    opacity: 1;
    pointer-events: all;
}

.habit-item.paused .habit-item-content {
    opacity: 0.4;
}

.habit-item.paused .checkbox-wrapper input[type="checkbox"] {
    cursor: default;
}

.habit-item.paused .habit-title {
    text-decoration: line-through;
    text-decoration-color: #666;
}

.checkbox-wrapper {
    position: relative;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.checkbox-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

.checkbox-custom {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #333;
    border-radius: 4px;
    transition:
        border-color 0.2s ease,
        background 0.2s ease;
    pointer-events: none;
}

.checkbox-wrapper input[type="checkbox"]:hover ~ .checkbox-custom {
    border-color: #555;
}

.checkbox-wrapper input[type="checkbox"]:checked ~ .checkbox-custom {
    background: #e0e0e0;
    border-color: #e0e0e0;
}

.checkbox-wrapper input[type="checkbox"]:checked ~ .checkbox-custom::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #000;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.habit-title-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.habit-title {
    flex: 1;
    background: transparent;
    border: none;
    font-family: inherit;
    outline: none;
    color: #e0e0e0;
    transition:
        color 0.2s ease,
        padding-left 0.3s ease;
    width: 95%;
    font-size: 0.95rem;
    padding-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    -webkit-mask-image: linear-gradient(
        to right,
        black 0%,
        black 90%,
        transparent 100%
    );
    mask-image: linear-gradient(
        to right,
        black 0%,
        black 90%,
        transparent 100%
    );
    min-width: 0;
    user-select: text;
}

.habit-title:focus {
    cursor: text;
    color: #fff;
}

.habit-title::placeholder {
    color: #666;
    opacity: 1;
    transition:
        color 0.2s ease,
        opacity 0.2s ease;
}

.habit-title:focus::placeholder,
.habit-item:hover .habit-title::placeholder {
    color: #bbb;
}

.habit-title::selection {
    background: #555;
}

.interval-badge {
    font-size: 0.65rem;
    color: #888;
    border: 1px solid #1a1a1a;
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    font-weight: 400;
    white-space: nowrap;
    cursor: pointer;
    background: transparent;
    font-family: inherit;
    outline: none;
    transition:
        border-color 0.2s ease,
        color 0.2s ease;
    flex-shrink: 0;
}

.interval-badge:hover {
    border-color: #333;
    color: #e0e0e0;
}

.interval-input {
    width: 48px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 0.75rem;
    padding: 0.15rem 0.3rem;
    text-align: center;
    outline: none;
    flex-shrink: 0;
    -moz-appearance: textfield;
}

.interval-input::-webkit-outer-spin-button,
.interval-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.interval-input:focus {
    border-color: #555;
    color: #fff;
}

.pause-button {
    opacity: 0;
    pointer-events: none;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.375rem;
    transition:
        color 0.2s ease,
        opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    outline: none;
}

.pause-button:hover {
    color: #e0e0e0;
}

.pause-button.is-paused {
    opacity: 1;
    pointer-events: all;
    color: #888;
}

.delete-button {
    opacity: 0;
    pointer-events: none;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.375rem;
    transition:
        color 0.2s ease,
        opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    outline: none;
}

.delete-button:hover {
    color: #e0e0e0;
}

.add-button {
    z-index: 5;
    outline: none;
}

.settings-icon {
    z-index: 100;
    outline: none;
}

.mobile-habit-modal {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 1002;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    background: rgba(0, 0, 0, 0.4);
    align-items: flex-end;
    justify-content: center;
}

.mobile-habit-modal.visible {
    opacity: 1;
    pointer-events: all;
}

.mobile-habit-modal-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #0a0a0a;
    border: 1px solid #1a1a1a;
    border-radius: 16px;
    padding: 0.75rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    transform: translateY(calc(100% + env(safe-area-inset-bottom, 0px)))
        scale(0.92);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    width: calc(100% - 2rem);
    max-width: 400px;
    margin-bottom: 16px;
}

.mobile-habit-modal.visible .mobile-habit-modal-content {
    transform: translateY(0) scale(1);
}

.mobile-habit-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    padding: 0.5rem 0.75rem;
    min-width: 0;
    min-height: 44px;
}

.mobile-habit-input::selection {
    background: #555;
}

.mobile-habit-input::placeholder {
    color: #666;
}

.mobile-habit-interval {
    width: 56px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 8px;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.5rem 0.25rem;
    text-align: center;
    outline: none;
    flex-shrink: 0;
    -moz-appearance: textfield;
}

.mobile-habit-interval::-webkit-outer-spin-button,
.mobile-habit-interval::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.mobile-habit-interval::placeholder {
    color: #666;
}

.mobile-habit-interval:focus {
    border-color: #555;
    color: #fff;
}

.mobile-habit-submit {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: #555;
    border: none;
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
    outline: none;
    touch-action: manipulation;
}

.mobile-habit-submit:hover {
    background: #444;
}

.mobile-habit-submit:active {
    transform: scale(0.95);
}

.midnight-reminder {
    position: fixed;
    top: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    z-index: 1004;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.midnight-reminder.visible {
    opacity: 1;
    pointer-events: all;
    transform: translateX(-50%) translateY(0);
}

.midnight-reminder-text {
    background: #0a0a0a;
    border: 1px solid #1a1a1a;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: #999;
    font-size: 0.8rem;
    font-weight: 300;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        backdrop-filter 0.3s ease,
        background 0.3s ease;
    backdrop-filter: blur(0);
    background: rgba(0, 0, 0, 0);
    max-height: 100%;
    overflow-y: auto;
}

.settings-overlay.visible {
    opacity: 1;
    pointer-events: all;
    backdrop-filter: blur(4px);
    background: rgba(0, 0, 0, 0.2);
}

.settings-box {
    background: #0a0a0a;
    border: 1px solid #1a1a1a;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.settings-content {
    color: #999;
    font-size: 0.9rem;
    max-height: 100%;
    overflow-y: auto;
}

@media (max-width: 768px) {
    body {
        grid-template-columns: 1fr;
    }

    .container {
        grid-column: 1;
        width: 90%;
        margin: 0 auto;
    }

    .progression-bar {
        padding: 0.75rem 0 0.5rem;
        gap: 0.25rem;
    }

    .progression-day {
        min-width: 36px;
        padding: 0.3rem 0.35rem;
    }

    .progression-day-name {
        font-size: 0.5rem;
    }

    .progression-date-num {
        font-size: 0.75rem;
    }

    .progression-nav {
        width: 28px;
        height: 28px;
    }

    .habit-item,
    .habit-title {
        font-size: 1.15rem;
    }

    .settings-icon {
        width: 48px;
        height: 48px;
    }

    .add-button {
        width: 72px;
        height: 72px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .habit-item:hover .delete-button,
    .habit-item:hover .pause-button,
    .delete-button,
    .pause-button {
        opacity: 1;
        pointer-events: all;
    }

    .checkbox-wrapper input[type="checkbox"]:hover ~ .checkbox-custom {
        border-color: #333;
    }

    .add-button:hover {
        background: #1a1a1a;
        transform: none;
    }

    .settings-icon:hover {
        color: #e0e0e0;
        background: #000;
        transform: none;
    }

    .progression-day:hover {
        background: transparent;
        color: #666;
    }

    .progression-day.selected:hover {
        background: #1a1a1a;
        color: #e0e0e0;
    }

    .progression-nav:hover {
        color: #666;
        background: transparent;
    }

    .delete-button:hover {
        color: #666;
    }

    .pause-button:hover {
        color: #666;
    }

    .interval-badge:hover {
        border-color: #1a1a1a;
        color: #888;
    }

    .mobile-habit-submit:hover {
        background: #555;
    }
}

button:active {
    transform: scale(0.97);
}

@media (display-mode: standalone) {
    .progression-bar {
        padding-top: calc(1.25rem + env(safe-area-inset-top, 0px));
    }
    .settings-icon {
        top: calc(1.25rem + env(safe-area-inset-top, 0px));
    }
    .add-button {
        bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }
}
