:root{
    --bg:#0b0f17;
    --panel:#111827;
    --card:#0f172a;
    --muted:#94a3b8;
    --text:#e5e7eb;
    --line:#23304a;
    --accent:#60a5fa;
    --accent2:#a78bfa;
    --danger:#fb7185;
    --ok:#34d399;

    --radius:14px;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
    --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
    margin:0;
    font-family: var(--sans);
    color: var(--text);
    background: var(--bg);
}

[hidden]{ display:none !important; }

.topbar{
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(11,15,23,.92);
    border-bottom: 1px solid rgba(35,48,74,.65);
}
.topbar__inner{
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 14px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 10px;
}
.brand__title{ font-weight: 800; letter-spacing: .02em; }
.brand__sub{ font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar__actions{ display:flex; gap:10px; }

.container{
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px;
}

.layout{
    display:grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 14px;
    align-items:start;
}

.panel{
    background: rgba(17,24,39,.72);
    border: 1px solid rgba(35,48,74,.65);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: none;
}
.panel-preview{
    position: sticky;
    top: 74px;
    max-height: calc(100vh - 92px);
    overflow: auto;
}

.h2{
    margin: 0 0 10px;
    font-size: 16px;
    letter-spacing: .02em;
}
.h3{
    margin: 0;
    font-size: 14px;
    letter-spacing: .02em;
}

.card{
    background: rgba(15,23,42,.72);
    border: 1px solid rgba(35,48,74,.65);
    border-radius: var(--radius);
    padding: 12px;
    margin-top: 12px;
    box-shadow: none;
}

.cardHeaderRow{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 12px;
}
.cardHeaderRow__actions{
    display:flex;
    gap: 10px;
}

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

.field{ display:flex; flex-direction:column; gap:6px; }
.field__label{ font-size:12px; color: var(--muted); }
.field__control{
    width:100%;
    border-radius: 12px;
    border: 1px solid rgba(35,48,74,.9);
    background: rgba(11,15,23,.6);
    color: var(--text);
    padding: 10px 10px;
    outline: none;
}
.field__control:focus{
    border-color: rgba(96,165,250,.9);
    box-shadow: 0 0 0 3px rgba(96,165,250,.18);
}

.note{
    margin-top: 10px;
    border-radius: 12px;
    border: 1px dashed rgba(148,163,184,.3);
    padding: 10px;
}
.note__title{
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}
.note__pre{
    margin:0;
    white-space: pre-wrap;
    font-family: var(--mono);
    font-size: 12px;
    color: rgba(229,231,235,.9);
}

.btn{
    border: 1px solid rgba(35,48,74,.9);
    background: rgba(11,15,23,.55);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 12px;
    cursor:pointer;
}
.btn:hover{ border-color: rgba(96,165,250,.8); }
.btn[disabled]{ opacity:.5; cursor:not-allowed; }

.btn-primary{
    background: linear-gradient(135deg, rgba(96,165,250,.25), rgba(167,139,250,.22));
    border-color: rgba(96,165,250,.6);
}

.sectionHeader{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 10px;
}

.sectionsList{
    display:flex;
    flex-direction:column;
    gap: 10px;
    margin-top: 10px;
}

.sectionItem{
    border-radius: 14px;
    border: 1px solid rgba(35,48,74,.65);
    background: rgba(11,15,23,.45);
    padding: 10px;
}
.sectionRow{
    display:flex;
    align-items:center;
    gap: 10px;
}
.dragHandle{
    width: 36px;
    height: 36px;
    display:grid;
    place-items:center;
    border-radius: 12px;
    border: 1px solid rgba(35,48,74,.7);
    background: rgba(15,23,42,.7);
    user-select:none;
    touch-action:none;
    cursor: grab;
}
.dragHandle:active{ cursor: grabbing; }

.sectionMeta{
    display:flex;
    gap: 10px;
    flex: 1;
    align-items:center;
}
.sectionMeta .field{ flex: 1; }

.sectionActions{
    display:flex;
    gap: 8px;
}
.iconBtn{
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(35,48,74,.7);
    background: rgba(15,23,42,.7);
    color: var(--text);
    cursor:pointer;
}
.iconBtn:hover{ border-color: rgba(251,113,133,.7); }

.toolbar{
    display:flex;
    flex-wrap:wrap;
    gap: 8px;
    margin-top: 10px;
}
.tool{
    width: 38px;
    height: 34px;
    display:grid;
    place-items:center;
    font-family: var(--mono);
    font-size: 12px;
    border-radius: 10px;
    border: 1px solid rgba(35,48,74,.9);
    background: rgba(15,23,42,.75);
    color: var(--text);
    cursor:pointer;
}
.tool:hover{ border-color: rgba(96,165,250,.8); }

.textarea{
    width:100%;
    min-height: 120px;
    resize: vertical;
    font-family: var(--sans);
    line-height: 1.55;
}

.helper{
    margin-top: 12px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(35,48,74,.65);
    background: rgba(11,15,23,.35);
}
.helper__title{ font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.helper__text{ font-size: 12px; color: rgba(229,231,235,.86); line-height: 1.55; }

.errors{
    margin-top: 12px;
    border-radius: 12px;
    border: 1px solid rgba(251,113,133,.6);
    background: rgba(251,113,133,.08);
    padding: 10px;
}
.errors h4{
    margin:0 0 6px;
    font-size: 13px;
}
.errors ul{
    margin:0;
    padding-left: 18px;
    color: rgba(229,231,235,.92);
    font-size: 13px;
}

.outputArea{
    width:100%;
    min-height: 210px;
    resize: vertical;
    border-radius: 12px;
    border: 1px solid rgba(35,48,74,.9);
    background: rgba(11,15,23,.55);
    color: rgba(229,231,235,.95);
    padding: 10px;
    font-family: var(--mono);
    line-height: 1.5;
    margin-top: 10px;
}

.previewShell{
    border-radius: var(--radius);
    overflow:hidden;
    border: 1px solid rgba(35,48,74,.65);
    background: #0b1020;
}
.previewTop{
    display:flex;
    align-items:center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(35,48,74,.65);
    background: rgba(15,23,42,.8);
}
.dot{ width:10px; height:10px; border-radius:999px; opacity:.9; }
.dot--red{ background:#ff5f57; }
.dot--yellow{ background:#febc2e; }
.dot--green{ background:#28c840; }
.previewTitle{ margin-left: 6px; font-size: 12px; color: rgba(229,231,235,.88); }

.previewBody{
    padding: 12px;
    color: rgba(229,231,235,.95);
    font-size: 14px;
    line-height: 1.65;
}
.previewEmpty{ color: var(--muted); font-size: 13px; }

.previewBody h1{ margin: 12px 0 8px; font-size: 18px; }
.previewBody h2{ margin: 12px 0 8px; font-size: 16px; }
.previewBody p{ margin: 8px 0; }
.previewBody code{
    font-family: var(--mono);
    background: rgba(148,163,184,.14);
    padding: 1px 5px;
    border-radius: 6px;
    border: 1px solid rgba(148,163,184,.2);
}
.previewBody a{ color: var(--accent); }
.previewBody ul{ margin: 8px 0 8px 18px; }
.previewBody li{ margin: 3px 0; }
.previewBody u{ text-decoration-thickness: 2px; text-underline-offset: 3px; }

.banner{
    max-width: 1200px;
    margin: 12px auto 0;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid rgba(96,165,250,.55);
    background: rgba(96,165,250,.12);
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 10px;
}
.banner__text{ font-size: 13px; color: rgba(229,231,235,.95); }
.banner__actions{ display:flex; gap: 10px; }

.toastGlobal{
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 100;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(35,48,74,.85);
    background: rgba(15,23,42,.95);
    color: rgba(229,231,235,.95);
    font-size: 13px;
}

.siteFooter{
    max-width: 1200px;
    margin: 5px auto 0;
    padding: 8px 14px 22px;
    color: rgba(148,163,184,.9);
    font-size: 15px;
    background: transparent;
    text-align: center;
}

@media (max-width: 980px){
    .layout{ grid-template-columns: 1fr; }
    .panel-preview{ position: static; max-height: none; }
}
@media (max-width: 560px){
    .grid2{ grid-template-columns: 1fr; }
    .topbar__inner{ flex-direction: column; align-items: stretch; }
    .topbar__actions{ justify-content: stretch; }
    .topbar__actions .btn{ flex: 1; }

    .cardHeaderRow{ flex-direction: column; align-items: stretch; }
    .cardHeaderRow__actions{ justify-content: stretch; }
    .cardHeaderRow__actions .btn{ flex: 1; }
}