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

@font-face {
    font-family: "Roboto Local";
    src: url("../fonts/Roboto-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: "Roboto Local";
    src: url("../fonts/Roboto-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: "Roboto Mono Local";
    src: url("../fonts/RobotoMono-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

:root {
    --bg: #f5f0e4;
    --surface: #ede7d4;
    --surface2: #e2dac6;
    --surface3: #d4c9b0;

    --border: rgba(90, 70, 30, 0.1);
    --border2: rgba(90, 70, 30, 0.22);

    --text: #2b2014;
    --text2: #6a5536;
    --text3: #a8936a;

    --accent: #6a5536;

    --c-concept: #5a4ad4;
    --c-method: #0a9870;
    --c-model: #2272c0;
    --c-metric: #b87a08;
    --c-feature: #258a4c;
    --c-finding: #bb3828;
    --c-implication: #a83278;

    --font-ui: "Roboto Local";
    --font-mono: "Roboto Mono Local";

    --top-h: 52px;
    --bot-h: 36px;
    --panel-w: 340px;

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

html,
body {
    width: 100%;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    overflow: hidden;
}

#wrap {
    position: relative;
    width: 100vw;
    height: 100vh;
    width: 100dvw;
    height: 100dvh;
    overflow: hidden;
}

.screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transition: opacity 0.25s var(--ease-out);
}

.screen.hidden {
    display: none !important;
}

#screen-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);

    background-image: radial-gradient(
        ellipse 70% 60% at 50% 45%,
        rgba(214, 194, 156, 0.28) 0%,
        transparent 100%
    );
}

#drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 48px 56px 40px;
    border: 2px dashed var(--border2);
    border-radius: 22px;
    background: var(--surface);
    box-shadow:
        0 2px 20px rgba(90, 70, 30, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    max-width: 420px;
    width: 90%;
    text-align: center;
    transition:
        border-color 0.2s,
        background 0.2s,
        box-shadow 0.2s;
    cursor: default;
    user-select: none;
}

#drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--surface2);
    box-shadow:
        0 0 0 4px rgba(90, 74, 212, 0.1),
        0 2px 20px rgba(90, 70, 30, 0.07);
}

#drop-icon {
    width: 52px;
    height: 52px;
    color: var(--text3);
    transition: color 0.2s;
}

#drop-zone.drag-over #drop-icon {
    color: var(--accent);
}

#drop-text-block {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#drop-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    line-height: 1.3;
}

#drop-title code {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent);
    background: rgba(90, 74, 212, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
}

#drop-sub {
    font-size: 11.5px;
    color: var(--text3);
    line-height: 1.5;
}

#drop-or {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    color: var(--text3);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#drop-or::before,
#drop-or::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border2);
}

#drop-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
}

#file-btn,
#load-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 22px;
    border-radius: 10px;
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--text2);
    font-family: var(--font-ui);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition:
        background 0.15s,
        border-color 0.15s,
        color 0.15s,
        box-shadow 0.15s;
}

#file-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

#file-btn:hover,
#load-btn:hover {
    background: var(--surface3);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 3px rgba(90, 74, 212, 0.1);
}

#file-btn:active,
#load-btn:active {
    transform: translateY(1px);
}

#drop-error {
    font-size: 11px;
    color: #b83828;
    font-family: var(--font-mono);
    min-height: 1em;
    display: none;
}

#drop-error.visible {
    display: block;
}

#screen-graph {
    display: flex;
    flex-direction: column;
}

#topbar {
    flex-shrink: 0;
    min-height: var(--top-h);
    height: auto;
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border2);
    background: var(--surface);
    position: relative;
    z-index: 10;
    box-shadow: 0 1px 4px rgba(90, 70, 30, 0.06);
    gap: 12px;
    flex-wrap: wrap;
    row-gap: 6px;
}

#topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 1 auto;
    min-width: 0;
}

#logo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(90, 74, 212, 0.45);
    flex-shrink: 0;
}

#title-block {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#subtitle {
    font-size: 10.5px;
    color: var(--text3);
    font-weight: 400;
    letter-spacing: 0.03em;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#divider {
    width: 1px;
    height: 24px;
    background: var(--border2);
    margin: 0 8px;
    flex-shrink: 0;
}

#reset-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    border-radius: 8px;
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--text2);
    font-family: var(--font-ui);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
    transition:
        background 0.15s,
        border-color 0.15s,
        color 0.15s;
}

#reset-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

#reset-btn:hover {
    background: var(--surface3);
    border-color: rgba(184, 56, 40, 0.4);
    color: #bb3828;
}

#kg-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    overflow: visible;
    flex: 1 1 auto;
    min-width: 0;
}

.li {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: var(--text2);
    font-family: var(--font-ui);
    white-space: nowrap;
    padding: 3px 8px 3px 5px;
    border-radius: 20px;
    border: 1px solid var(--border2);
    background: var(--surface2);
    letter-spacing: 0.02em;
    transition:
        border-color 0.15s,
        background 0.15s,
        color 0.15s;
}

.li:hover {
    background: var(--surface3);
    color: var(--text);
}

.ld {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

#main {
    flex: 1 1 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

#kg-svg {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#kg-svg:active {
    cursor: grabbing;
}

#dp {
    position: absolute;
    top: 12px;
    right: 12px;
    width: var(--panel-w);
    height: clamp(240px, 42vh, 420px);
    max-width: calc(100% - 24px);
    max-height: calc(100% - 24px);
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 4px 24px rgba(90, 70, 30, 0.12),
        0 1px 4px rgba(90, 70, 30, 0.08),
        0 0 0 0.5px rgba(90, 70, 30, 0.04);
    opacity: 0;
    transform: translateX(16px);
    pointer-events: none;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
    z-index: 20;
}

