/* ═══════════════════════════════════════════════════════════
   LH GOLD — Design System
   Aesthetic: Dark luxury terminal · editorial gold trading
   ═══════════════════════════════════════════════════════════ */

:root {
    /* ── Burgundy surface scale (HSL ~350-354°, warm crimson) ── */
    --surface-950: #1c0510;
    --surface-900: #340a1c;
    --surface-850: #4a1024;
    --surface-800: #62162c;
    --surface-700: #7e212b;
    --surface-600: #962c38;
    --surface-500: #ad3a42;
    --surface-400: #c45460;
    /* ── Gold accent scale (HSL ~45°, bright warm) ── */
    --gold-700: #a68b12;
    --gold-600: #c4a52a;
    --gold-500: #edc751;
    --gold-400: #f2d470;
    --gold-300: #f6e08e;
    --gold-200: #faeaaf;
    --gold-100: #fdf5d8;
    /* ── Text on dark burgundy ── */
    --text-primary: #faf3ee;
    --text-secondary: #d4aca8;
    --text-muted: #9e6e6b;
    /* ── Semantic accents ── */
    --accent-success: #34d399;
    --accent-error: #f87171;
    --accent-warning: #fbbf24;
    /* ── Glass / overlay ── */
    --glass-border: rgba(242, 212, 112, 0.18);
    --glass-border-subtle: rgba(242, 212, 112, 0.08);
    --glass-bg: rgba(52, 10, 28, 0.7);
    --glass-bg-strong: rgba(52, 10, 28, 0.85);
    /* ── Shadows with warm undertone ── */
    --shadow-elevation-1: 0 1px 3px rgba(20,8,16,0.5), 0 4px 14px rgba(20,8,16,0.3);
    --shadow-elevation-2: 0 4px 10px rgba(20,8,16,0.5), 0 14px 44px rgba(20,8,16,0.35);
    --shadow-elevation-3: 0 8px 20px rgba(20,8,16,0.5), 0 28px 72px rgba(20,8,16,0.4);
    --shadow-gold-glow: 0 0 30px rgba(237, 199, 81, 0.12), 0 0 60px rgba(237, 199, 81, 0.06), 0 0 100px rgba(237, 199, 81, 0.03);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --font-display: "Playfair Display", "Noto Sans Thai", serif;
    --font-body: "DM Sans", "Noto Sans Thai", sans-serif;
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100vh;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text-primary);
    background: var(--surface-950);
    background-image:
        radial-gradient(ellipse 90% 50% at 50% -10%, rgba(126, 33, 43, 0.5), transparent 70%),
        radial-gradient(ellipse 70% 60% at 85% 100%, rgba(237, 199, 81, 0.08), transparent 60%),
        radial-gradient(ellipse 60% 50% at 10% 60%, rgba(98, 22, 44, 0.4), transparent 60%),
        linear-gradient(170deg, var(--surface-950) 0%, #280912 40%, var(--surface-900) 70%, var(--surface-950) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    opacity: 1;
    z-index: 0;
}

body::after {
    content: "";
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    background: conic-gradient(from 180deg at 50% 50%, transparent 0deg, rgba(126, 33, 43, 0.06) 45deg, transparent 90deg, rgba(237, 199, 81, 0.025) 200deg, rgba(126, 33, 43, 0.04) 300deg, transparent 360deg);
    animation: slow-rotate 90s linear infinite;
    z-index: 0;
}

@keyframes slow-rotate {
    to { transform: rotate(360deg); }
}

/* ── Page Shell ─────────────────────────────────────────── */

