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

:root {
    --ink: #050505;
    --ink-soft: #111111;
    --panel: #161616;
    --line: rgba(255, 255, 255, 0.12);
    --cream: #f3f3f3;
    --cream-dim: #9a9a9a;
    --gold: #d4d4d4;
    --gold-soft: #8a8a8a;
}

html, body {
    background: var(--ink);
    color: var(--cream);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
}

.container {
    max-width: 1680px;
    margin: 0 auto;
    padding: 0 32px;
}

header {
    border-bottom: 1px solid var(--line);
    background: rgba(5, 5, 5, 0.92);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 20;
    padding-top: env(safe-area-inset-top);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 76px;
}

header .container > a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--cream);
}

header .container > a img {
    height: 36px;
}

nav a {
    color: var(--cream-dim);
    text-decoration: none;
    margin-left: 28px;
    font-size: 0.72em;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

nav a:hover {
    color: var(--gold);
}

.hero {
    padding: 40px 0 32px;
    margin-bottom: 44px;
    border-bottom: 1px solid var(--line);
}

.hero-top {
    display: grid;
    grid-template-columns: minmax(280px, 1.1fr) minmax(240px, 0.7fr);
    gap: 16px 48px;
    align-items: end;
}

.hero-kicker {
    color: var(--gold);
    font-size: 0.72em;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.hero h1 {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(2.4rem, 5vw, 4rem);
    line-height: 0.88;
    letter-spacing: 0.04em;
}

.hero-lead {
    margin: 0 0 6px;
    color: var(--cream);
    font-size: 1.05rem;
    font-weight: 300;
    letter-spacing: 0.01em;
}

.hero-story {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px 32px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.hero-story p {
    margin: 0;
    color: var(--cream-dim);
    font-size: 0.92rem;
    line-height: 1.65;
}

.hero-aside {
    margin-top: 18px;
    padding-bottom: 8px;
    color: var(--gold);
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

@media (max-width: 1100px) {
    .hero-top,
    .hero-story {
        grid-template-columns: 1fr 1fr;
    }

    .hero-story p:last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 720px) {
    .hero-top,
    .hero-story {
        grid-template-columns: 1fr;
    }
}

.back-link {
    background: transparent;
    color: var(--cream);
    border: 1px solid var(--line);
    padding: 10px 16px;
    font-size: 0.68em;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.back-link:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.gallery-empty {
    color: var(--cream-dim);
    padding: 80px 0;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2rem;
    letter-spacing: 0.06em;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 56px 36px;
    padding-bottom: 80px;
}

.stone-card {
    background: transparent;
    cursor: pointer;
    text-align: left;
    border: 0;
    color: inherit;
    width: 100%;
    padding: 0;
}

.stone-card .card-image-wrapper,
.collection-card .card-image-wrapper,
.stone-card .card-image-wrapper.is-cropped,
.collection-card .card-image-wrapper.is-cropped {
    --box-h: 420px;
    width: 100%;
    height: auto;
    min-height: 240px;
    margin-bottom: 18px;
    background: transparent;
}

.stone-card .card-crop-fit,
.collection-card .card-crop-fit {
    width: 100%;
    max-width: 100%;
    max-height: none;
}

@media (hover: hover) and (pointer: fine) {
    .stone-card:hover .card-crop-fit,
    .collection-card:hover .card-crop-fit {
        transform: scale(1.03);
    }
}

.stone-card,
.collection-card,
.back-link,
.lightbox-close,
.measure-label {
    -webkit-tap-highlight-color: transparent;
}

.stone-card h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    line-height: 1;
}

.stone-meta {
    margin-top: 6px;
    color: var(--cream-dim);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stone-note {
    margin-top: 10px;
    color: var(--gold);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.collection-view {
    padding-bottom: 80px;
}

.collection-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin: 36px 0 32px;
}

.collection-heading h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2.4rem, 6vw, 4rem);
    font-weight: 400;
    letter-spacing: 0.05em;
    line-height: 0.9;
}

.collection-heading p {
    margin-top: 10px;
    color: var(--cream-dim);
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 56px 36px;
}

.collection-card {
    background: transparent;
    border: 0;
    color: inherit;
    text-align: left;
    padding: 0;
    cursor: pointer;
    width: 100%;
}

.collection-card h3 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.55rem;
    font-weight: 400;
    letter-spacing: 0.05em;
}

[hidden] {
    display: none !important;
}

.card-image-wrapper {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    overflow: hidden;
    position: relative;
}

.card-image-wrapper.is-cropped {
    --box-h: 160px;
    height: var(--box-h);
    width: 100%;
    background: transparent;
}

.card-crop-fit {
    position: relative;
    aspect-ratio: var(--piece-ar, 1);
    width: min(100%, calc(var(--piece-ar, 1) * var(--box-h, 160px)));
    height: auto;
    max-width: 100%;
    max-height: 100%;
    isolation: isolate;
    overflow: hidden;
    transition: transform 0.5s ease;
}

.card-image-clip {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: transparent;
}

.card-image-wrapper .card-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.card-image-wrapper.is-cropped .card-image {
    position: absolute;
    max-width: none;
    max-height: none;
    object-fit: fill;
    object-position: top left;
}

.card-image-wrapper.is-cropped .card-image.is-calibrated {
    inset: auto;
}

.card-image-wrapper.is-cropped .card-image.is-bbox-fill {
    inset: 0;
    width: 100%;
    height: 100%;
}

.card-image-wrapper svg.card-poly {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.card-image-wrapper svg.card-poly polygon {
    fill: rgba(196, 165, 114, 0.08);
    stroke: var(--gold);
    stroke-width: 1.2;
    vector-effect: non-scaling-stroke;
}

.card-image-wrapper .no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cream-dim);
}

.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(8, 7, 6, 0.96);
    overflow: hidden;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overscroll-behavior: none;
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 30px;
    color: var(--cream);
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    z-index: 10000;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    display: block;
    margin: 0 auto;
    padding: 48px 16px 16px;
    max-width: 96vw;
    max-height: 86vh;
    height: auto;
    object-fit: contain;
    cursor: default;
    pointer-events: none;
}

