* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #007bff;
    --primary-dark: #0056b3;
    --primary-light: #e7f1ff;
    --text: #333;
    --text-muted: #666;
    --bg: #f8f9fa;
    --border: #ddd;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    box-shadow: var(--shadow);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    text-decoration: none;
}

main {
    padding: 2rem 0;
}

.lg-flex {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

.content-area {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

h2 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text);
}

h3 {
    font-size: 1.1rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.warning-box {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    color: #856404;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

label {
    font-weight: 600;
    color: var(--text);
}

.input-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

input[type="text"],
select {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input[readonly] {
    background-color: #f0f0f0;
    cursor: default;
}

.result-container {
    position: relative;
    display: flex;
    gap: 0.5rem;
}

.result-container input {
    flex: 1;
}

.copy-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: var(--primary-dark);
}

.copy-success {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--success);
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.copy-success.show {
    opacity: 1;
}

.unit-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

select {
    max-height: 150px;
    padding: 0.75rem;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-weight: 600;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.formula-display {
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
    padding: 1rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    min-height: 40px;
}

.unit-definition {
    background: var(--bg);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary);
}

.unit-definition p {
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

code {
    background: var(--bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: var(--danger);
}

.table-container {
    overflow-x: auto;
}

.reference-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.reference-table th,
.reference-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.reference-table th {
    background: var(--primary-light);
    font-weight: 600;
    color: var(--text);
}

.reference-table tr:hover {
    background: var(--bg);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.sidebar-section {
    padding: 1.5rem;
}

.sidebar-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-link {
    color: var(--primary);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 3px;
    transition: all 0.2s;
}

.sidebar-link:hover {
    background: var(--primary-light);
    padding-left: 0.75rem;
}

footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.error-message {
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 20px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

@media (max-width: 768px) {
    .lg-flex {
        grid-template-columns: 1fr;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    h1 {
        font-size: 1.5rem;
    }
}