:root {
    --bg: #f5f5f7;
    --panel: rgba(255, 255, 255, 0.86);
    --panel-solid: #ffffff;
    --ink: #171717;
    --muted: #737373;
    --line: rgba(0, 0, 0, 0.1);
    --accent: #007aff;
    --accent-dark: #005ecb;
    --danger: #d92d20;
    --success: #16803c;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: AvenirNextLTPro-Regular, Avenir Next, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.45;
}

body.is-modal-open {
    overflow: hidden;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

.app-shell {
    width: min(1160px, 100%);
    margin: 0 auto;
    padding: 22px 14px 116px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin: -22px -14px 10px;
    padding: 22px 18px 12px;
    background: rgba(245, 245, 247, 0.86);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.eyebrow {
    margin: 0 0 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(34px, 7vw, 54px);
    line-height: 1;
}

h2 {
    font-size: 27px;
    line-height: 1.12;
}

.app-header__count {
    display: inline-flex;
    min-width: 58px;
    height: 36px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--accent);
    font-weight: 800;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.08);
}

.app-header__tools {
    display: flex;
    align-items: end;
    gap: 8px;
    margin-left: auto;
}

.sort-form {
    display: grid;
    position: relative;
}

.sort-dropdown {
    position: relative;
}

.sort-dropdown__button {
    display: inline-flex;
    width: min(174px, 58vw);
    min-height: 36px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
    padding: 0 12px;
    font-size: 13px;
    font-weight: 800;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.08);
}

.sort-dropdown__button .fa-sort {
    color: var(--accent);
}

.sort-dropdown__button .fa-chevron-down {
    color: var(--muted);
    font-size: 11px;
    transition: transform 0.18s ease;
}

.sort-dropdown.is-open .sort-dropdown__button .fa-chevron-down {
    transform: rotate(180deg);
}

.sort-dropdown__button span {
    overflow: hidden;
    min-width: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sort-dropdown__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 25;
    display: none;
    width: 230px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7)),
        rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 18px 44px rgba(0, 0, 0, 0.18);
}

.sort-dropdown.is-open .sort-dropdown__menu {
    display: grid;
}

.sort-dropdown__option {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    min-height: 46px;
    background: transparent;
    color: var(--ink);
    padding: 0 14px;
    text-align: left;
    font-size: 13px;
    font-weight: 800;
}

.sort-dropdown__option + .sort-dropdown__option {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.sort-dropdown__option .far {
    color: var(--muted);
}

.sort-dropdown__option.is-active,
.sort-dropdown__option:hover,
.sort-dropdown__option:focus-visible {
    background: rgba(0, 122, 255, 0.1);
    color: var(--accent);
}

.sort-dropdown__option.is-active .far,
.sort-dropdown__option:hover .far,
.sort-dropdown__option:focus-visible .far {
    color: var(--accent);
}

.notice {
    margin: 16px 4px;
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff1ef;
    color: var(--danger);
    font-weight: 700;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 3px;
}

.photo-card {
    position: relative;
    overflow: hidden;
    min-width: 0;
    background: #e7e7ea;
}

.photo-card a {
    display: block;
    aspect-ratio: 1;
}

.photo-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-card__delete {
    position: absolute;
    top: 7px;
    right: 7px;
    z-index: 2;
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    background: rgba(20, 20, 22, 0.48);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    opacity: 0.95;
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.photo-card__delete:hover,
.photo-card__delete:focus-visible {
    background: var(--danger);
}

.photo-card__meta {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    min-height: 32px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 8px 6px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.58), rgba(0, 0, 0, 0));
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
}

.photo-card__meta span {
    overflow: hidden;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-card__meta time {
    display: none;
}

.empty-state {
    display: grid;
    min-height: 50vh;
    place-items: center;
    margin: 0;
    color: var(--muted);
    text-align: center;
}

.is-hidden {
    display: none !important;
}

.dock {
    position: fixed;
    right: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 20;
    display: grid;
    width: min(430px, calc(100% - 28px));
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 8px;
    transform: translateX(50%);
    border: 1px solid rgba(255, 255, 255, 0.66);
    border-radius: 30px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.28)),
        rgba(255, 255, 255, 0.46);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.84),
        inset 0 -1px 0 rgba(255, 255, 255, 0.22),
        0 18px 52px rgba(0, 0, 0, 0.23);
}

.dock::before {
    content: "";
    position: absolute;
    inset: 1px;
    z-index: 0;
    border-radius: inherit;
    background: radial-gradient(circle at 50% 0, rgba(255, 255, 255, 0.9), transparent 48%);
    opacity: 0.8;
    pointer-events: none;
}

