:root {
    --bg: #070a12;
    --panel: #101624;
    --panel-soft: #151d2e;
    --panel-line: #253149;
    --text: #eef4ff;
    --muted: #93a4bd;
    --accent: #4f8cff;
    --accent-2: #27e0a3;
    --danger: #ff5571;
    --warning: #ffcc66;
    --shadow: 0 20px 60px rgba(0, 0, 0, .35);
    --radius: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(79, 140, 255, .20), transparent 36rem),
        radial-gradient(circle at bottom right, rgba(39, 224, 163, .12), transparent 28rem),
        var(--bg);
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell {
    height: 100vh;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 390px 1fr;
    overflow: hidden;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    border-right: 1px solid rgba(255,255,255,.08);
    background: rgba(10, 15, 26, .84);
    backdrop-filter: blur(18px);
    padding: 22px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(79, 140, 255, .75) rgba(255,255,255,.06);
}
.sidebar::-webkit-scrollbar { width: 10px; }
.sidebar::-webkit-scrollbar-track { background: rgba(255,255,255,.05); border-radius: 99px; }
.sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    border-radius: 99px;
    border: 2px solid rgba(10, 15, 26, .84);
}
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
}
.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: white;
    font-weight: 900;
    letter-spacing: -1px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 12px 30px rgba(79, 140, 255, .3);
}
.brand h1, .topbar h2 {
    margin: 0;
    font-size: 22px;
    letter-spacing: -.03em;
}
.brand p, .topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.card, .preview-card, .info-card {
    background: linear-gradient(180deg, rgba(21, 29, 46, .94), rgba(13, 18, 30, .94));
    border: 1px solid rgba(255,255,255,.08);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card { padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 14px; font-size: 15px; color: #dce8ff; }

.drop-zone {
    border: 1.5px dashed rgba(147, 164, 189, .45);
    border-radius: 16px;
    padding: 26px 18px;
    min-height: 180px;
    text-align: center;
    cursor: pointer;
    display: grid;
    place-items: center;
    gap: 6px;
    background: rgba(255,255,255,.025);
    transition: .2s ease;
    outline: none;
}
.drop-zone:hover, .drop-zone.drag-over, .drop-zone:focus {
    border-color: var(--accent);
    background: rgba(79, 140, 255, .08);
    transform: translateY(-1px);
}
.drop-icon {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: rgba(79, 140, 255, .12);
    color: var(--accent);
    font-size: 28px;
    margin-bottom: 4px;
}
.drop-zone span, .drop-zone small { color: var(--muted); }
.drop-zone small { display: block; }
.file-badge {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(39, 224, 163, .10);
    color: #bfffea;
    border: 1px solid rgba(39, 224, 163, .2);
    font-size: 13px;
    word-break: break-word;
}

label {
    display: grid;
    gap: 7px;
    color: #dbe7fb;
    font-size: 13px;
    margin-bottom: 13px;
}
select, input[type="number"] {
    width: 100%;
    color: var(--text);
    background: #0a1020;
    border: 1px solid var(--panel-line);
    border-radius: 12px;
    padding: 11px 12px;
    outline: none;
}
select:focus, input[type="number"]:focus { border-color: var(--accent); }
.range-row label { margin-bottom: 7px; display: flex; justify-content: space-between; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 8px 0 15px;
}
.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    color: #cbd8ec;
    background: rgba(255,255,255,.025);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 11px;
    padding: 9px 10px;
}
.checkbox-grid input { accent-color: var(--accent); }
.button-stack { display: grid; gap: 10px; }
.controls-note {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.08);
    color: var(--muted);
    font-size: 13px;
}
.controls-note strong { color: #dce8ff; font-size: 13px; }
.action-card {
    position: sticky;
    top: 16px;
    z-index: 3;
}
.sidebar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.action-btn {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    white-space: nowrap;
}
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 11px 15px;
    border-radius: 13px;
    border: 0;
    text-decoration: none;
    color: white;
    cursor: pointer;
    transition: .2s ease;
    font-weight: 700;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #7367ff); box-shadow: 0 12px 30px rgba(79, 140, 255, .25); }
.btn-secondary { background: linear-gradient(135deg, var(--accent-2), #13b5d9); }
.btn-ghost { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.09); }
.btn-danger { background: rgba(255, 85, 113, .14); color: #ffb6c4; border: 1px solid rgba(255, 85, 113, .28); }

.workspace {
    height: 100vh;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(147, 164, 189, .55) rgba(255,255,255,.04);
}
.workspace::-webkit-scrollbar { width: 10px; }
.workspace::-webkit-scrollbar-track { background: rgba(255,255,255,.04); }
.workspace::-webkit-scrollbar-thumb { background: rgba(147, 164, 189, .45); border-radius: 99px; }
.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 18px;
}
.topbar-copy { min-width: 0; }
.action-tools {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.preview-tools { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }

.topbar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.1);
    background: rgba(255,255,255,.06);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.topbar-toggle:hover { background: rgba(255,255,255,.11); }
.topbar-toggle input { accent-color: var(--accent); margin: 0; }
.topbar-toggle span { font-size: 13px; color: var(--text); }
.tool-btn {
    min-width: 44px;
    height: 40px;
    padding: 0 13px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.1);
    background: rgba(255,255,255,.06);
    color: var(--text);
    cursor: pointer;
}
.tool-btn:hover { background: rgba(255,255,255,.11); }

.preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    min-height: 520px;
}
.preview-grid.original-hidden {
    grid-template-columns: 1fr;
}
.preview-grid.original-hidden .original-card {
    display: none;
}
.preview-grid.original-hidden .svg-card {
    grid-column: 1 / -1;
}
.preview-card { padding: 14px; min-width: 0; }
.preview-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}
.preview-title span { color: var(--muted); font-size: 13px; }
.preview-box {
    position: relative;
    min-height: 470px;
    height: calc(100vh - 245px);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.08);
    display: grid;
    place-items: center;
    background: #070a12;
    outline: none;
}
.preview-box:focus { border-color: rgba(79, 140, 255, .65); box-shadow: 0 0 0 3px rgba(79, 140, 255, .13); }
.preview-dark { background: #070a12; }
.preview-white { background: #ffffff; }
.preview-transparent {
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, #d7dce7 25%, transparent 25%),
        linear-gradient(-45deg, #d7dce7 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d7dce7 75%),
        linear-gradient(-45deg, transparent 75%, #d7dce7 75%);
    background-size: 28px 28px;
    background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}
.checker-bg {
    background-color: #101624;
    background-image:
        linear-gradient(45deg, rgba(255,255,255,.035) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,.035) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,.035) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.035) 75%);
    background-size: 26px 26px;
    background-position: 0 0, 0 13px, 13px -13px, -13px 0;
}
.preview-box img, .preview-box object, .preview-box svg {
    max-width: 95%;
    max-height: 95%;
    display: block;
}
.pan-layer {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    cursor: grab;
    user-select: none;
    touch-action: none;
}
.pan-layer.dragging { cursor: grabbing; }
.pan-layer object, .pan-layer .inline-svg-preview {
    width: 94%;
    height: 94%;
    pointer-events: none;
    overflow: visible;
    shape-rendering: geometricPrecision;
    text-rendering: geometricPrecision;
}
.inline-svg-preview path,
.inline-svg-preview polyline,
.inline-svg-preview polygon,
.inline-svg-preview line,
.inline-svg-preview rect,
.inline-svg-preview circle,
.inline-svg-preview ellipse {
    shape-rendering: geometricPrecision;
}
.mouse-help {
    margin: -4px 0 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}
.mouse-info {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 5;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(2, 5, 12, .72);
    color: #dce8ff;
    border: 1px solid rgba(255,255,255,.12);
    backdrop-filter: blur(8px);
    font-size: 12px;
    pointer-events: none;
}
.preview-white .mouse-info, .preview-transparent .mouse-info {
    background: rgba(255, 255, 255, .82);
    color: #152033;
    border-color: rgba(21, 32, 51, .16);
}
.empty-state {
    color: var(--muted);
    padding: 20px;
    text-align: center;
    border: 1px dashed rgba(255,255,255,.12);
    border-radius: 14px;
    background: rgba(255,255,255,.025);
}
.info-panel {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-top: 18px;
}
.info-card { padding: 14px; }
.info-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 7px;
}
.info-card strong { font-size: 15px; word-break: break-word; }
.hidden { display: none !important; }

