:root {
    --bg: #0b0f17;
    --panel: #121a26;
    --panel2: #0f1622;
    --border: #223049;
    --text: #e7eefc;
    --muted: #9fb0cf;
    --accent: #6df;
    --danger: #f66;
    --ok: #7f7;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--sans);
    color: var(--text);
}

.app {
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr;
}

header {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 14, 22, 0.75);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-nav .dropdown-menu {
    z-index: 1021;
}

.title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.title h1 {
    margin: 0;
    font-size: 14px;
    letter-spacing: 0.4px;
    font-weight: 700;
}
.title .sub {
    font-size: 12px;
    color: var(--muted);
}

.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

button, select, input[type="text"] {
    font: inherit;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.06s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
button:hover, select:hover, input[type="text"]:hover {
    border-color: #35507a;
    box-shadow: 0 0 0 2px rgba(109, 223, 255, 0.12);
}
button:active { transform: translateY(1px); }

.main {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 12px;
    padding: 12px;
    min-height: 0;
}

.panel {
    background: rgba(18, 26, 38, 0.75);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;height: 100%;
}

.panel .panel-head {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 14, 22, 0.5);
}

.panel .panel-head .left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.panel .panel-head .name {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.panel .panel-head .hint {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52ch;
}

.tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tab {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 22, 34, 0.6);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}
.tab.active {
    border-color: rgba(109, 223, 255, 0.55);
    box-shadow: 0 0 0 2px rgba(109, 223, 255, 0.12);
    color: var(--accent);
}

.editor-wrap {
    display: none;
    min-height: 0;
    height: 100%;
}
.editor-wrap.active { display: flex; flex-direction: column; min-height: 0;
flex: 1 1 auto;
}

textarea {
    width: 100%;
    height: 100%;
    resize: none;
    border: none;
    outline: none;
    padding: 12px;
    box-sizing: border-box;
    background: rgba(10, 14, 22, 0.65);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.35;
    min-height: 0;flex: 1 1 auto;
height: auto;
}

.meta {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: rgba(10, 14, 22, 0.5);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
}

.meta .row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(15, 22, 34, 0.6);
    font-size: 12px;
    color: var(--muted);
}
.pill b { color: var(--text); font-weight: 700; }

.preview-wrap {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 10px;
    padding: 10px 12px;flex: 1 1 auto;
overflow: auto;
}

.preview-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
}

.preview-frame-shell {
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(10, 14, 22, 0.65);
    display: flex;
    justify-content: center;
    align-items: stretch;min-height: 75vh;
}

iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.preview-frame-shell.mobile iframe {
    width: 390px;
    max-width: 100%;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.05), 0 18px 60px rgba(0,0,0,0.45);
}

details {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
details > summary {
    cursor: pointer;
    padding: 10px 12px;
    font-weight: 700;
    font-size: 12px;
    list-style: none;
}
details > summary::-webkit-details-marker { display:none; }
details .details-body {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 8px;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
}
label span { color: var(--muted); }
input[type="text"] {
    cursor: text;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(10, 14, 22, 0.65);
}

.status {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80ch;
}

.warn { color: #ffcf6d; }
.err  { color: #ff8080; }
.ok   { color: #8dffb3; }

@media (max-width: 1100px) {
    .main { grid-template-columns: 1fr; }
    .preview-frame-shell.mobile iframe { width: 100%; }
}

.preview-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 10px;
    padding: 10px 12px;
    overflow: auto;
}

.preview-frame-shell {
    flex: 1 1 auto;
    min-height: 70vh;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(10, 14, 22, 0.65);
    display: flex;
    justify-content: center;
    align-items: stretch;
}

/* sliders */
input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}