.dock__item {
    position: relative;
    z-index: 1;
    display: grid;
    min-height: 58px;
    place-items: center;
    gap: 3px;
    border-radius: 22px;
    background: transparent;
    color: rgba(23, 23, 23, 0.62);
    font-size: 12px;
    font-weight: 800;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.dock__item--primary {
    min-height: 66px;
    margin-top: -16px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background:
        linear-gradient(180deg, rgba(88, 166, 255, 0.96), rgba(0, 122, 255, 0.96)),
        var(--accent);
    color: #fff;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.42),
        0 12px 30px rgba(0, 122, 255, 0.42);
}

.dock__item:hover,
.dock__item:focus-visible {
    background: rgba(255, 255, 255, 0.42);
    color: var(--accent);
    transform: translateY(-1px);
}

.dock__item--primary:hover,
.dock__item--primary:focus-visible {
    background: var(--accent-dark);
    color: #fff;
}

.dock__icon {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.42);
    font-size: 16px;
    line-height: 1;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.dock__item--primary .dock__icon {
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.24);
    font-size: 19px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(20, 20, 22, 0.24);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.modal-backdrop.is-visible {
    display: flex;
}

.modal {
    position: relative;
    width: min(430px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78)),
        var(--panel);
    padding: 24px;
    backdrop-filter: blur(26px) saturate(180%);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
    box-shadow: var(--shadow);
}

.modal--wide {
    width: min(560px, 100%);
}

.modal--welcome {
    padding-top: 34px;
}

.modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.62);
    color: var(--muted);
    font-weight: 800;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.modal__close:hover,
.modal__close:focus-visible {
    background: rgba(0, 0, 0, 0.12);
    color: var(--ink);
}

.modal__copy {
    margin: 14px 0 22px;
    color: var(--muted);
}

.stack-form {
    display: grid;
    gap: 10px;
    margin: 18px 0 0;
}

label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

input[type="text"] {
    width: 100%;
    min-height: 50px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--ink);
    padding: 0 15px;
}

.stack-form button,
.button-secondary {
    min-height: 50px;
    border-radius: 16px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.stack-form button:hover,
.stack-form button:focus-visible {
    background: var(--accent-dark);
}

.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 16px;
    background: rgba(217, 45, 32, 0.1);
    color: var(--danger);
}

.button-secondary:hover,
.button-secondary:focus-visible {
    background: rgba(217, 45, 32, 0.16);
}

.button-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    border-radius: 16px;
    background: var(--danger);
    color: #fff;
    font-weight: 800;
}

.button-danger:hover,
.button-danger:focus-visible {
    background: #b42318;
}

.modal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.modal-actions .button-secondary {
    margin-top: 0;
}

.form-message {
    min-height: 20px;
    margin: 0;
    color: var(--danger);
    font-size: 13px;
    font-weight: 700;
}

.form-message.is-success {
    color: var(--success);
}

.upload-panel {
    margin-top: 18px;
}

.file-picker {
    position: relative;
    display: grid;
    min-height: 92px;
    place-items: center;
    gap: 8px;
    border: 1px dashed rgba(0, 122, 255, 0.42);
    border-radius: 20px;
    background: rgba(0, 122, 255, 0.08);
    color: var(--accent);
    font-size: 16px;
}

.file-picker .far {
    font-size: 28px;
}

.file-picker input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.upload-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.upload-item {
    display: grid;
    min-width: 0;
    gap: 7px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    padding: 12px;
}

.upload-item__top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
}

.upload-item__name {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    font-size: 14px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-item__status {
    min-width: 54px;
    text-align: right;
    white-space: nowrap;
}

.progress {
    overflow: hidden;
    height: 7px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
}

.progress__bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.16s ease;
}

.upload-item.is-complete .progress__bar {
    background: var(--success);
}

.upload-item.is-error .progress__bar {
    background: var(--danger);
}

@media (min-width: 860px) {
    .app-shell {
        padding-right: 24px;
        padding-left: 24px;
    }

    .app-header {
        margin-right: -24px;
        margin-left: -24px;
        padding-right: 28px;
        padding-left: 28px;
    }

    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 5px;
    }
}

@media (min-width: 1240px) {
    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

@media (max-width: 760px) {
    .app-shell {
        padding-bottom: 126px;
    }

    .modal-backdrop {
        align-items: flex-end;
        justify-content: stretch;
        padding: 0;
    }

    .modal {
        width: 100%;
        max-height: min(82vh, 760px);
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 28px 28px 0 0;
        padding: 32px 20px max(22px, env(safe-area-inset-bottom));
        box-shadow: 0 -18px 58px rgba(0, 0, 0, 0.24);
    }

    .modal::before {
        content: "";
        position: absolute;
        top: 10px;
        left: 50%;
        width: 44px;
        height: 5px;
        transform: translateX(-50%);
        border-radius: 999px;
        background: rgba(0, 0, 0, 0.18);
    }

    .modal--wide,
    .modal--welcome {
        width: 100%;
    }

    .modal__close {
        top: 16px;
        right: 16px;
    }

    .dock {
        width: min(390px, calc(100% - 20px));
        bottom: max(10px, env(safe-area-inset-bottom));
        border-radius: 28px;
    }

    .dock__item {
        min-height: 54px;
    }

    .dock__item--primary {
        min-height: 64px;
    }
}