.lightbox-crop {
    display: none;
    width: min(96vw, 2200px);
    margin: 56px auto 16px;
    padding: 52px 64px 40px;
    box-sizing: border-box;
    overflow: visible;
    pointer-events: auto;
}

.lightbox-crop.is-open {
    display: block;
}

.lightbox-crop .card-image-wrapper,
.lightbox-crop .card-image-wrapper.is-cropped,
.lightbox-crop .card-image-wrapper.is-rect,
.lightbox-crop .card-image-wrapper.is-measuring {
    --box-h: min(72vh, 880px);
    width: 100%;
    height: var(--box-h);
    max-height: var(--box-h);
    margin: 0;
    background: transparent;
    overflow: visible;
}

.lightbox-crop .card-image.is-rect {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.is-gallery svg.card-poly {
    display: none;
}

.lightbox-crop,
.lightbox-crop .card-image-wrapper,
.lightbox-crop .card-image-wrapper.is-measuring,
.lightbox-crop .card-crop-fit.is-measuring {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.lightbox-crop .card-image-wrapper.is-measuring {
    cursor: default;
    overflow: visible;
}

.lightbox-crop .card-crop-fit.is-measuring {
    cursor: none;
}

.lightbox-crop .card-crop-fit,
.lightbox-crop .card-crop-fit.is-measuring {
    overflow: visible;
    isolation: auto;
    transition: none;
    transform-origin: center center;
}

.lightbox-crop .card-image-wrapper.is-zoomed {
    overflow: hidden;
}

.lightbox-crop .card-image-clip {
    overflow: hidden;
    isolation: isolate;
}

.lightbox-crop .measure-overlay,
.lightbox-crop .measure-labels,
.lightbox-crop .measure-svg {
    overflow: visible;
}

.lightbox-crop .card-crop-fit.is-measuring.is-over-measure {
    cursor: pointer;
}

.lightbox-crop .card-crop-fit.is-measuring.is-over-measure .measure-cursor {
    display: none;
}

.measure-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
}

.measure-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.measure-line {
    stroke: #ffe14a;
    stroke-width: 2.8;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.85));
}

.measure-line.is-auto {
    stroke: #ffe14a;
}

.measure-line.is-pending {
    stroke: var(--gold);
    stroke-dasharray: 6 5;
}

.measure-dot {
    fill: #f8fafc;
    stroke: #0f172a;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.measure-dot.is-pending {
    fill: var(--gold);
}