.page-shell {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* ── Hero ────────────────────────────────────────────────── */

.hero {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 32px;
    padding: 36px;
    border-radius: var(--radius-xl);
    background:
        linear-gradient(145deg, rgba(98, 22, 44, 0.6) 0%, rgba(52, 10, 28, 0.85) 50%, rgba(74, 16, 36, 0.7) 100%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-elevation-2), var(--shadow-gold-glow);
    backdrop-filter: blur(24px) saturate(1.4);
    position: relative;
    overflow: hidden;
    animation: fadeUp 0.6s var(--ease-out-expo) both;
}

.hero::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 5%, var(--gold-400) 35%, var(--gold-300) 50%, var(--gold-400) 65%, transparent 95%);
    opacity: 0.6;
}

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

.hero-brand {
    display: flex;
    gap: 20px;
    align-items: center;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    background: none;
    padding: 0;
    border-radius: 0;
}

.hero-brand-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.brand-logo {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: 2px solid rgba(242, 212, 112, 0.35);
    box-shadow: 0 4px 20px rgba(20, 8, 16, 0.5), 0 0 0 1px rgba(242, 212, 112, 0.1);
    flex-shrink: 0;
}

.brand-kicker,
.eyebrow {
    font-family: var(--font-body);
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold-500);
    font-weight: 700;
}

.hero-brand h1 {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3.5vw, 2.8rem);
    font-weight: 700;
    line-height: 1.15;
    color: var(--text-primary);
    margin: 0;
}

.hero-copy {
    max-width: 54ch;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.hero-highlight {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(126, 33, 43, 0.35) 0%, rgba(98, 22, 44, 0.2) 50%, rgba(237, 199, 81, 0.08) 100%);
    border: 1px solid rgba(242, 212, 112, 0.15);
    position: relative;
    overflow: visible;
    box-shadow: inset 0 1px 0 rgba(242, 212, 112, 0.08), var(--shadow-elevation-1);
    backdrop-filter: none;
    color: var(--text-primary);
}

.hero-highlight::after {
    display: none;
}

.hero-highlight-inner {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.hero-highlight-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.hero-highlight-value {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 700;
    line-height: 1;
    color: var(--gold-400);
    margin: 0;
}

.hero-highlight-copy {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
    margin: 0;
}

/* ── App Grid ────────────────────────────────────────────── */

.app-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ── Cards (shared) ──────────────────────────────────────── */

.calculator-card,
.results-panel {
    border-radius: var(--radius-xl);
    padding: 32px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px) saturate(1.3);
    box-shadow: var(--shadow-elevation-2);
    animation: fadeUp 0.6s var(--ease-out-expo) both;
}

.calculator-card {
    background:
        linear-gradient(160deg, rgba(98, 22, 44, 0.5) 0%, rgba(52, 10, 28, 0.88) 40%, rgba(74, 16, 36, 0.6) 100%);
    animation-delay: 0.08s;
}

.results-panel {
    background:
        linear-gradient(200deg, rgba(74, 16, 36, 0.6) 0%, rgba(52, 10, 28, 0.88) 50%, rgba(98, 22, 44, 0.5) 100%);
    animation-delay: 0.16s;
}

.card-heading h2 {
    font-family: var(--font-display);
    margin-top: 10px;
    font-size: clamp(1.4rem, 2vw, 1.9rem);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

/* ── Material Preview Image ─────────────────────────────── */

.material-preview {
    margin-top: 20px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    height: 140px;
    position: relative;
    border: 1px solid rgba(173, 58, 66, 0.2);
    box-shadow: var(--shadow-elevation-1);
}

.material-preview::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(20, 8, 16, 0.1) 0%, rgba(20, 8, 16, 0.5) 100%);
    pointer-events: none;
}

.material-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 40%;
    display: block;
    transition: opacity 0.4s var(--ease-out-expo), transform 0.6s var(--ease-out-expo);
}

.material-preview-img.is-swapping {
    opacity: 0;
    transform: scale(1.04);
}

/* ── Calculator Form ─────────────────────────────────────── */

.calculator-form {
    margin-top: 28px;
}

.gold-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-row {
    display: flex;
    gap: 16px;
    margin-top: 16px;
}

