:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.5);
    --border-color: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #020617;
    background-image: radial-gradient(circle at 15% 0%, rgba(30, 58, 138, 0.4), transparent 50%),
                      radial-gradient(circle at 85% 80%, rgba(15, 118, 110, 0.3), transparent 50%),
                      radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.05), transparent 70%);
    color: var(--text-main);
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    width: 100%;
    margin: 2rem auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-weight: 800;
    font-size: 3rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

header p {
    color: var(--text-muted);
}

.nav-tabs {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    opacity: 0.5;
}

.tab-btn:hover {
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.04);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.tab-btn.active {
    opacity: 1;
    border-bottom: 2px solid var(--accent);
    background: linear-gradient(to top, rgba(56, 189, 248, 0.15), transparent);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.tab-title {
    color: var(--text-main);
    font-size: 1rem;
    font-weight: bold;
    white-space: nowrap;
}

.tab-subtitle {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: normal;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }
}

.col-left, .col-right {
    display: flex;
    flex-direction: column;
}

.card {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255,255,255,0.05);
    height: 100%; margin-bottom: 0;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.4s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.4), 0 0 20px rgba(56, 189, 248, 0.05), inset 0 1px 0 rgba(255,255,255,0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group-hz {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.form-group-hz label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group-hz .input-wrapper {
    width: 140px;
}

.form-group input, .form-group-hz input {
    width: 100%;
    padding: 0.75rem;
    padding-right: 2.5rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group input:focus, .form-group-hz input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2), 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.form-group input:hover:not(:focus), .form-group-hz input:hover:not(:focus) {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Hide number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.unit {
    position: absolute;
    right: 12px;
    color: #94a3b8;
    font-size: 0.9rem;
    pointer-events: none;
}

.form-group input:focus, .form-group-hz input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px dashed var(--border-color);
}

.result-item:last-of-type {
    border-bottom: none;
}

.result-label {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.pdf-ref {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.6);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    margin-left: 0.8rem;
    border: 1px solid var(--border-color);
    cursor: help;
    transition: all 0.2s;
    font-weight: normal;
    letter-spacing: normal;
    white-space: nowrap;
    flex-shrink: 0;
    text-decoration: none;
}
.pdf-ref:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(56, 189, 248, 0.1);
}

.result-value {
    font-weight: 600;
    font-size: 1.1rem;
}

.highlight {
    background: rgba(56, 189, 248, 0.1);
    padding: 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.highlight .result-value {
    color: var(--accent);
    font-size: 1.3rem;
}

.critical-inductance-note {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

.formula-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .formula-grid {
        grid-template-columns: 1fr;
    }
}

.formula-item {
    background: rgba(15, 23, 42, 0.4);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.formula-item h3 {
    font-size: 1.05rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

/* State Diagrams & Waveforms Styling */
.state-diagrams {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .state-diagrams {
        grid-template-columns: 1fr;
    }
}

.state-panel {
    background: rgba(15, 23, 42, 0.4);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.state-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.state-tags {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    font-size: 0.9rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.tag-orange { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border: 1px solid #f59e0b; }
.tag-green { background: rgba(16, 185, 129, 0.2); color: #10b981; border: 1px solid #10b981; }
.tag-blue { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid #38bdf8; }

.state-desc {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.svg-container {
    background: rgba(15, 23, 42, 0.8);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    justify-content: center;
    border: 1px solid var(--border-color);
    margin-top: auto;
}

.waveforms-bg {
    background: #0f172a;
    padding: 2rem;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-content {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h2 { margin: 0; font-size: 1.5rem; }
.modal-close {
    background: none; border: none; color: white;
    font-size: 2rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: #f43f5e; }

/* Tabs inside Modal */
.modal-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}
.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 6px;
    transition: all 0.2s;
}
.tab-btn:hover { background: rgba(255,255,255,0.05); color: white; }
.tab-btn.active {
    background: var(--accent);
    color: white;
}
.modal-tab-content { display: none; }
.modal-tab-content.active { display: block; }

/* Table styling for Coordinates */
.table-container {
    overflow-x: auto;
    margin-bottom: 1rem;
}
.coord-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel-bg);
}
.coord-table th, .coord-table td {
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.coord-table th { color: var(--accent); font-weight: normal; }
.coord-table input {
    background: #0f172a;
    border: 1px solid var(--border-color);
    color: white;
    padding: 0.4rem;
    border-radius: 4px;
    width: 100px;
}
.btn-remove-row {
    background: #f43f5e; color: white;
    border: none; border-radius: 4px;
    padding: 0.3rem 0.6rem; cursor: pointer;
}
.btn-remove-row:hover { background: #e11d48; }
.btn-add-row {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent); border: 1px dashed var(--accent);
    padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer;
    width: 100%; margin-bottom: 1rem;
}
.btn-add-row:hover { background: rgba(56, 189, 248, 0.2); }
.calc-result-box {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid #10b981;
    padding: 1rem; border-radius: 8px;
    text-align: center; font-size: 1.2rem;
}/* Card Header Dual-line Typography */
.card-header-title {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.card-header-title .zh {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.2;
}
.card-header-title .en {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.1;
    letter-spacing: 0.02em;
}

/* Alignment for page-loss */
@media (min-width: 769px) {
    #page-loss .col-left > .card, #page-loss .col-right > .card {
        height: 100%;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
}

