:root {
    --bg-primary: #080d1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.88);
    --bg-input: #0b111e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --gold: #d4af37;
    --gold-soft: #f3e5ab;
    --teal: #2dd4bf;
    --border: rgba(255, 255, 255, 0.12);
    --border-hover: rgba(45, 212, 191, 0.45);
    --error: #f87171;
}

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

body {
    font-family: 'Outfit', 'Noto Sans Myanmar', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: radial-gradient(circle at 50% 0%, #15223e 0%, var(--bg-primary) 75%);
    color: var(--text-main);
    padding: 16px 12px 40px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

@media (min-width: 640px) {
    body {
        padding: 24px 20px 60px;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* HEADER & LANGUAGE SWITCHER */
header {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 18px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.header-brand {
    flex: 1;
    min-width: 0;
}

header h1 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 5vw, 2.5rem);
    letter-spacing: 0.01em;
    line-height: 1.25;
    background: linear-gradient(135deg, #ffffff 20%, var(--gold-soft) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    margin-top: 4px;
    font-size: clamp(0.78rem, 2.8vw, 0.92rem);
    line-height: 1.45;
}

/* Language Toggle Switch */
.lang-switch-wrapper {
    flex-shrink: 0;
}

.lang-toggle-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 30px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.25s ease;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    min-height: 38px;
}

.lang-toggle-btn:hover,
.lang-toggle-btn:active {
    border-color: var(--teal);
    box-shadow: 0 0 12px rgba(45, 212, 191, 0.3);
}

.lang-opt {
    transition: color 0.2s ease;
}

.lang-opt.active {
    color: var(--teal);
    font-weight: 700;
}

.lang-divider {
    color: var(--border);
    font-weight: 300;
}

/* GRID & CARDS */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 16px;
}

@media (min-width: 768px) {
    .grid {
        grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
        gap: 20px;
    }
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    transition: transform 0.2s ease, border-color 0.25s ease;
    width: 100%;
}

@media (min-width: 640px) {
    .card {
        padding: 22px;
        border-radius: 16px;
    }
}

.card:hover {
    border-color: var(--border-hover);
}

.card h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 4vw, 1.4rem);
    margin-bottom: 14px;
    color: var(--teal);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    line-height: 1.35;
}

.form-group {
    margin-bottom: 14px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.84rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Form Inputs optimized for Mobile Touch (font-size >= 16px to prevent iOS auto-zoom) */
input[type="range"],
input[type="color"],
select,
input[type="text"],
input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    font-family: 'DM Mono', monospace;
    font-size: 16px; /* Prevents mobile Safari zoom */
    transition: border-color 0.2s ease;
    min-height: 42px;
    color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: brightness(0) invert(1);
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

input[type="color"] {
    padding: 4px;
    height: 44px;
    cursor: pointer;
}

input[type="range"] {
    accent-color: var(--gold);
    padding: 0;
    height: 8px;
    min-height: 28px;
    cursor: pointer;
}

select:focus,
input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}

.split-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (min-width: 480px) {
    .split-row {
        flex-direction: row;
        gap: 14px;
    }
}

.split-col {
    flex: 1;
    min-width: 0;
}

.preview-box {
    width: 100%;
    min-height: 85px;
    border-radius: 10px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
    transition: background 0.25s ease, color 0.25s ease;
    padding: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    word-break: break-word;
    font-size: 0.92rem;
}

.contrast-demo {
    font-family: 'Noto Sans Myanmar', sans-serif;
    font-size: 0.98rem;
}

.mini-btn {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: inherit;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    min-height: 36px;
    touch-action: manipulation;
}

.mini-btn:active {
    background: rgba(0, 0, 0, 0.7);
}

/* Responsive Table Wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.output-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    min-width: 260px;
}

.output-table th,
.output-table td {
    padding: 8px 10px;
    border: 1px solid var(--border);
    text-align: left;
    word-break: break-word;
}

.output-table th {
    background: var(--bg-input);
    color: var(--gold-soft);
    font-weight: 600;
    width: 38%;
}

canvas {
    background: #000;
    border-radius: 8px;
    width: 100%;
    height: 150px;
    display: block;
    border: 1px solid var(--border);
}

.note {
    font-size: 0.8rem;
    margin-top: 12px;
    color: var(--text-muted);
    line-height: 1.55;
    word-break: break-word;
}

.note.mono {
    font-family: 'DM Mono', monospace;
    font-size: 0.78rem;
}

.kelvin-ticks {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    gap: 2px;
}

.kelvin-ticks span {
    flex: 1;
    line-height: 1.2;
}

/* Color Badge & Swatch inside Table */
.color-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.78rem;
    margin: 2px 0;
}

.color-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    flex-shrink: 0;
}