.field-row .field:first-child {
    flex: 1;
}

.unit-field {
    width: 160px;
}

.field-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.field-input {
    width: 100%;
    border: 1px solid rgba(173, 58, 66, 0.25);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    background: var(--surface-800);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.95rem;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
    transition:
        border-color 0.25s var(--ease-out-expo),
        box-shadow 0.25s var(--ease-out-expo),
        background 0.25s var(--ease-out-expo);
    -webkit-appearance: none;
    appearance: none;
}

select.field-input {
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23d4aca8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    cursor: pointer;
}

.field-input::placeholder {
    color: var(--text-muted);
}

.field-input:hover {
    border-color: rgba(196, 84, 96, 0.35);
    background: var(--surface-700);
}

.field-input:focus {
    outline: none;
    border-color: var(--gold-500);
    box-shadow: 0 0 0 3px rgba(237, 199, 81, 0.18), 0 0 16px rgba(237, 199, 81, 0.06), inset 0 1px 2px rgba(0,0,0,0.2);
    background: var(--surface-700);
}

/* ── Buttons ─────────────────────────────────────────────── */

.action-row {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.primary-button,
.secondary-button {
    border: none;
    border-radius: var(--radius-sm);
    padding: 15px 24px;
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition:
        transform 0.3s var(--ease-spring),
        box-shadow 0.3s var(--ease-out-expo),
        background 0.2s ease;
    position: relative;
    overflow: hidden;
}

.primary-button::before,
.secondary-button::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
}

.primary-button:hover::before,
.secondary-button:hover::before {
    opacity: 1;
}

