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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1e1e1e;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.header {
    background: #2d2d2d;
    padding: 1rem 2rem;
    border-bottom: 1px solid #404040;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn {
    padding: 0.5rem 1rem;
    background: #007acc;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn:hover {
    background: #005a9e;
}

.btn:disabled {
    background: #555;
    cursor: not-allowed;
}

.btn-secondary {
    background: #555;
}

.btn-secondary:hover {
    background: #666;
}

.btn-secondary.active {
    background: #007acc;
    opacity: 1;
}

.btn.active {
    background: #007acc;
}

/* Sliding switch for Filled/Outline */
.fill-mode-switch {
    display: flex;
    background: #555;
    border-radius: 4px;
    padding: 2px;
    margin-left: 10px;
    position: relative;
    cursor: pointer;
    user-select: none;
    min-width: 120px;
}

.fill-mode-switch .switch-option {
    flex: 1;
    padding: 0.4rem 0.8rem;
    border-radius: 3px;
    transition: color 0.2s;
    z-index: 2;
    position: relative;
    font-size: 0.9rem;
    text-align: center;
}

.fill-mode-switch .switch-slider {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 2px;
    background: #007acc;
    border-radius: 3px;
    transition: left 0.2s ease, width 0.2s ease;
    z-index: 1;
}

.fill-mode-switch .switch-option.active {
    color: white;
    font-weight: 600;
}

.fill-mode-switch .switch-option.inactive {
    color: #bbb;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 300px;
    background: #252526;
    border-right: 1px solid #404040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem 1rem 0.35rem;
    font-weight: 600;
}

.sidebar-note {
    padding: 0 1rem 0.7rem;
    color: #999;
    font-size: 0.75rem;
    border-bottom: 1px solid #404040;
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.file-item {
    padding: 0.75rem;
    margin: 0.25rem 0;
    background: #2d2d2d;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-item:hover {
    background: #3d3d3d;
}

.file-item.active {
    background: #007acc;
}

.layer-toggle {
    margin: 0 0.45rem 0 0;
    flex: 0 0 auto;
    cursor: pointer;
}

.layer-swatch {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 2px;
    margin-right: 0.45rem;
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid #666;
    box-sizing: border-box;
}

.file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 0.8rem;
    color: #999;
    margin-left: 0.5rem;
}

.viewer-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    position: relative;
}

.viewer-toolbar {
    padding: 0.75rem 1rem;
    background: #252526;
    border-bottom: 1px solid #404040;
    display: flex;
    gap: 1rem;
    align-items: center;
    position: relative;
    z-index: 1;
}

.unwarp-bar {
    display: none;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    background: #1f2a33;
    border-bottom: 1px solid #3c3c3c;
    flex-wrap: wrap;
}

.unwarp-bar.visible {
    display: flex;
}

.unwarp-bar .hint {
    color: #d0d0d0;
    font-size: 0.82rem;
    margin-left: 0.4rem;
}

.zoom-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.zoom-info {
    min-width: 100px;
    text-align: center;
    font-size: 0.9rem;
}

.canvas-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #1e1e1e;
}

#gerberCanvas {
    display: block;
    background: #2d2d2d;
    cursor: crosshair;
}

.status-bar {
    padding: 0.5rem 1rem;
    background: #007acc;
    color: white;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.status-bar .coords-section {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.status-bar .unit-btn {
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    font-weight: bold;
    background: rgba(255,255,255,0.25);
    color: white;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 3px;
    cursor: pointer;
    min-width: 28px;
}
.status-bar .unit-btn:hover {
    background: rgba(255,255,255,0.35);
}

.upload-area {
    padding: 1rem;
    border-top: 1px solid #404040;
    overflow-y: auto;
    max-height: 58vh;
}
#homeConfirmConvertBtn:disabled,
#viewerConfirmConvertBtn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.upload-btn {
    width: 100%;
    padding: 0.75rem;
    background: #555;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
}

.upload-btn:hover {
    background: #666;
}

input[type="file"] {
    display: none;
}

.info-panel {
    position: absolute;
    top: calc(0.75rem + 1rem + 1rem + 10px);
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    min-width: 200px;
    max-width: 500px;
    max-height: calc(100vh - 150px);
    display: none;
    overflow-y: auto;
    z-index: 1000;
}

.info-panel.visible {
    display: block;
}

.gerber-text-container {
    margin-top: 1rem;
    border-top: 1px solid #404040;
    padding-top: 1rem;
}

.gerber-text-label {
    color: #999;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.gerber-text-content {
    background: #1a1a1a;
    border: 1px solid #404040;
    border-radius: 4px;
    padding: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #e0e0e0;
}

.gerber-line {
    cursor: pointer;
    padding: 2px 4px;
    margin: 1px 0;
    border-radius: 2px;
    transition: background 0.2s;
}

.gerber-line:hover {
    background: rgba(255, 255, 255, 0.1);
}

.gerber-line.selected {
    background: rgba(0, 122, 204, 0.3);
    border-left: 3px solid #007acc;
}

.info-row {
    margin: 0.5rem 0;
}

.info-label {
    color: #999;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 30;
    color: #ddd;
    font-size: 1.05rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: rgba(30, 30, 30, 0.94);
    border: 1px solid #555;
    border-radius: 6px;
    pointer-events: auto;
}

.loading .stop-btn {
    background: #8b2e2e;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.9rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.loading .stop-btn:hover {
    background: #a33;
}

.loading-track {
    width: 240px;
    height: 8px;
    background: #333;
    border-radius: 4px;
    overflow: hidden;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: #3ec1ff;
}

/* SVG Inspector Modal */
.svg-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    overflow: auto;
}