.measure-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.measure-label {
    position: absolute;
    transform: translate(-50%, -50%);
    border: 0;
    background: #ffe14a;
    color: #111;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    padding: 5px 8px;
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.55);
    pointer-events: auto;
    cursor: pointer;
    white-space: nowrap;
    z-index: 5;
}

.measure-label.is-auto {
    background: #ffe14a;
    color: #111;
}

.measure-label:hover {
    background: #fff;
    color: #b91c1c;
}

.measure-label.is-pending {
    background: #fff3a1;
    color: #111;
    pointer-events: none;
    cursor: default;
}

.measure-cursor {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 6;
}

.measure-cursor-cross {
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%);
}

.measure-cursor-cross::before,
.measure-cursor-cross::after {
    content: '';
    position: absolute;
    background: #f8fafc;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.55);
}

.measure-cursor-cross::before {
    left: 13px;
    top: 0;
    width: 2px;
    height: 28px;
}

.measure-cursor-cross::after {
    top: 13px;
    left: 0;
    width: 28px;
    height: 2px;
}

.measure-cursor-badge {
    position: absolute;
    left: 0;
    top: 18px;
    transform: translate(-50%, 0);
    background: var(--gold-soft);
    color: #111;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 999px;
    white-space: nowrap;
}

.lightbox-measure-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--cream);
    font-size: 14px;
    font-weight: 400;
    margin: 0 auto 24px;
    padding: 8px 14px;
    background: rgba(17, 16, 14, 0.82);
    border: 1px solid var(--line);
    width: fit-content;
    max-width: 90vw;
}

.lightbox-measure-icon {
    display: inline-flex;
    color: var(--gold);
}

@media (max-width: 1100px) {
    .gallery-grid,
    .collection-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 40px 24px;
    }
}

@media (max-width: 720px) {
    .container {
        padding: 0 16px;
    }

    header .container {
        min-height: 58px;
    }

    header .container > a img {
        height: 30px;
    }

    nav a {
        margin-left: 16px;
        font-size: 0.68em;
    }

    .hero {
        padding: 28px 0 24px;
        margin-bottom: 28px;
    }

    .hero-aside {
        letter-spacing: 0.08em;
        line-height: 1.5;
    }

    .gallery-grid,
    .collection-grid {
        grid-template-columns: 1fr;
        gap: 36px;
        padding-bottom: 48px;
    }

    .stone-card .card-image-wrapper,
    .collection-card .card-image-wrapper,
    .stone-card .card-image-wrapper.is-cropped,
    .collection-card .card-image-wrapper.is-cropped {
        --box-h: 280px;
        min-height: 180px;
    }

    .stone-card h2 {
        font-size: 1.7rem;
    }

    .back-link {
        min-height: 44px;
        padding: 12px 16px;
    }

    .collection-toolbar {
        margin: 20px 0 20px;
    }

    .lightbox-close {
        top: calc(10px + env(safe-area-inset-top));
        right: max(12px, env(safe-area-inset-right));
        width: 48px;
        height: 48px;
        font-size: 36px;
        background: rgba(0, 0, 0, 0.45);
        border-radius: 50%;
    }

    .lightbox-crop {
        width: 100%;
        margin: calc(8px + env(safe-area-inset-top)) auto 8px;
        padding: 44px 10px 72px;
    }

    .lightbox-crop .card-image-wrapper,
    .lightbox-crop .card-image-wrapper.is-cropped,
    .lightbox-crop .card-image-wrapper.is-rect,
    .lightbox-crop .card-image-wrapper.is-measuring {
        --box-h: min(58dvh, 520px);
        max-height: var(--box-h);
    }

    .lightbox-measure-hint {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        margin: 0;
        max-width: none;
        width: auto;
        font-size: 13px;
        padding: 10px 12px;
        text-align: center;
    }

    .measure-label {
        font-size: 13px;
        padding: 6px 9px;
        min-height: 28px;
    }
}

@media (max-width: 720px) and (orientation: landscape) {
    .lightbox-crop .card-image-wrapper,
    .lightbox-crop .card-image-wrapper.is-cropped,
    .lightbox-crop .card-image-wrapper.is-rect,
    .lightbox-crop .card-image-wrapper.is-measuring {
        --box-h: min(78dvh, 640px);
    }

    .lightbox-crop {
        padding: 36px 48px 16px;
    }

    .lightbox-measure-hint {
        left: auto;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        max-width: 46vw;
    }
}