.primary-button {
    flex: 1;
    color: var(--surface-950);
    background: linear-gradient(135deg, var(--gold-300) 0%, var(--gold-400) 40%, var(--gold-600) 100%);
    box-shadow: 0 4px 18px rgba(237, 199, 81, 0.3), 0 1px 3px rgba(237, 199, 81, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    letter-spacing: 0.02em;
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(237, 199, 81, 0.4), 0 2px 8px rgba(237, 199, 81, 0.45), 0 0 60px rgba(237, 199, 81, 0.1);
}

.primary-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(237, 199, 81, 0.2);
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.secondary-button {
    min-width: 150px;
    color: var(--gold-400);
    background: rgba(237, 199, 81, 0.08);
    border: 1px solid rgba(237, 199, 81, 0.18);
    box-shadow: var(--shadow-elevation-1);
}

.secondary-button:hover {
    transform: translateY(-2px);
    background: rgba(237, 199, 81, 0.14);
    border-color: rgba(237, 199, 81, 0.28);
    box-shadow: var(--shadow-elevation-2), 0 0 20px rgba(237, 199, 81, 0.06);
}

.refresh-chip {
    border: 1px solid rgba(237, 199, 81, 0.18);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    background: rgba(237, 199, 81, 0.08);
    color: var(--gold-400);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition:
        transform 0.3s var(--ease-spring),
        background 0.2s ease,
        box-shadow 0.3s var(--ease-out-expo);
}

.refresh-chip:hover {
    transform: translateY(-1px);
    background: rgba(237, 199, 81, 0.14);
    box-shadow: 0 4px 16px rgba(237, 199, 81, 0.12);
}

.refresh-chip svg {
    flex-shrink: 0;
}

/* ── Status Banner ───────────────────────────────────────── */

.status-banner {
    margin-top: 24px;
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.35s var(--ease-out-expo);
}

.status-loading {
    background: rgba(251, 191, 36, 0.08);
    border-color: rgba(251, 191, 36, 0.15);
    color: var(--accent-warning);
}

.status-success {
    background: rgba(52, 211, 153, 0.08);
    border-color: rgba(52, 211, 153, 0.15);
    color: var(--accent-success);
}

.status-error {
    background: rgba(248, 113, 113, 0.08);
    border-color: rgba(248, 113, 113, 0.15);
    color: var(--accent-error);
}

/* ── Results Panel ───────────────────────────────────────── */

.results-topline {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.timestamp-pill {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    text-align: right;
    background: rgba(74, 16, 36, 0.3);
    border: 1px solid rgba(173, 58, 66, 0.14);
}

.timestamp-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.last-updated {
    margin-top: 4px;
    text-align: right;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.45;
}

.value-frame {
    margin-top: 24px;
    padding: 24px;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(ellipse 80% 60% at 10% 10%, rgba(237, 199, 81, 0.12), transparent 50%),
        radial-gradient(ellipse 60% 80% at 90% 90%, rgba(126, 33, 43, 0.2), transparent 50%),
        linear-gradient(160deg, var(--surface-700) 0%, var(--surface-800) 100%);
    border: 1px solid rgba(242, 212, 112, 0.18);
    box-shadow: var(--shadow-elevation-2), inset 0 1px 0 rgba(242, 212, 112, 0.1);
    position: relative;
}

.value-frame::before {
    content: "";
    position: absolute;
    top: 0;
    left: 24px;
    right: 24px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(237, 199, 81, 0.2), transparent);
}

.value-frame-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.value-label,
.summary-label,
.total-label,
.notes-title {
    font-family: var(--font-body);
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.value-number {
    margin-top: 12px;
    font-family: var(--font-body);
    font-size: clamp(2.2rem, 5vw, 3.8rem);
    line-height: 1;
    font-weight: 700;
    color: var(--gold-300);
    letter-spacing: -0.02em;
}

.value-placeholder {
    font-family: var(--font-body);
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    line-height: 1.3;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0;
}

.result-hint {
    margin-top: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 0.85rem;
}

/* ── Summary Cards ───────────────────────────────────────── */

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.summary-card {
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, var(--surface-700), var(--surface-800));
    border: 1px solid rgba(173, 58, 66, 0.2);
    box-shadow: var(--shadow-elevation-1);
}

.summary-value {
    margin-top: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ── Total Card ──────────────────────────────────────────── */

.total-card {
    position: relative;
    overflow: hidden;
    margin-top: 20px;
    border-radius: var(--radius-lg);
    padding: 28px;
    background:
        radial-gradient(ellipse 70% 60% at 80% 80%, rgba(237, 199, 81, 0.18), transparent 55%),
        radial-gradient(ellipse 80% 70% at 10% 20%, rgba(126, 33, 43, 0.3), transparent 50%),
        linear-gradient(145deg, var(--surface-700) 0%, var(--surface-800) 50%, var(--surface-700) 100%);
    color: var(--text-primary);
    border: 1px solid rgba(242, 212, 112, 0.22);
    box-shadow: var(--shadow-elevation-3), var(--shadow-gold-glow);
}

.total-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 5%, var(--gold-500) 30%, var(--gold-300) 50%, var(--gold-500) 70%, transparent 95%);
    opacity: 0.4;
}

.total-card::after {
    content: "";
    position: absolute;
    bottom: -60px;
    right: -60px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(237, 199, 81, 0.2), transparent 65%);
    pointer-events: none;
}

.total-label {
    color: var(--gold-500);
    font-size: 0.72rem;
}

.total-value {
    margin-top: 12px;
    font-family: var(--font-body);
    font-size: clamp(2rem, 4.5vw, 3.2rem);
    line-height: 1.05;
    font-weight: 700;
    color: var(--gold-300);
    letter-spacing: -0.02em;
}

.total-placeholder {
    font-family: var(--font-body);
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    line-height: 1.3;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0;
}

.total-footnote {
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.6;
}

/* ── Notes Card ──────────────────────────────────────────── */

.notes-card {
    margin-top: 20px;
    padding: 18px 20px;
    border-radius: var(--radius-md);
    background: linear-gradient(160deg, var(--surface-800), var(--surface-850));
    border: 1px solid rgba(173, 58, 66, 0.15);
    box-shadow: var(--shadow-elevation-1);
}