.svg-modal-content {
    background-color: #1e1e1e;
    margin: 2% auto;
    padding: 20px;
    border: 1px solid #404040;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
}

.svg-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #404040;
}

.svg-modal-header h2 {
    margin: 0;
    color: #e0e0e0;
}

.svg-modal-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.svg-modal-close:hover {
    color: #fff;
}

.svg-modal-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.svg-modal-textarea {
    flex: 1;
    min-height: 400px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background-color: #2d2d2d;
    color: #e0e0e0;
    border: 1px solid #555;
    padding: 15px;
    border-radius: 4px;
    resize: vertical;
    overflow: auto;
    white-space: pre;
    word-wrap: normal;
}

.svg-modal-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #888;
    margin: 14px 0 6px 0;
}
.svg-modal-section-title:first-of-type {
    margin-top: 0;
}
.svg-modal-section-title .hint {
    text-transform: none;
    letter-spacing: normal;
    color: #666;
    font-weight: normal;
}
.svg-modal-render-preview {
    margin-top: 16px;
    border: 2px solid #007acc;
    border-radius: 6px;
    background: #1e1e1e;
    overflow: hidden;
    max-height: 320px;
}
.svg-preview-chrome {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 8px 12px;
    background: rgba(0, 122, 204, 0.2);
    border-bottom: 2px solid #007acc;
}
.svg-preview-badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: #fff;
    background: #007acc;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
}
.svg-preview-sub {
    font-size: 0.78rem;
    color: #c8c8c8;
    line-height: 1.35;
    flex: 1;
    min-width: 180px;
}
.svg-preview-canvas-host {
    padding: 12px;
    max-height: 240px;
    overflow: auto;
    background: #fafafa;
}
.svg-preview-canvas-host svg {
    max-width: 100%;
    height: auto;
    display: block;
}
.svg-preview-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.svg-preview-toolbar-badge {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Hamburger and routing */
.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid #555;
    border-radius: 4px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 1.25rem;
}
.hamburger-btn:hover {
    background: #404040;
    border-color: #666;
}
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9998;
}
.nav-overlay.visible {
    display: block;
}
.nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    max-width: 85vw;
    height: 100vh;
    background: #252526;
    border-right: 1px solid #404040;
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    padding: 1rem 0;
}
.nav-drawer.visible {
    transform: translateX(0);
}
.nav-drawer a, .nav-drawer .nav-item {
    display: block;
    padding: 0.75rem 1.5rem;
    color: #e0e0e0;
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 1rem;
}
.nav-drawer a:hover, .nav-drawer .nav-item:hover {
    background: #2d2d2d;
}
.nav-drawer .nav-item.active {
    background: #007acc;
    color: white;
}
.route-page {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}
.route-page.active {
    display: flex;
}
#route-home, #route-easy {
    padding: 2rem;
    overflow: auto;
}
.home-card, .easy-card {
    max-width: 920px;
    margin: 0 auto;
    background: #2d2d2d;
    border: 1px solid #404040;
    border-radius: 8px;
    padding: 2rem;
}
.easy-card {
    max-width: 1100px;
}
.easy-card h2, .home-card h2 {
    margin-bottom: 0.5rem;
}
.easy-upload {
    font-size: 1.15rem;
    padding: 0.85rem 1.4rem;
    background: #28a745;
}
.easy-file-name {
    margin-left: 0.75rem;
    color: #ddd;
    font-size: 0.95rem;
}
.easy-choice-label {
    margin: 1.25rem 0 0.6rem;
    color: #ccc;
    font-size: 1rem;
}
.easy-presets {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
}
.easy-polarity {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}
.easy-polarity .easy-preset {
    padding: 0.6rem 0.5rem;
    font-size: 0.95rem;
}
.easy-preset {
    padding: 1rem 0.5rem;
    font-size: 1.05rem;
    border: 2px solid #555;
    background: #333;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
}
.easy-preset:hover {
    border-color: #888;
}
.easy-preset.active {
    border-color: #28a745;
    background: #1e4d32;
}
.easy-preview {
    margin-top: 1.25rem;
}
.easy-preview .pdf-trace-preview-frame {
    background: #1e1e1e;
}
.easy-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.easy-original-btn {
    padding: 0.28rem 0.7rem;
    font-size: 0.78rem;
    flex: 0 0 auto;
}
.easy-spot-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
}
.easy-spot-label {
    font-size: 0.78rem;
    color: #ddd;
    white-space: nowrap;
}
.easy-preview .pdf-trace-preview-frame img {
    width: 100%;
    height: auto;
}
.easy-preview-stack {
    position: relative;
    display: inline-block;
    width: 100%;
    line-height: 0;
}
.easy-preview .pdf-trace-preview-frame .easy-original {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    opacity: 0.62;
    display: none;
    pointer-events: none;
}
.easy-preview .pdf-trace-preview-frame .easy-original.visible {
    display: block;
}
.easy-convert {
    margin-top: 1rem;
    font-size: 1.15rem;
    padding: 0.85rem 1.4rem;
    background: #28a745;
}
@media (max-width: 720px) {
    .easy-presets {
        grid-template-columns: 1fr 1fr 1fr;
    }
}
.home-pdf-main-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-start;
}
.home-pdf-settings-col {
    flex: 1 1 280px;
    min-width: 0;
}
.home-pdf-preview-col {
    flex: 0 1 320px;
    min-width: 220px;
    max-width: 100%;
    align-self: flex-start;
    position: sticky;
    top: 1rem;
}
.home-pdf-preview-col .pdf-trace-preview-panel {
    margin-top: 0;
}
@media (max-width: 640px) {
    .home-pdf-main-row {
        flex-direction: column;
    }
    .home-pdf-preview-col {
        flex: 1 1 auto;
        width: 100%;
    }
}
.home-card h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
}
.home-card p {
    color: #aaa;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}
.pdf-trace-preview-panel {
    margin-top: 12px;
    border: 2px solid #0e639c;
    border-radius: 6px;
    overflow: hidden;
    background: #1a1a1a;
}
.pdf-trace-preview-chrome {
    padding: 6px 8px;
    background: rgba(14, 99, 156, 0.25);
    border-bottom: 1px solid #0e639c;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.pdf-trace-preview-badge {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #fff;
    background: #0e639c;
    align-self: flex-start;
    padding: 3px 8px;
    border-radius: 3px;
}
.pdf-trace-preview-status {
    font-size: 0.72rem;
    color: #bbb;
    line-height: 1.35;
}
.pdf-trace-preview-frame {
    padding: 8px;
    background: #f4f4f4;
    text-align: center;
    min-height: 160px;
}
[hidden] {
    display: none !important;
}
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible {
    outline: 2px solid #7ec8ff;
    outline-offset: 2px;
}
.route-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.route-tab {
    padding: 0.4rem 0.75rem;
    border: 1px solid #555;
    border-radius: 4px;
    background: #333;
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
}
.route-tab.active {
    border-color: #28a745;
    background: #1e4d32;
}
.easy-lead, .field-hint, .easy-preflight {
    color: #c8c8c8;
    font-size: 0.9rem;
    line-height: 1.4;
}
.easy-preflight {
    margin-top: 0.75rem;
    min-height: 1.2em;
}
.easy-card.drag-over {
    outline: 2px dashed #28a745;
    outline-offset: 4px;
    background: #243028;
}
.easy-error {
    margin-top: 0.75rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid #a33;
    border-radius: 6px;
    background: #3a2222;
    color: #ffd0d0;
}
.easy-error p {
    margin: 0 0 0.4rem 0;
}
.easy-result {
    margin-top: 0.9rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid #2e7d46;
    border-radius: 6px;
    background: #1c2b22;
}
.easy-result ul {
    margin: 0.4rem 0 0.7rem 1.1rem;
}
.easy-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.easy-result-actions a.btn {
    text-decoration: none;
    display: inline-block;
}
.easy-advanced {
    margin-top: 0.9rem;
    color: #ddd;
}
.easy-advanced summary {
    cursor: pointer;
    margin-bottom: 0.5rem;
}
.setting-field {
    margin-bottom: 0.5rem;
}
.setting-field label, .check-row, .easy-advanced label {
    display: block;
    font-size: 0.8rem;
    color: #c8c8c8;
    margin-bottom: 0.25rem;
}
.check-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin-bottom: 0.5rem;
}
.setting-field input[type="number"], .setting-field select, .easy-advanced input[type="number"], .easy-page-row select {
    width: 100%;
    padding: 0.35rem;
    background: #333;
    border: 1px solid #555;
    color: #fff;
    border-radius: 4px;
}
.setting-field input[type="range"], .easy-opacity input {
    width: 100%;
}
.potrace-controls {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    border: 1px solid #444;
    border-radius: 4px;
}
.potrace-title {
    font-size: 0.78rem;
    color: #ddd;
    margin-bottom: 0.4rem;
}
.easy-page-row, .easy-opacity {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.6rem;
    color: #c8c8c8;
    font-size: 0.85rem;
}
.easy-page-row select {
    width: auto;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}
.account-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
}
.account-form, .account-signed-in {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.account-form input {
    width: 14rem;
    padding: 0.45rem 0.6rem;
    border-radius: 4px;
    border: 1px solid #555;
    background: #1e1e1e;
    color: #e0e0e0;
    font-size: 0.9rem;
}
.account-email {
    font-size: 0.85rem;
    color: #ddd;
}
.account-status {
    margin: 0;
    font-size: 0.75rem;
    color: #bbb;
    max-width: 24rem;
    text-align: right;
}
.account-status a {
    color: #7ec8ff;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
