* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f4f6f8;
    color: #222;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: #1e293b;
    padding: 1rem 2rem;
}

header .brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.2rem;
}

main {
    flex: 1;
    max-width: 720px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1rem;
}

h1 { margin-bottom: 1rem; }

.new-form {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
}

.new-form input {
    flex: 1;
    padding: .6rem .8rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
}

.new-form button {
    padding: .6rem 1.2rem;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}

.new-form button:hover { background: #1d4ed8; }

.mindmap-list { list-style: none; }

.mindmap-list li {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .8rem 1rem;
    margin-bottom: .5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mindmap-list .meta {
    color: #64748b;
    font-size: .85rem;
}

.empty { color: #64748b; }

footer {
    text-align: center;
    padding: 1rem;
    color: #94a3b8;
}

/* --- Navigation --- */
header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-right a { color: #cbd5e1; text-decoration: none; }
.nav-right a:hover { color: #fff; }

.user-badge { color: #94a3b8; font-size: .9rem; }
.user-badge em { color: #64748b; font-style: normal; }

.link-btn {
    background: none;
    border: none;
    color: #f87171;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* --- Flash messages --- */
.flash {
    padding: .7rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* --- Auth box --- */
.auth-box {
    max-width: 380px;
    margin: 3rem auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 2rem;
}

/* --- Forms --- */
.stacked-form, .auth-box form { display: flex; flex-direction: column; gap: .5rem; }
.stacked-form label, .auth-box label { font-weight: 600; margin-top: .5rem; }
.stacked-form input, .stacked-form textarea, .stacked-form select,
.auth-box input, .grid-form input, .grid-form select, .new-form select {
    padding: .6rem .8rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}
.stacked-form button, .auth-box button, .grid-form button {
    margin-top: 1rem;
    padding: .6rem 1.2rem;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    align-self: flex-start;
}
.auth-box button { align-self: stretch; }
.stacked-form button:hover, .auth-box button:hover, .grid-form button:hover { background: #1d4ed8; }

.grid-form {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.5rem;
}
.grid-form input { flex: 1 1 160px; }
.grid-form button { margin-top: 0; }

.inline { display: inline; }
.checkbox { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }

/* --- Tables --- */
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}
.table th, .table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
.table th { background: #f8fafc; }
.table tr:last-child td { border-bottom: none; }

/* --- Buttons & badges --- */
.btn-sm {
    display: inline-block;
    padding: .25rem .6rem;
    background: #e2e8f0;
    color: #1e293b;
    border: none;
    border-radius: 5px;
    font-size: .85rem;
    text-decoration: none;
    cursor: pointer;
}
.btn-sm:hover { background: #cbd5e1; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }

.badge {
    display: inline-block;
    padding: .15rem .5rem;
    background: #e2e8f0;
    border-radius: 999px;
    font-size: .78rem;
    color: #475569;
}
.badge-superadmin { background: #fde68a; color: #92400e; }
.badge-admin      { background: #bfdbfe; color: #1e40af; }
.badge-user       { background: #e2e8f0; color: #475569; }

/* --- Misc --- */
.actions { display: flex; align-items: center; gap: .4rem; }
.mindmap-list a { color: #1e293b; text-decoration: none; }
.mindmap-list a:hover { color: #2563eb; }
.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}
.content { white-space: pre-wrap; font-family: inherit; }
h2 { margin: 1.5rem 0 .8rem; font-size: 1.15rem; }

.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; word-break: break-all; }
.badge-verified   { background: #dcfce7; color: #166534; }
.badge-unverified { background: #fef3c7; color: #92400e; }

/* --- Full-width pages (editor) --- */
main.full { max-width: none; margin: 0; padding: 0 1rem; display: flex; flex-direction: column; flex: 1; }
main.full .flash { margin-top: 1rem; }

/* --- Editor header --- */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: .8rem 0;
    gap: 1rem;
    flex-wrap: wrap;
}
.editor-header h1 { margin: 0; font-size: 1.3rem; }
.editor-toolbar { display: flex; gap: .4rem; }

/* --- Editor canvas --- */
.editor-wrap {
    position: relative;
    flex: 1;
    min-height: 65vh;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    margin-bottom: 1rem;
}
.editor-wrap:fullscreen { border: none; border-radius: 0; }

.editor-svg { width: 100%; height: 100%; min-height: 65vh; display: block; cursor: grab; }
.editor-svg.panning { cursor: grabbing; }
.editor-wrap:fullscreen .editor-svg { min-height: 100vh; }

.edge { fill: none; stroke: #cbd5e1; stroke-width: 2; }

.node { cursor: pointer; }
.node-box { fill: #fff; stroke-width: 2.5; filter: drop-shadow(0 1px 2px rgba(0,0,0,.08)); }
.node.selected .node-box { stroke-width: 4; fill: #f0f9ff; }
.node-tint { fill-opacity: .1; stroke: none; pointer-events: none; }
.node-name.centered, .node-meta.centered { text-anchor: middle; }

/* Connector ends + outgoing connection point */
.edge-out { fill: #fff; stroke: #94a3b8; stroke-width: 2; }
.edge-in { fill: #94a3b8; }
.edge-draft { stroke: #2563eb; stroke-dasharray: 6 4; pointer-events: none; }
.port { cursor: crosshair; }
.port-hit { fill: transparent; }
.port-circle { fill: #fff; stroke: #94a3b8; stroke-width: 2; }
.port:hover .port-circle { stroke: #2563eb; stroke-width: 2.5; }
.resize-handle { cursor: nwse-resize; }
.resize-handle rect { fill: #fff; stroke: #2563eb; stroke-width: 1.5; }
.resize-grip { stroke: #2563eb; stroke-width: 1.2; fill: none; pointer-events: none; }
.connecting .node.connect-no { opacity: .45; }
.connecting .node.connect-hover .node-box { stroke-width: 5; stroke: #2563eb !important; }
.connecting, .connecting .node { cursor: crosshair; }

/* Node type admin */
.shape-preview { flex: none; }
.type-form { align-items: center; }
.node-name { font-size: 14px; font-weight: 600; fill: #1e293b; dominant-baseline: middle; pointer-events: none; }
.node-meta { font-size: 11px; fill: #64748b; dominant-baseline: middle; pointer-events: none; }
.node-thumb { pointer-events: none; }
.thumb-frame { fill: none; stroke: #e2e8f0; pointer-events: none; }
.empty-hint { font-size: 15px; fill: #64748b; }

/* --- Layout mode toggle (inside canvas, also visible in fullscreen) --- */
.mode-toggle {
    position: absolute; top: .6rem; left: .6rem; z-index: 5;
    display: inline-flex; border: 1px solid #cbd5e1; border-radius: 6px;
    overflow: hidden; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.mode-toggle button {
    border: none; background: transparent; padding: .35rem .7rem;
    font-size: .85rem; cursor: pointer; color: #334155;
}
.mode-toggle button + button { border-left: 1px solid #cbd5e1; }
.mode-toggle button:hover { background: #f1f5f9; }
.mode-toggle button.active { background: #2563eb; color: #fff; }

/* Free mode: draggable nodes */
.mode-free .node.draggable { cursor: move; }
.node.dragging { cursor: grabbing; }
.node.dragging .node-box { filter: drop-shadow(0 6px 10px rgba(0,0,0,.18)); }

/* --- Node panel --- */
.node-panel {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 320px;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    box-shadow: -4px 0 12px rgba(0,0,0,.06);
    overflow-y: auto;
    padding: 1rem;
    z-index: 5;
}
.node-panel.hidden { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.panel-head h2 { margin: 0; font-size: 1.1rem; word-break: break-word; }
.panel-head .link-btn { color: #64748b; font-size: 1.4rem; line-height: 1; }

.node-panel label { display: block; font-weight: 600; font-size: .85rem; margin: .7rem 0 .2rem; }
.node-panel input[type=text], .node-panel input[type=url],
.node-panel select, .node-panel textarea {
    width: 100%;
    padding: .45rem .6rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: .92rem;
    font-family: inherit;
}
.node-panel h3 { margin: 1.1rem 0 .4rem; font-size: .95rem; border-top: 1px solid #e2e8f0; padding-top: .8rem; }
.node-panel .btn-primary {
    margin-top: .7rem;
    padding: .45rem 1rem;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.node-panel .btn-primary:hover { background: #1d4ed8; }
.panel-text { white-space: pre-wrap; font-size: .92rem; }

.img-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.img-item { position: relative; margin: 0; }
.img-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid #e2e8f0; display: block; }
.img-item button { position: absolute; top: -6px; right: -6px; padding: 0 .4rem; }

.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .25rem 0; }
.link-list a { color: #2563eb; word-break: break-all; font-size: .9rem; }
.link-add { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }

.editor-users { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .5rem; }
.panel-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.status-chip {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    color: #fff;
    font-size: .82rem;
    font-weight: 600;
    text-shadow: 0 1px 1px rgba(0,0,0,.25);
}
