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

body {
    font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f8fafc;
    color: #0f172a;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ======== Layout ======== */

.layout {
    display: flex;
    min-height: 100dvh;
}

/* ======== Sidebar ======== */

.sidebar {
    width: 220px;
    min-width: 220px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
}

.sidebar-brand {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.sidebar-close {
    display: none;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.15s;
}

.sidebar-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Geist', sans-serif;
    color: #64748b;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.nav-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.nav-item.active {
    background: #eff6ff;
    color: #3b82f6;
}

.nav-item svg {
    flex-shrink: 0;
}

/* ======== Overlay (mobile) ======== */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

/* ======== Main ======== */

.main {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* ======== Topbar (mobile) ======== */

.topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s;
}

.topbar-menu:hover {
    background: #f1f5f9;
}

.topbar-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #0f172a;
}

.topbar-spacer {
    flex: 1;
}

/* ======== Page Content ======== */

.page-content {
    flex: 1;
    padding: 48px 32px;
}

.page {
    display: none;
    max-width: 520px;
    margin: 0 auto;
}

.page.active {
    display: block;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 28px;
}

/* ======== Card ======== */

.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px -8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

/* ======== Fields ======== */

.fields {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 20px;
}

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

.field-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.field-input-box {
    display: flex;
    align-items: stretch;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input-box:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.field-input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Geist Mono', monospace;
    background: transparent;
    border: none;
    outline: none;
    color: #0f172a;
}

.field-input::placeholder {
    color: #cbd5e1;
}

.field-input::-webkit-outer-spin-button,
.field-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.field-input[type="number"] {
    -moz-appearance: textfield;
}

.field-unit {
    display: flex;
    align-items: center;
    padding: 0 16px 0 4px;
    font-size: 0.8125rem;
    color: #94a3b8;
    font-weight: 500;
}

/* ======== Hex Input ======== */

.hex-input-box {
    display: flex;
    align-items: stretch;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.hex-input-box:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.hex-hash {
    display: flex;
    align-items: center;
    padding: 12px 0 12px 16px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Geist Mono', monospace;
    color: #94a3b8;
}

.hex-input {
    padding-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ======== Color Preview ======== */

.color-preview {
    height: 56px;
    border-radius: 10px;
    margin-top: 18px;
    background: #e2e8f0;
    transition: background 0.2s;
}

/* ======== Button ======== */

.btn-calc {
    display: block;
    width: 100%;
    padding: 13px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: 'Geist', sans-serif;
    color: #fff;
    background: #3b82f6;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn-calc:hover {
    background: #2563eb;
}

.btn-calc:active {
    transform: scale(0.98);
}

/* ======== Results ======== */

.results {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #1e293b;
    border-radius: 10px;
    padding: 14px 18px;
    transition: background 0.15s;
}

.result-item:hover {
    background: #273548;
}

.result-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    min-width: 36px;
}

.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.result-value {
    font-size: 1.125rem;
    font-weight: 600;
    font-family: 'Geist Mono', monospace;
    color: #a5f3fc;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-code {
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Geist Mono', monospace;
    color: #86efac;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ======== Copy Button ======== */

.btn-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-copy:hover {
    background: #334155;
    color: #94a3b8;
}

.btn-copy:active {
    transform: scale(0.93);
}

/* ======== Empty State ======== */

.empty-hint {
    text-align: center;
    font-size: 0.875rem;
    color: #94a3b8;
    padding: 24px 0;
}

.empty-hint.hidden {
    display: none;
}

/* ======== Placeholder ======== */

.placeholder-card {
    text-align: center;
}

.placeholder-text {
    font-size: 0.9375rem;
    color: #94a3b8;
    padding: 32px 0;
}

/* ======== Toast ======== */

.toast {
    position: fixed;
    top: 40px;
    left: 50%;
    transform: translate(-50%, -200%);
    opacity: 0;
    padding: 10px 24px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #fff;
    background: #10b981;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
    pointer-events: none;
    z-index: 9999;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.15s;
}

.toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

.hidden {
    display: none !important;
}

/* ======== Mobile: <= 768px ======== */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar-overlay.show {
        opacity: 1;
        pointer-events: auto;
    }

    .main {
        margin-left: 0;
    }

    .topbar {
        display: flex;
    }

    .page-content {
        padding: 24px 16px;
    }

    .page-title {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
}