#dp.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
}

#dp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface2);
}

#dp-header-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 0;
}

#dp-type {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-family: var(--font-mono);
    line-height: 1;
}

#dp-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    letter-spacing: -0.01em;
}

#dp-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--border2);
    background: var(--surface);
    color: var(--text2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    margin-left: 10px;
    margin-top: 2px;
    transition:
        background 0.15s,
        color 0.15s;
}

#dp-close:hover {
    background: var(--surface3);
    color: var(--text);
}

#dp-body {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--surface3) transparent;
}

#dp-body::-webkit-scrollbar {
    width: 4px;
}
#dp-body::-webkit-scrollbar-thumb {
    background: var(--surface3);
    border-radius: 4px;
}

#dp-desc {
    font-size: 12px;
    color: var(--text2);
    line-height: 1.75;
    font-family: var(--font-ui);
    font-weight: 400;
}

#dp-conns-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dp-section-title {
    font-size: 9.5px;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: var(--font-mono);
}

#dp-tags {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dp-conn {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    transition:
        border-color 0.12s,
        background 0.12s;
}

.dp-conn:hover {
    border-color: var(--border2);
    background: var(--surface3);
}

.dp-conn-line {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dp-conn-rel {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text3);
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

.dp-node-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    color: var(--text2);
    font-family: var(--font-ui);
    padding: 3px 8px 3px 6px;
    border-radius: 16px;
    border: 1px solid var(--border2);
    background: var(--surface);
    max-width: 100%;
}

.dp-node-label {
    white-space: normal;
    line-height: 1.3;
}

.dp-node-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dp-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 6px;
    background: var(--surface2);
    border: 1px solid var(--border);
    font-size: 10.5px;
    color: var(--text2);
    line-height: 1.4;
    font-family: var(--font-ui);
    transition:
        border-color 0.12s,
        background 0.12s;
}

.dp-tag:hover {
    border-color: var(--border2);
    background: var(--surface3);
}

.dp-tag-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dp-tag-dir {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text3);
    flex-shrink: 0;
}

#botbar {
    flex-shrink: 0;
    min-height: var(--bot-h);
    height: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-top: 1px solid var(--border2);
    background: var(--surface);
    box-shadow: 0 -1px 4px rgba(90, 70, 30, 0.04);
    flex-wrap: wrap;
    row-gap: 6px;
}

.hint {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: var(--text3);
    letter-spacing: 0.02em;
}

.hint kbd {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text2);
    line-height: 1.6;
}

.hint-sep {
    color: var(--text3);
    font-size: 12px;
    margin: 0 4px;
    opacity: 0.4;
}

#info-btn {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border2);
    background: var(--surface);
    color: var(--text3);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(90, 70, 30, 0.12);
    transition:
        background 0.15s,
        color 0.15s,
        border-color 0.15s,
        box-shadow 0.15s;
    z-index: 200;
}

#info-btn:hover {
    background: var(--surface2);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow:
        0 0 0 4px rgba(90, 74, 212, 0.1),
        0 2px 10px rgba(90, 70, 30, 0.12);
}

#info-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

#info-panel {
    position: fixed;
    bottom: 60px;
    right: 16px;
    width: 460px;
    max-width: calc(100vw - 32px);
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 14px;
    box-shadow:
        0 8px 40px rgba(90, 70, 30, 0.16),
        0 2px 8px rgba(90, 70, 30, 0.08);
    overflow: hidden;
    z-index: 199;
    transform-origin: bottom right;
    transition:
        opacity 0.2s var(--ease-out),
        transform 0.2s var(--ease-out);
}

#info-panel.hidden {
    display: none;
}

#info-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}

#info-panel-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
}

#info-close {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 1px solid var(--border2);
    background: var(--surface);
    color: var(--text2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition:
        background 0.15s,
        color 0.15s;
}

#info-close:hover {
    background: var(--surface3);
    color: var(--text);
}

#info-desc {
    padding: 12px 14px 4px;
    font-size: 11.5px;
    color: var(--text2);
    line-height: 1.7;
}

#info-desc code {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--accent);
    background: rgba(90, 74, 212, 0.08);
    padding: 1px 4px;
    border-radius: 3px;
}

#info-types {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 14px;
}

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

.info-label {
    font-size: 9.5px;
    color: var(--text3);
    font-family: var(--font-ui);
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.info-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.info-code {
    font-family: var(--font-mono);
    font-size: 9.5px;
    color: var(--text2);
    line-height: 1.6;
    display: block;
}

#info-template-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 5px;
    font-size: 9.5px;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: var(--font-mono);
}

#copy-btn {
    padding: 3px 10px;
    border-radius: 5px;
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--text2);
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s,
        border-color 0.15s;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#copy-btn:hover {
    background: var(--surface3);
    color: var(--accent);
    border-color: var(--accent);
}
#copy-btn.copied {
    color: #258a4c;
    border-color: #258a4c;
}

#info-template {
    margin: 0 14px 14px;
    padding: 12px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text2);
    line-height: 1.65;
    overflow-x: auto;
    white-space: pre;
    scrollbar-width: thin;
    scrollbar-color: var(--surface3) transparent;
}

#info-template::-webkit-scrollbar {
    height: 4px;
}
#info-template::-webkit-scrollbar-thumb {
    background: var(--surface3);
    border-radius: 4px;
}
