* {
    box-sizing: border-box
}

:root {
    --bg: #0f1115;
    --panel: #151922;
    --panel2: #1b2130;
    --text: #e6ebf2;
    --muted: #a7b0be;
    --accent: #ef4444;
    --accent2: #dc2626;
    --border: #263041;
    --ghost: #2b3344;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, Segoe UI, Roboto, Arial, sans-serif;
    user-select: none
}

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

h2 {
    margin: 0 0 14px
}

.bar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 14px
}

.left,
.right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap
}

.btn {
    background: var(--accent);
    border: 0;
    color: #fff;
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer
}

.btn:hover {
    background: var(--accent2)
}

.ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text)
}

.pill {
    border: 1px dashed var(--accent);
    color: var(--muted);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px
}

.hint {
    color: var(--muted);
    font-size: 12px
}

.log {
    width: 100%;
    height: 120px;
    background: #0d1017;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: #cfe3ff;
    padding: 10px;
    font-family: ui-monospace, Consolas, Menlo, monospace;
    white-space: pre-wrap
}

.err {
    margin-top: 10px;
    background: #2a1b1b;
    border: 1px solid #5a2b2b;
    color: #ffb4b4;
    padding: 10px;
    border-radius: 10px;
    display: none;
    white-space: pre-wrap
}

.viewport {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    height: 60vh;
    overflow: hidden
}

.move {
    position: absolute;
    inset: 0;
    z-index: 50;
    cursor: grab;
    background: transparent
}

.move.grabbing {
    cursor: grabbing
}

#canvas {
    position: absolute;
    inset: 0
}

.grid {
    position: absolute;
    left: 0;
    top: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    grid-auto-flow: row dense;
    gap: 40px;
    padding: 20px;
    width: 3000px;
    transform-origin: 0 0;
    transition: transform .08s ease
}

.card {
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    min-width: 300px;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative
}

.card.placeholder {
    border-style: dashed;
    border-color: var(--ghost);
    opacity: .9
}

.tname {
    font-weight: 800;
    font-size: 18px
}

.fields {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.frow {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .02);
    border: 1px solid rgba(255, 255, 255, .04);
    position: relative
}

.fname {
    color: #fff
}

.fcons {
    font-style: italic;
    color: #93c5fd
}

.anchor {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, .25)
}

svg.rels {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 200
}

.rel {
    stroke: rgba(239, 68, 68, 1);
    fill: none;
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, .6));
    shape-rendering: geometricPrecision
}

.dot {
    fill: #0f1115;
    stroke: rgba(239, 68, 68, 1);
    shape-rendering: geometricPrecision
}

.gh {
    display: flex;
    align-items: center;
    gap: 10px
}

.gh img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    opacity: .8;
    transition: .2s
}

.gh img.loaded {
    opacity: 1
}

.gh a {
    color: #fff;
    text-decoration: none
}

.gh small {
    color: var(--muted)
}

.lang {
    display: flex;
    gap: 6px;
    align-items: center
}

.lang button {
    border: 1px solid var(--border);
    background: #0f121a;
    color: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer
}

.lang button.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, .25) inset
}