.notes-list {
    margin-top: 10px;
    padding-left: 18px;
    color: var(--text-muted);
    line-height: 1.7;
    font-size: 0.85rem;
}

.notes-list li + li {
    margin-top: 6px;
}

.notes-list li::marker {
    color: var(--gold-600);
}

/* ── Footer ──────────────────────────────────────────────── */

.page-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid rgba(173, 58, 66, 0.2);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

/* ── Settings / Pricing Center ───────────────────────────── */

.settings-layout {
    display: grid;
    grid-template-columns: 1.35fr 0.65fr;
    gap: 24px;
}

.settings-layout-single {
    grid-template-columns: 1fr;
}

.settings-shell {
    padding-bottom: 32px;
}

.settings-list {
    display: grid;
    gap: 0;
    margin-top: 0;
}

.settings-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-top: 20px;
}

.notes-inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    max-width: 420px;
}

.settings-guide {
    display: grid;
    gap: 6px;
    margin-top: 20px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: rgba(74, 16, 36, 0.25);
    border: 1px solid rgba(173, 58, 66, 0.12);
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.85rem;
}

.settings-guide strong {
    color: var(--gold-400);
    font-weight: 600;
}

.settings-table-card {
    margin-top: 24px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: linear-gradient(170deg, var(--surface-850) 0%, var(--surface-900) 100%);
    border: 1px solid rgba(242, 212, 112, 0.1);
    box-shadow: var(--shadow-elevation-2);
    position: relative;
}

.settings-table-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-400) 30%, var(--gold-300) 50%, var(--gold-400) 70%, transparent);
    opacity: 0.35;
    z-index: 1;
}

.settings-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.strip-card {
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: linear-gradient(150deg, var(--surface-700) 0%, var(--surface-800) 100%);
    border: 1px solid rgba(173, 58, 66, 0.14);
    box-shadow: var(--shadow-elevation-1);
    transition: border-color 0.25s ease, transform 0.25s var(--ease-out-expo);
}

.strip-card:hover {
    border-color: rgba(242, 212, 112, 0.15);
    transform: translateY(-1px);
}

.strip-label {
    display: block;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold-400);
    opacity: 0.7;
}

.strip-value {
    display: block;
    margin-top: 8px;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
}

.settings-panel-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    padding: 24px 28px 20px;
    border-bottom: 1px solid rgba(242, 212, 112, 0.06);
}

.settings-panel-head h3 {
    margin-top: 6px;
    font-family: var(--font-display);
    color: var(--text-primary);
    font-size: clamp(1.2rem, 1.8vw, 1.6rem);
    font-weight: 700;
}

.settings-panel-copy {
    max-width: 42ch;
    color: var(--text-muted);
    line-height: 1.6;
    text-align: right;
    font-size: 0.85rem;
}

.settings-card {
    padding: 22px 28px;
    border-top: 1px solid rgba(242, 212, 112, 0.06);
    background: transparent;
    transition: background 0.25s ease;
}

.settings-card:nth-child(even) {
    background: rgba(28, 5, 16, 0.25);
}

.settings-card:hover {
    background: rgba(28, 5, 16, 0.35);
}

.settings-card:first-child {
    border-top: none;
}

.settings-form {
    display: block;
}

.settings-title {
    font-size: 1.35rem;
    color: #ffffff;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow: 0 0 16px rgba(237, 199, 81, 0.4);
}

.settings-subtitle {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-family: "DM Sans", monospace;
    letter-spacing: 0.06em;
}

.settings-meta {
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1.4;
}

.settings-row {
    display: grid;
    grid-template-columns: minmax(160px, 0.8fr) minmax(280px, 1.4fr) minmax(160px, 0.8fr);
    gap: 24px;
    align-items: center;
}

