:root{
    color-scheme: dark;
    --bg:#0d1117;
    --panel:#161b22;
    --panel2:#0f141b;
    --text:#c9d1d9;
    --muted:#8b949e;
    --border:#30363d;
    --accent:#58a6ff;
    --danger:#f85149;
    --fx1: #7f7fff;
    --fx2: #9f6bff;
    --fx3: #ff4fd8;
    --ok:#3fb950;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
    --radius: 12px;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
    --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{ box-sizing:border-box; }
body{
    margin:0;
    font-family:var(--sans);
    background:linear-gradient(180deg, #0b1016, var(--bg));
    color:var(--text);
    height:100vh;
    display:flex;
    flex-direction:column;
    padding-bottom: 42px;
}

header{
    position:sticky;
    top:0;
    z-index:10;
    background:rgba(13,17,23,.9);
    backdrop-filter: blur(10px);
    border-bottom:1px solid var(--border);
}

.toolbar{
    display:flex;
    gap:10px;
    align-items:center;
    padding:12px 14px;
    max-width:1400px;
    margin:0 auto;
}

.title{
    display:flex;
    align-items:center;
    gap:10px;
    margin-right:auto;
    min-width: 240px;
}
.title h1{
    font-size:16px;
    margin:0;
    letter-spacing:.3px;
}
.title-inner{
    display:flex;
    flex-direction:column;
    justify-content:center;
    line-height:1.1;
}
.title .sub{
    font-size:12px;
    color:var(--muted);
}

button, .btnlike{
    appearance:none;
    border:1px solid var(--border);
    background:linear-gradient(180deg, #1b2230, #121a25);
    color:var(--text);
    padding:9px 10px;
    border-radius:10px;
    cursor:pointer;
    font-size:13px;
    display:inline-flex;
    align-items:center;
    gap:8px;
    box-shadow: 0 6px 14px rgba(0,0,0,.25);
    width: 100px;
    justify-content: center;
}
button:hover, .btnlike:hover{
    border-color:#3d4a5a;
    transform: translateY(-1px);
}
button:active, .btnlike:active{ transform: translateY(0); }

.btn-primary{
    border-color: rgba(88,166,255,.45);
    box-shadow: 0 8px 18px rgba(88,166,255,.15);
}
.btn-danger{
    border-color: rgba(248,81,73,.45);
}

.spacer{ width:10px; }

.filename{
    display:flex;
    align-items:center;
    gap:8px;
    padding:8px 10px;
    border:1px solid var(--border);
    border-radius:10px;
    background:rgba(22,27,34,.65);
}
.filename label{
    font-size:12px;
    color:var(--muted);
}
.filename input{
    width:200px;
    border:none;
    outline:none;
    background:transparent;
    color:var(--text);
    font-family:var(--mono);
    font-size:12px;
}

.status{
    display:flex;
    align-items:center;
    gap:10px;
    min-width: 260px;
    justify-content:flex-end;
}
.pill{
    font-size:12px;
    padding:5px 8px;
    border-radius:999px;
    border:1px solid var(--border);
    color:var(--muted);
    background:rgba(22,27,34,.55);
    max-width: 520px;
    overflow:hidden;
    text-overflow: ellipsis;
    white-space:nowrap;
}
.pill.ok{
    color: var(--ok);
    border-color: rgba(63,185,80,.35);
}
.pill.err{
    color: var(--danger);
    border-color: rgba(248,81,73,.35);
}

main{
    flex:1;
    display:flex;
    padding:14px;
    max-width:1400px;
    margin:0 auto;
    width:100%;
    gap:14px;
}

.panel{
    background:rgba(22,27,34,.75);
    border:1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow:hidden;
    display:flex;
    flex-direction:column;
    min-height: 0;
}

.panel-header{
    padding:10px 12px;
    border-bottom:1px solid var(--border);
    display:flex;
    align-items:center;
    justify-content:space-between;
    background: linear-gradient(180deg, rgba(15,20,27,.7), rgba(22,27,34,.2));
}
.panel-header .h{
    font-size:13px;
    color:var(--muted);
    letter-spacing:.2px;
    display:flex;
    gap:10px;
    align-items:center;
}

.left{ flex: 1.05; }
.right{ flex: 0.95; }

.content{
    padding:12px;
    overflow:auto;
    min-height:0;
}

/* Tree editor */
.node{
    border:1px solid rgba(48,54,61,.7);
    border-radius:12px;
    padding:10px;
    background:rgba(13,17,23,.35);
    margin-bottom:10px;
}
.node .row{
    display:flex;
    align-items:center;
    gap:8px;
    flex-wrap:wrap;
}
.k{
    width: 170px;
    max-width: 42vw;
    border:1px solid var(--border);
    border-radius:10px;
    background:rgba(13,17,23,.6);
    color:var(--text);
    padding:8px 10px;
    font-family:var(--mono);
    font-size:12px;
    outline:none;
}
.k:focus{ border-color: rgba(88,166,255,.55); }

select, input[type="text"].v, input[type="number"].v{
    border:1px solid var(--border);
    border-radius:10px;
    background:rgba(13,17,23,.6);
    color:var(--text);
    padding:8px 10px;
    font-family:var(--mono);
    font-size:12px;
    outline:none;
}
select:focus, .v:focus{ border-color: rgba(88,166,255,.55); }

.mini{
    padding:7px 9px;
    font-size:12px;
    border-radius:10px;
}
.mini.add{ border-color: rgba(63,185,80,.35); }
.mini.rm{ border-color: rgba(248,81,73,.35); }

.children{
    margin-top:10px;
    padding-left: 14px;
    border-left: 2px solid rgba(48,54,61,.55);
    display:flex;
    flex-direction:column;
    gap:10px;
}

.hint{
    font-size:12px;
    color:var(--muted);
    line-height:1.4;
    margin: 0 0 10px 0;
}

.CodeMirror{
    height:100%;
    font-family:var(--mono);
    font-size:12.8px;
    line-height:1.55;
    background:#0d1117;
    color:#c9d1d9;
}
.CodeMirror-gutters{
    background:#0d1117;
    border-right:1px solid #30363d;
}
.CodeMirror-linenumber{
    color:#6e7681;
}
.CodeMirror-cursor{ border-left: 1px solid #c9d1d9; }
.CodeMirror-selected{ background: rgba(56,139,253,.22) !important; }

/* Token colours approximating GitHub Dark */
.cm-s-default .cm-property{ color:#79c0ff; }
.cm-s-default .cm-string{ color:#a5d6ff; }
.cm-s-default .cm-number{ color:#d2a8ff; }
.cm-s-default .cm-atom{ color:#ff7b72; }
.cm-s-default .cm-keyword{ color:#ff7b72; }
.cm-s-default .cm-comment{ color:#8b949e; }
.cm-s-default .cm-def{ color:#c9d1d9; }
.cm-s-default .cm-bracket{ color:#c9d1d9; }
.cm-s-default .cm-error{ background: rgba(248,81,73,.20); color:#ff7b72; }

.sr{
    position:absolute; left:-9999px; width:1px; height:1px; overflow:hidden;
}

@media (max-width: 980px){
    main{ flex-direction:column; }
    .filename input{ width: 150px; }
    .status{ min-width: 180px; }
}

.footer{
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 7px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    background: rgba(13,13,18,.35);
    backdrop-filter: blur(10px);
    z-index: 50;
}

.footer-inner{
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    color: rgba(231,231,242,.70);
    font-size: 12px;
}

.footer-brand{
    font-weight: 700;
    background: linear-gradient(90deg, var(--fx1), var(--fx2), var(--fx3));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
