:root {
    --bg: #e9e8e6;
    --text: #111;
    --muted: #9a9a9a;
    --card: #ffffff;
    --border: #d8d7d4;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    --radius: 4px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Times New Roman", Times, serif;
    font-size: 17px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
    overflow-x: hidden;
    max-width: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

img,
video {
    max-width: 100%;
    display: block;
}

video {
    pointer-events: none;
}

video::-webkit-media-controls,
video::-webkit-media-controls-enclosure,
video::-webkit-media-controls-panel,
video::-webkit-media-controls-play-button,
video::-webkit-media-controls-start-playback-button,
video::-webkit-media-controls-overlay-play-button,
video::-webkit-media-controls-fullscreen-button {
    display: none !important;
    -webkit-appearance: none;
    opacity: 0;
    pointer-events: none;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ---------- Landing page ---------- */
.page-landing main {
    justify-content: flex-start;
    padding-top: 18vh;
    text-align: center;
    gap: 18px;
}

.landing-leaf {
    width: 110px;
    height: 110px;
    margin-bottom: 28px;
    opacity: 0.18;
}

.landing-leaf img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.landing-copy {
    max-width: 360px;
    margin: 0;
    font-size: 19px;
}

.btn {
    display: inline-block;
    margin-top: 28px;
    padding: 7px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow);
    font-family: inherit;
    color: inherit;
}

.page-landing footer {
    padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
    text-align: center;
    color: var(--muted);
    font-size: 15px;
}

.page-landing footer p {
    margin: 2px 0;
}

.page-landing footer a {
    text-decoration: underline;
}

/* ---------- Top nav (back buttons) ---------- */
.top-nav {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top));
    left: 16px;
    z-index: 10;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--card);
    border-radius: var(--radius);
    font-size: 16px;
    box-shadow: var(--shadow);
    font-family: inherit;
}

.pill .arrow {
    font-size: 18px;
    line-height: 1;
}

/* ---------- Leaves grid ---------- */
.page-leaves main {
    justify-content: flex-start;
    padding-top: calc(96px + env(safe-area-inset-top));
    padding-bottom: 40px;
}

.leaf-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 16px;
    width: 100%;
    max-width: 520px;
}

.leaf-cell {
    aspect-ratio: 1 / 1;
    border: none;
    background: transparent;
    padding: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0;
    overflow: hidden;
}

.leaf-cell .leaf-shape {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

/* ---------- Camera ---------- */
.page-camera {
    background: var(--bg);
}

.page-camera main {
    padding: 0;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
}

.camera-stage {
    position: relative;
    width: 100%;
    max-width: 720px;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    margin: 0 auto;
    touch-action: pan-y;
}

.camera-stage video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: 82%;
    mask-size: 82%;
}

.camera-error {
    position: absolute;
    bottom: 40%;
    color: var(--muted);
    font-size: 15px;
    text-align: center;
    padding: 0 24px;
}

.camera-controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 20px 24px calc(32px + env(safe-area-inset-bottom));
    position: relative;
}

.camera-controls .shutter {
    grid-column: 2;
    justify-self: center;
}

.camera-controls .flip-btn {
    grid-column: 3;
    justify-self: center;
}

.shutter {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #fff;
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 4px;
    box-shadow: var(--shadow);
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s ease;
}

.shutter:active {
    transform: scale(0.94);
}

.leaf-preview {
    width: 60px;
    height: 60px;
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.leaf-preview::before {
    content: "";
    width: 38px;
    height: 38px;
    background: #111;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

.flip-btn {
    width: 60px;
    height: 60px;
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #111;
    font-family: inherit;
}

.flip-leaf {
    width: 38px;
    height: 38px;
    background: currentColor;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    transition: transform 0.2s ease;
}

.flip-btn.active .flip-leaf {
    transform: scaleX(-1);
}

.camera-stage video {
    transition: transform 0.2s ease;
}

/* ---------- Share ---------- */
.page-share main {
    justify-content: center;
    padding: calc(96px + env(safe-area-inset-top)) 20px 20px;
}

.share-card {
    width: 100%;
    max-width: 520px;
    aspect-ratio: 1 / 1;
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.share-card img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.share-footer {
    display: flex;
    justify-content: center;
    padding: 20px 24px calc(48px + env(safe-area-inset-bottom));
}

.btn-share {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 7px 18px;
    background: var(--card);
    border: none;
    border-radius: var(--radius);
    font-size: 18px;
    font-family: inherit;
    color: inherit;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.btn-share .arrow {
    font-size: 20px;
}