.settings-identity {
    display: grid;
    gap: 3px;
}

.settings-identity:has(.settings-title:not(:empty)) {
    align-content: start;
}

.settings-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 12px;
}

.settings-metrics .field-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.settings-metrics .field-input {
    background: rgba(28, 5, 16, 0.5);
    border-color: rgba(242, 212, 112, 0.1);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 12px 14px;
}

.settings-metrics .field-input:hover {
    border-color: rgba(242, 212, 112, 0.2);
    background: rgba(28, 5, 16, 0.6);
}

.settings-metrics .field-input:focus {
    border-color: var(--gold-500);
    background: rgba(28, 5, 16, 0.65);
}

.settings-toggles {
    display: grid;
    grid-template-columns: minmax(140px, 1fr);
    gap: 12px;
}

.settings-global-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 22px 28px 26px;
    border-top: 1px solid rgba(242, 212, 112, 0.06);
}

/* ── Toggle ──────────────────────────────────────────────── */

.toggle-field {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    padding: 10px 14px;
    border: 1px solid rgba(242, 212, 112, 0.08);
    border-radius: var(--radius-sm);
    background: rgba(28, 5, 16, 0.4);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
    min-width: 0;
    cursor: pointer;
    transition: border-color 0.25s ease, background 0.25s ease;
}

.toggle-field:hover {
    border-color: rgba(242, 212, 112, 0.15);
    background: rgba(28, 5, 16, 0.55);
}

.toggle-field input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-slider {
    position: relative;
    width: 42px;
    height: 23px;
    border-radius: 999px;
    background: var(--surface-600);
    transition: background 0.3s var(--ease-out-expo), box-shadow 0.3s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--text-secondary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    transition: transform 0.3s var(--ease-spring), background 0.3s ease;
}

.toggle-field input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
    box-shadow: 0 0 12px rgba(237, 199, 81, 0.15);
}

.toggle-field input:checked + .toggle-slider::after {
    transform: translateX(19px);
    background: #fff;
}

.toggle-field input:disabled + .toggle-slider {
    opacity: 0.4;
}

.toggle-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.toggle-copy .field-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.toggle-value {
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 600;
}

/* ── Mini Badge ──────────────────────────────────────────── */

.mini-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--surface-700);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.mini-badge-live {
    background: rgba(52, 211, 153, 0.08);
    color: var(--accent-success);
    border: 1px solid rgba(52, 211, 153, 0.12);
}

.settings-list-table {
    gap: 0;
    margin-top: 0;
}

