html, body, #app {
    height: 100%;
    margin: 0;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    color: #0f172a;
    background: #f8fafc;
}

.app {
    display: grid;
    grid-template-columns: 170px 1fr 280px;
    grid-template-rows: 48px 1fr 32px;
    height: 100%;
    outline: none;
}

.bar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 12px;
    background: #fff;
    border-bottom: 1px solid #cbd5e1;
}

.menu { display: flex; gap: 6px; flex-wrap: wrap; }

button, .file-btn {
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px 8px;
    font: inherit;
    cursor: pointer;
}

button:hover, .file-btn:hover { background: #dbeafe; }

.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.toolbox, .inspector {
    background: #eef2f6;
    padding: 10px;
    overflow: auto;
}

.inspector { background: #f8fafc; }

.toolbox button { display: block; width: 100%; margin-bottom: 6px; }

h3 { margin: 0 0 8px; font-size: 14px; }
h4 { margin: 12px 0 6px; font-size: 13px; }

.hint { font-size: 11px; color: #64748b; }
.legend { font-size: 11px; margin: 0; }
.legend.one { color: #0d9488; }
.legend.many { color: #2563eb; }
.legend.nn { color: #7e22ce; }

.viewport {
    position: relative;
    overflow: auto;
    background: #f5f7fa;
    border: 1px solid #cbd5e1;
    margin: 8px;
}

.world-sizer {
    position: relative;
}

.world {
    position: absolute;
    left: 0;
    top: 0;
    width: 4000px;
    height: 3000px;
    transform-origin: 0 0;
}

.zoom-tools {
    position: sticky;
    top: 8px;
    left: 8px;
    z-index: 4;
    display: flex;
    gap: 4px;
    width: max-content;
    pointer-events: none;
}

.zoom-tools button { pointer-events: auto; }

.col-add {
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
}

.col-add:hover { background: #ecfdf5; color: #0d9488; }

.origin { color: #64748b; font-size: 10px; }

.inline-rename-wrap {
    position: absolute;
    z-index: 6;
}

.inline-rename {
    width: 100%;
    font: inherit;
    font-size: 12px;
    padding: 2px 4px;
    box-sizing: border-box;
}

.suggest-wrap { position: relative; }

.suggest {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 9;
    max-height: 180px;
    overflow: auto;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
}

.suggest li {
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
}

.suggest li:hover { background: #eff6ff; }

.rel-label { font-size: 11px; font-weight: 700; pointer-events: none; }

.findings { list-style: none; padding: 0; max-height: 180px; overflow: auto; }
.findings li { padding: 6px; cursor: pointer; font-size: 12px; }
.findings li.sel { background: #dbeafe; }

.panel.wide { width: 560px; }

.links { position: absolute; left: 0; top: 0; pointer-events: none; }
.links g { pointer-events: stroke; cursor: pointer; }

.tbl {
    position: absolute;
    background: #fff;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    overflow: hidden;
    box-sizing: border-box;
    user-select: none;
}

.tbl.sel { border: 2px solid #2563af; }

.tbl.nf {
    border: 2px solid #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.28);
}

.tbl.nf .hd { background: #fecaca; color: #7f1d1d; }
.tbl.nf.sel { border-color: #dc2626; }

.nf-tip {
    position: absolute;
    z-index: 8;
    width: 260px;
    background: #fff;
    border: 1px solid #dc2626;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(127, 29, 29, 0.18);
    font-size: 12px;
    line-height: 1.35;
}

.nf-tip-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.nf-tip strong { color: #7f1d1d; }
.nf-tip-bar button { flex-shrink: 0; }
.nf-why { margin: 8px 0 4px; }
.nf-form { display: inline-block; font-weight: 700; color: #dc2626; margin-right: 4px; }
.nf-fix { margin: 0 0 8px; color: #334155; }
.nf-tip button { margin-bottom: 6px; }

.hd {
    height: 32px;
    line-height: 32px;
    padding: 0 10px;
    font-weight: 700;
    font-size: 13px;
    background: #e2e8f0;
}

.tbl.sel .hd { background: #dbeafe; }

.col {
    height: 22px;
    line-height: 22px;
    padding: 0 8px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
}

.col-sel { background: #eff6ff; }

.inspector label { display: block; font-size: 12px; margin-top: 8px; }
.inspector input, .inspector select { width: 100%; box-sizing: border-box; margin-top: 2px; padding: 4px; }
.check { display: flex; align-items: center; gap: 6px; }
.check input { width: auto; }
.row { display: flex; gap: 8px; }
.constraints { list-style: none; padding: 0; max-height: 140px; overflow: auto; }
.constraints li { padding: 4px; font-size: 12px; cursor: pointer; }
.constraints li.sel { background: #dbeafe; }

.status {
    grid-column: 1 / -1;
    padding: 6px 12px;
    background: #f1f5f9;
    font-size: 13px;
}

.rel-menu {
    position: absolute;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 5;
    min-width: 220px;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    display: grid;
    place-items: center;
    z-index: 10;
}

.panel {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    width: 420px;
    max-width: 92vw;
}

.panel select, .panel input[type=number] { width: 100%; margin: 4px 0 10px; padding: 6px; }

.loading-progress { display: none; }