.loader {
    position: fixed;
    inset: 0;
    background: rgba(2, 5, 12, .72);
    backdrop-filter: blur(12px);
    display: grid;
    place-items: center;
    z-index: 50;
}
.loader-box {
    width: min(380px, calc(100vw - 40px));
    padding: 26px;
    border-radius: 22px;
    background: linear-gradient(180deg, #151d2e, #0c1220);
    border: 1px solid rgba(255,255,255,.1);
    box-shadow: var(--shadow);
    text-align: center;
}
.spinner {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,.14);
    border-top-color: var(--accent);
    margin: 0 auto 15px;
    animation: spin 1s linear infinite;
}
.loader-box p { color: var(--muted); margin: 8px 0 18px; }
.progress-line {
    height: 6px;
    background: rgba(255,255,255,.08);
    border-radius: 99px;
    overflow: hidden;
}
.progress-line span {
    display: block;
    width: 36%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    animation: progress 1.1s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes progress { 0% { transform: translateX(-110%); } 100% { transform: translateX(300%); } }

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: min(420px, calc(100vw - 40px));
    padding: 14px 16px;
    border-radius: 14px;
    background: #111a2c;
    color: var(--text);
    border: 1px solid rgba(255,255,255,.10);
    box-shadow: var(--shadow);
    z-index: 70;
    line-height: 1.45;
}
.toast.success { border-color: rgba(39, 224, 163, .35); }
.toast.error { border-color: rgba(255, 85, 113, .4); }
.toast.warning { border-color: rgba(255, 204, 102, .45); }

@media (max-width: 1180px) {
    .app-shell { grid-template-columns: 340px 1fr; }
    .preview-grid { grid-template-columns: 1fr; }
    .preview-box { height: 420px; min-height: 360px; }
    .info-panel { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
    .app-shell { display: block; height: auto; overflow: visible; }
    .sidebar { position: relative; height: auto; max-height: none; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.08); }
    .workspace { height: auto; padding: 16px; overflow: visible; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .preview-tools { width: 100%; justify-content: stretch; }
    .sidebar-actions { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .info-panel { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
    .sidebar { padding: 14px; }
    .info-panel { grid-template-columns: 1fr; }
    .preview-tools { width: 100%; }
    .tool-btn { flex: 1; }
    .topbar-toggle { justify-content: center; width: 100%; }
    .sidebar-actions { grid-template-columns: 1fr; }
}

.control-hint {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}