/* ── Utility ─────────────────────────────────────────────── */

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

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 980px) {
    .hero-highlight {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .hero-highlight-copy {
        text-align: left;
    }

    .app-grid,
    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-strip,
    .settings-row,
    .settings-metrics,
    .settings-toggles {
        grid-template-columns: 1fr;
    }

    .settings-panel-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .settings-panel-copy {
        text-align: left;
    }

    .settings-global-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .page-shell {
        padding: 16px 14px 32px;
    }

    .hero {
        padding: 24px 20px;
        border-radius: var(--radius-lg);
    }

    .calculator-card,
    .results-panel {
        border-radius: var(--radius-lg);
        padding: 24px 20px;
    }

    .hero-brand {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .field-row,
    .gold-controls,
    .summary-grid,
    .action-row,
    .results-topline {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .settings-toolbar,
    .notes-inline {
        align-items: stretch;
    }

    .settings-card {
        padding: 18px 20px;
    }

    .settings-identity {
        padding-bottom: 4px;
        border-bottom: 1px solid rgba(242, 212, 112, 0.05);
        margin-bottom: 4px;
    }

    .unit-field {
        width: 100%;
    }

    .last-updated {
        text-align: left;
    }

    .timestamp-pill {
        width: 100%;
        text-align: left;
    }

    .settings-table-card {
        border-radius: var(--radius-lg);
    }

    .settings-panel-head {
        padding-left: 20px;
        padding-right: 20px;
    }

    .settings-global-actions {
        padding-left: 20px;
        padding-right: 20px;
    }

    .toggle-field,
    .field-input {
        min-height: 52px;
    }

    .secondary-button {
        width: 100%;
    }

    .settings-strip {
        grid-template-columns: 1fr;
    }
}

/* ── Scrollbar ───────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-950);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-600);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--surface-500);
}

/* ── Selection ───────────────────────────────────────────── */

::selection {
    background: rgba(237, 199, 81, 0.3);
    color: var(--text-primary);
}

/* ── Customer App: Minimal mobile-first ──────────────────── */

body.customer-app .page-shell {
    max-width: 480px;
    padding: 16px 14px 24px;
}

body.customer-app .page-footer,
body.customer-app .hero,
body.customer-app .results-panel,
body.customer-app .notes-card,
body.customer-app .value-frame,
body.customer-app .customer-results {
    display: none;
}

body.customer-app .customer-card {
    animation: cardEntry 0.5s var(--ease-out-expo) both;
}

@keyframes cardEntry {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

body.customer-app .customer-card {
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    padding: 20px 18px 18px;
    border: 1px solid rgba(246, 224, 142, 0.18);
    background: linear-gradient(168deg, rgba(62, 13, 28, 0.96) 0%, rgba(40, 8, 18, 0.99) 100%);
    box-shadow: var(--shadow-elevation-2);
}

body.customer-app .customer-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 12%;
    right: 12%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-400) 30%, var(--gold-300) 50%, var(--gold-400) 70%, transparent);
    opacity: 0.5;
    z-index: 2;
}

body.customer-app .customer-card > * {
    position: relative;
    z-index: 1;
}

/* Material image strip */
body.customer-app .material-preview {
    position: relative;
    z-index: 1;
    margin: -20px -18px 14px;
    height: 80px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid rgba(246, 224, 142, 0.08);
    opacity: 1;
    overflow: hidden;
}

body.customer-app .material-preview-img {
    object-position: center 38%;
}

body.customer-app .material-preview::after {
    background:
        linear-gradient(180deg,
            rgba(40, 8, 18, 0.35) 0%,
            rgba(62, 13, 28, 0.05) 30%,
            rgba(62, 13, 28, 0.05) 65%,
            rgba(62, 13, 28, 0.5) 100%);
}

/* ── Topbar: logo left, price right ─────────────────────── */

body.customer-app .customer-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

body.customer-app .customer-topbar .hero-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    padding: 0;
    border-radius: 0;
}

body.customer-app .customer-topbar .brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border-width: 1.5px;
}

body.customer-app .customer-topbar h1 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.15;
    margin: 0;
}

body.customer-app .price-live {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(237, 199, 81, 0.08);
    border: 1px solid rgba(246, 224, 142, 0.15);
    white-space: nowrap;
}

