/* ============================================================
   YaviMind — iOS-style glass UI
   ============================================================ */
:root {
    --ink: #1c1c28;
    --ink-soft: #5a5f70;
    --ink-faint: #9aa0b0;
    --accent: #5b8cff;
    --accent2: #8a63ff;
    --glass: rgba(255, 255, 255, 0.58);
    --glass-strong: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.65);
    --shadow: 0 10px 40px rgba(30, 40, 90, 0.14);
    --radius: 22px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body {
    background: linear-gradient(160deg, #dfe7ff 0%, #f3e8ff 38%, #ffe9f2 70%, #e8fff6 100%);
}

.hidden { display: none !important; }

/* ---------- animated background orbs ---------- */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; filter: blur(70px); }
.bg-orbs i {
    position: absolute; border-radius: 50%; opacity: 0.55;
    animation: orb-float 24s ease-in-out infinite alternate;
}
.bg-orbs i:nth-child(1) { width: 46vw; height: 46vw; left: -12vw; top: -14vw; background: #9db9ff; }
.bg-orbs i:nth-child(2) { width: 38vw; height: 38vw; right: -10vw; top: 22vh;  background: #d7b3ff; animation-delay: -8s; }
.bg-orbs i:nth-child(3) { width: 42vw; height: 42vw; left: 24vw; bottom: -18vw; background: #ffc4dd; animation-delay: -16s; }
@keyframes orb-float {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(6vw, -5vh) scale(1.12); }
}

/* ---------- glass primitives ---------- */
.glass-card, .glass-panel {
    background: var(--glass);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ---------- auth ---------- */
.auth-body {
    position: relative; z-index: 1;
    height: 100%; display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
body.auth-body { display: flex; } /* verify.php uses body itself */

.auth-card, .verify-card {
    width: 100%; max-width: 400px; padding: 42px 36px;
    text-align: center; position: relative; z-index: 1;
    animation: card-in 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes card-in {
    from { opacity: 0; transform: translateY(18px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.logo-mark { font-size: 52px; line-height: 1; margin-bottom: 12px; }
.auth-card h1, .verify-card h1 { font-size: 30px; letter-spacing: -0.5px; margin-bottom: 6px; }
.sub { color: var(--ink-soft); font-size: 15px; line-height: 1.5; }
.sub.small { font-size: 12.5px; color: var(--ink-faint); margin-top: 18px; }

.seg-control {
    display: flex; margin: 26px 0 18px; padding: 4px;
    background: rgba(120, 130, 160, 0.14); border-radius: 14px;
}
.seg {
    flex: 1; border: 0; background: transparent; padding: 9px 0;
    font-size: 14px; font-weight: 600; color: var(--ink-soft);
    border-radius: 11px; cursor: pointer; transition: all 0.25s ease;
    font-family: inherit;
}
.seg.active { background: #fff; color: var(--ink); box-shadow: 0 2px 10px rgba(30, 40, 90, 0.12); }

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
    padding: 14px 18px; font-size: 15.5px; font-family: inherit;
    border: 1px solid rgba(120, 130, 160, 0.25); border-radius: 14px;
    background: rgba(255, 255, 255, 0.72); color: var(--ink);
    outline: none; transition: border 0.2s, box-shadow 0.2s;
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(91, 140, 255, 0.16); }

.btn-primary {
    display: inline-block; border: 0; cursor: pointer; text-decoration: none;
    padding: 14px 26px; font-size: 15.5px; font-weight: 600; font-family: inherit;
    color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-radius: 14px; box-shadow: 0 6px 20px rgba(107, 105, 255, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 9px 26px rgba(107, 105, 255, 0.45); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary:disabled { filter: grayscale(0.4) opacity(0.6); cursor: default; transform: none; }
.btn-primary.slim { padding: 11px 18px; font-size: 14px; }

.auth-message {
    margin-top: 16px; padding: 13px 16px; border-radius: 14px;
    font-size: 14px; line-height: 1.45; text-align: left;
    background: rgba(91, 140, 255, 0.13); color: #2d5bd7;
    animation: card-in 0.35s ease;
}
.auth-message.error { background: rgba(255, 90, 90, 0.13); color: #c0392b; }

/* ---------- app layout ---------- */
#app-screen { position: relative; z-index: 1; height: 100%; display: flex; }

#sidebar {
    position: absolute; z-index: 30; left: 14px; top: 14px; bottom: 14px;
    width: 264px; display: flex; flex-direction: column;
    padding: 16px 14px; transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s;
}
#sidebar.collapsed { transform: translateX(-300px); opacity: 0; pointer-events: none; }

.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; padding: 0 4px; }
.logo-small { font-weight: 700; font-size: 16px; letter-spacing: -0.3px; }

.map-list { flex: 1; overflow-y: auto; margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.map-item {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 12px; border-radius: 14px; cursor: pointer;
    transition: background 0.18s; border: 1px solid transparent;
}
.map-item:hover { background: rgba(255, 255, 255, 0.55); }
.map-item.active { background: rgba(255, 255, 255, 0.85); border-color: rgba(91, 140, 255, 0.35); box-shadow: 0 3px 12px rgba(30, 40, 90, 0.08); }
.map-item .m-title { flex: 1; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-item .m-date { font-size: 11px; color: var(--ink-faint); }
.map-item .m-del { border: 0; background: none; cursor: pointer; font-size: 13px; opacity: 0; transition: opacity 0.15s; padding: 2px 4px; border-radius: 6px; }
.map-item:hover .m-del { opacity: 0.55; }
.map-item .m-del:hover { opacity: 1; background: rgba(255, 90, 90, 0.15); }

.sidebar-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(120, 130, 160, 0.18); }
.user-chip { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff; font-weight: 700; font-size: 15px;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 11px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
    border: 0; background: rgba(255, 255, 255, 0.5); cursor: pointer;
    width: 32px; height: 32px; border-radius: 10px; font-size: 15px;
    color: var(--ink-soft); transition: background 0.15s; flex: none;
    font-family: inherit;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.9); }
.icon-btn.floating { position: absolute; z-index: 29; left: 14px; top: 14px; width: 44px; height: 44px; font-size: 18px; border-radius: 14px; }

#workspace { position: relative; flex: 1; }

#topbar {
    position: absolute; z-index: 20; top: 14px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 12px; padding: 8px 16px;
    border-radius: 16px; max-width: min(520px, 76vw);
}
.map-title {
    border: 0; background: transparent; outline: none; font-family: inherit;
    font-size: 16px; font-weight: 700; color: var(--ink); text-align: center;
    min-width: 60px; width: 240px; letter-spacing: -0.2px;
}
.save-status { font-size: 12px; color: var(--ink-faint); white-space: nowrap; transition: color 0.3s; }
.save-status.saving { color: var(--accent); }
.save-status.error { color: #c0392b; }

/* ---------- canvas ---------- */
#canvas {
    position: absolute; inset: 0; overflow: hidden;
    touch-action: none; cursor: grab;
}
#canvas.panning { cursor: grabbing; }
#canvas.linking { cursor: crosshair; }

#edge-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
#edge-layer path.edge {
    fill: none; stroke: rgba(90, 100, 140, 0.34); stroke-width: 2.5;
    pointer-events: stroke; cursor: pointer; transition: stroke 0.15s;
}
#edge-layer path.edge-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
#edge-layer g.selected path.edge { stroke: var(--accent); stroke-width: 3; }
.temp-edge { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 7 6; opacity: 0.85; }

#node-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

/* ---------- nodes ---------- */
.node {
    position: absolute; transform: translate(-50%, -50%);
    min-width: 90px; max-width: 240px; padding: 13px 20px;
    border-radius: 999px; text-align: center;
    background: var(--glass-strong);
    -webkit-backdrop-filter: blur(16px) saturate(170%);
    backdrop-filter: blur(16px) saturate(170%);
    border: 1.5px solid var(--glass-border);
    box-shadow: 0 6px 22px rgba(30, 40, 90, 0.13);
    cursor: grab; user-select: none;
    transition: box-shadow 0.18s ease, border-color 0.18s ease;
    animation: node-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes node-pop {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.node.dragging { cursor: grabbing; box-shadow: 0 14px 38px rgba(30, 40, 90, 0.24); transition: none; animation: none; }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(91, 140, 255, 0.22), 0 8px 26px rgba(30, 40, 90, 0.18); }
.node.link-target { border-color: #34c759; box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.28); }

.node .txt {
    display: block; font-size: 14.5px; font-weight: 600; line-height: 1.35;
    outline: none; word-break: break-word; min-height: 1em; white-space: pre-wrap;
}
.node .txt[contenteditable="true"] { cursor: text; user-select: text; }

.node .handle {
    position: absolute; right: -11px; top: 50%; transform: translateY(-50%);
    width: 22px; height: 22px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff; font-size: 14px; line-height: 21px; text-align: center;
    box-shadow: 0 3px 10px rgba(107, 105, 255, 0.4);
    opacity: 0; transform: translateY(-50%) scale(0.6);
    transition: opacity 0.18s, transform 0.18s; cursor: crosshair;
}
.node:hover .handle, .node.selected .handle { opacity: 1; transform: translateY(-50%) scale(1); }

/* node colors */
.node.c1 { background: rgba(255, 255, 255, 0.78); }
.node.c2 { background: rgba(214, 228, 255, 0.82); }
.node.c3 { background: rgba(233, 219, 255, 0.82); }
.node.c4 { background: rgba(255, 221, 235, 0.82); }
.node.c5 { background: rgba(214, 248, 226, 0.82); }
.node.c6 { background: rgba(255, 240, 209, 0.85); }

/* ---------- toolbar ---------- */
#toolbar {
    position: absolute; z-index: 20; bottom: 18px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 18px;
    max-width: 94vw; flex-wrap: wrap; justify-content: center;
}
.tool-btn {
    border: 0; background: transparent; cursor: pointer; font-family: inherit;
    font-size: 14px; font-weight: 600; color: var(--ink-soft);
    padding: 9px 13px; border-radius: 12px; transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.tool-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.75); color: var(--ink); }
.tool-btn:disabled { opacity: 0.35; cursor: default; }
.tool-btn.danger:hover:not(:disabled) { background: rgba(255, 90, 90, 0.14); color: #c0392b; }
.tool-sep { width: 1px; height: 22px; background: rgba(120, 130, 160, 0.25); margin: 0 4px; }
.zoom-label { font-size: 12.5px; color: var(--ink-faint); min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }

.color-row { display: flex; gap: 7px; padding: 0 4px; transition: opacity 0.2s; }
.color-row.disabled { opacity: 0.3; pointer-events: none; }
.dot {
    width: 21px; height: 21px; border-radius: 50%; cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.9); box-shadow: 0 2px 6px rgba(30, 40, 90, 0.18);
    transition: transform 0.15s;
}
.dot:hover { transform: scale(1.2); }
.dot.c1 { background: #ffffff; }
.dot.c2 { background: #aac6ff; }
.dot.c3 { background: #cfb0ff; }
.dot.c4 { background: #ffb7d5; }
.dot.c5 { background: #a9ecc4; }
.dot.c6 { background: #ffdf9e; }

/* ---------- share dialog ---------- */
.share-dialog {
    position: absolute; z-index: 25; top: 74px; left: 50%; transform: translateX(-50%);
    width: min(360px, 92vw); padding: 20px 22px;
    animation: card-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.share-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.share-head h3 { font-size: 17px; letter-spacing: -0.3px; }
.sub.left { text-align: left; margin-top: 2px; }
#share-form { display: flex; gap: 8px; margin: 14px 0 4px; }
#share-form input {
    flex: 1; min-width: 0; padding: 11px 14px; font-size: 14px; font-family: inherit;
    border: 1px solid rgba(120, 130, 160, 0.25); border-radius: 12px;
    background: rgba(255, 255, 255, 0.72); outline: none;
}
#share-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15); }
.share-list { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; max-height: 180px; overflow-y: auto; }
.share-row {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    border-radius: 10px; background: rgba(255, 255, 255, 0.45); font-size: 13px;
}
.share-row .s-mail { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-row .s-name { color: var(--ink-faint); font-size: 11.5px; }
.share-row .s-x { border: 0; background: none; cursor: pointer; opacity: 0.5; font-size: 12px; padding: 2px 5px; border-radius: 6px; }
.share-row .s-x:hover { opacity: 1; background: rgba(255, 90, 90, 0.15); }

.map-item .m-badge { font-size: 12px; flex: none; }
.map-item .m-owner { font-size: 10.5px; color: var(--ink-faint); }

/* ---------- empty state / toast ---------- */
.empty-state {
    position: absolute; z-index: 15; left: 50%; top: 50%; transform: translate(-50%, -50%);
    padding: 44px 48px; text-align: center;
}
.empty-state h2 { margin: 4px 0 6px; letter-spacing: -0.4px; }
.empty-state .btn-primary { margin-top: 20px; }

.toast {
    position: fixed; z-index: 100; bottom: 84px; left: 50%; transform: translateX(-50%);
    background: rgba(28, 28, 40, 0.88); color: #fff; font-size: 14px; font-weight: 500;
    padding: 12px 22px; border-radius: 999px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    animation: card-in 0.3s ease;
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
    #sidebar { width: min(78vw, 264px); }
    #topbar { max-width: 60vw; }
    .map-title { width: 140px; }
    .empty-state { padding: 32px 24px; width: 86vw; }
}