body.customer-app .price-live-label {
    font-size: 0.64rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

body.customer-app .price-live-value {
    font-size: 0.96rem;
    font-weight: 700;
    color: var(--gold-300);
    line-height: 1;
}

body.customer-app .price-live-value.value-placeholder {
    font-size: 0.82rem;
    color: var(--text-muted);
}

body.customer-app .price-live-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid rgba(246, 224, 142, 0.14);
    border-radius: 6px;
    background: rgba(237, 199, 81, 0.1);
    color: var(--gold-400);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

body.customer-app .price-live-refresh:hover {
    background: rgba(237, 199, 81, 0.2);
    transform: rotate(30deg);
}

body.customer-app .price-live-refresh:active {
    transform: rotate(180deg);
}

/* ── Form ────────────────────────────────────────────────── */

body.customer-app .calc-form {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

body.customer-app .calc-form .field-label {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

body.customer-app .calc-form .field-input {
    min-height: 50px;
    padding: 12px 14px;
    font-size: 1rem;
    border-color: rgba(173, 58, 66, 0.28);
    background: rgba(74, 16, 36, 0.6);
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

body.customer-app .calc-form .field-input-sm {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.92rem;
}

body.customer-app .calc-row-weight {
    display: grid;
    grid-template-columns: 1fr 90px;
    gap: 8px;
    align-items: end;
}

body.customer-app .calc-row-weight .field-grow {
    min-width: 0;
}

body.customer-app .calc-row-weight .field-unit {
    width: 90px;
}

body.customer-app .calc-row-type {
    display: flex;
    gap: 8px;
    align-items: end;
}

body.customer-app .calc-row-type .field-grow {
    flex: 1;
    min-width: 0;
}

body.customer-app .calc-row-type .field-purity {
    width: 100px;
    flex-shrink: 0;
}

body.customer-app .calc-submit {
    min-height: 50px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* ── Result area ─────────────────────────────────────────── */

body.customer-app .calc-result {
    margin-top: 14px;
    padding: 16px;
    border-radius: 14px;
    background: rgba(80, 22, 35, 0.5);
    border: 1px solid rgba(246, 224, 142, 0.12);
    transition: border-color 0.4s ease, background 0.4s ease;
}

body.customer-app .calc-result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

body.customer-app .calc-result-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gold-400);
}

body.customer-app .calc-result-total {
    margin-top: 6px;
    font-family: var(--font-body);
    font-size: clamp(1.7rem, 7vw, 2.3rem);
    font-weight: 700;
    color: var(--gold-300);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

body.customer-app .calc-result-total.total-placeholder {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0;
    margin-top: 8px;
}

body.customer-app .calc-result-detail {
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    min-height: 0;
}

body.customer-app .calc-result-meta {
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 600;
    display: flex;
    gap: 6px;
}

body.customer-app .calc-result-meta span:empty {
    display: none;
}

body.customer-app .calc-result-meta span:not(:empty) + span:not(:empty)::before {
    content: "·";
    margin-right: 6px;
    color: var(--text-muted);
}

body.customer-app .calc-result-time {
    margin-top: 6px;
    font-size: 0.66rem;
    color: var(--text-muted);
}

body.customer-app .calc-result:has(.calc-result-total:not(.total-placeholder)) {
    background: rgba(80, 22, 35, 0.6);
    border-color: rgba(246, 224, 142, 0.2);
}

/* ── Status ──────────────────────────────────────────────── */

body.customer-app .status-banner {
    margin-top: 10px;
    margin-bottom: 2px;
    font-size: 0.76rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 10px;
}

/* ── Focus / a11y ────────────────────────────────────────── */

body.customer-app .field-input:focus,
body.customer-app .calc-submit:focus-visible,
body.customer-app .price-live-refresh:focus-visible {
    outline: 3px solid rgba(246, 224, 142, 0.7);
    outline-offset: 2px;
}

/* ── Small screens ───────────────────────────────────────── */

@media (max-width: 390px) {
    body.customer-app .page-shell {
        padding: 12px 10px 20px;
    }

    body.customer-app .customer-card {
        padding: 16px 14px 14px;
        border-radius: 18px;
    }

    body.customer-app .customer-card::before {
        left: 8%;
        right: 8%;
    }

    body.customer-app .material-preview {
        margin-top: -16px;
        margin-left: -14px;
        margin-right: -14px;
    }

    body.customer-app .customer-topbar {
        flex-wrap: wrap;
    }

    body.customer-app .price-live {
        order: -1;
        width: 100%;
        justify-content: space-between;
    }

    body.customer-app .calc-row-weight {
        grid-template-columns: 1fr 80px;
    }

    body.customer-app .calc-row-type {
        flex-wrap: wrap;
    }

    body.customer-app .calc-row-type .field-purity {
        width: 100%;
    }

    body.customer-app .calc-result {
        padding: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.customer-app * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
