* { box-sizing: border-box; }

:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #111418;
    color: #f2f4f7;
}

button, input { font: inherit; }

.login-shell {
    width: 100vw;
    height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 25% 20%, #28313c 0, transparent 36%),
        radial-gradient(circle at 80% 75%, #2a2420 0, transparent 32%),
        #121519;
}

.login-card {
    width: min(390px, calc(100vw - 32px));
    display: grid;
    gap: 14px;
    padding: 28px;
    background: rgba(28, 32, 37, .94);
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 18px;
    box-shadow: 0 25px 80px rgba(0,0,0,.45);
}

.login-card h1 { margin: 0; }
.login-card p { margin: -6px 0 8px; color: #aeb8c4; }

.login-card label {
    display: grid;
    gap: 6px;
    color: #cbd3dc;
}

.login-card input {
    padding: 11px 12px;
    color: #fff;
    background: #101317;
    border: 1px solid #3a424c;
    border-radius: 9px;
    outline: none;
}

.login-card button {
    margin-top: 5px;
    padding: 11px;
    border: 0;
    border-radius: 9px;
    font-weight: 700;
    cursor: pointer;
}

.error {
    padding: 10px 12px;
    border-radius: 8px;
    background: #55272c;
    color: #ffd8dc;
}

#app {
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-rows: 54px 1fr;
}

.topbar {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    background: #171b20;
    border-bottom: 1px solid #303740;
    z-index: 10;
}

.brand {
    font-weight: 800;
    letter-spacing: .2px;
}

.toolbar {
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: visible;
}

.toolbar > button,
.toolbar > label,
.toolbar > a {
    flex: 0 0 auto;
}

.toolbar button,
.upload-btn,
.toolbar-link {
    border: 1px solid #3b434d;
    background: #222831;
    color: #e8edf2;
    border-radius: 8px;
    padding: 7px 10px;
    cursor: pointer;
    white-space: nowrap;
}

.toolbar button.active {
    background: #394655;
    border-color: #667689;
}

.toolbar-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.toolbar-more-btn {
    font-weight: 700;
}

.toolbar-more-menu {
    position: absolute;
    z-index: 250;
    top: calc(100% + 8px);
    right: 0;
    width: max-content;
    min-width: 220px;
    max-width: min(360px, calc(100vw - 24px));
    max-height: min(72vh, 620px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    padding: 8px;
    border: 1px solid #414b56;
    border-radius: 10px;
    background: #171c22;
    box-shadow: 0 16px 40px rgba(0,0,0,.42);
}

.toolbar-more-menu[hidden] {
    display: none !important;
}

.toolbar-more-menu > button,
.toolbar-more-menu > label,
.toolbar-more-menu > a {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    text-decoration: none;
}

#deleteSelectionBtn:not(:disabled) {
    border-color: #8b4545;
}

#deleteSelectionBtn:not(:disabled):hover {
    background: #54292d;
    border-color: #b45b61;
}

.userbox {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 14px;
}

.userbox a { color: #b9c7d6; }

.workspace {
    min-height: 0;
    display: grid;
    grid-template-columns: 236px 1fr;
}

.sidepanel {
    padding: 14px;
    overflow-y: auto;
    background: #171b20;
    border-right: 1px solid #303740;
}

.sidepanel h3 {
    margin: 7px 0 10px;
    font-size: 14px;
}

.sidepanel label {
    display: grid;
    gap: 5px;
    margin: 10px 0;
    color: #cbd3dc;
    font-size: 13px;
}

.sidepanel label.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidepanel input[type="color"] {
    width: 100%;
    height: 34px;
    border: 1px solid #3b434d;
    border-radius: 7px;
    background: #111;
}

.hint {
    color: #96a1ad;
    line-height: 1.5;
    font-size: 12px;
}

.sidepanel hr {
    border: 0;
    border-top: 1px solid #303740;
    margin: 16px 0;
}

#canvasWrap {
    min-width: 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: #d9d5cd url("/assets/default-bg.png") center / cover;
}

#canvasWrap canvas {
    display: block;
}

.status {
    position: absolute;
    right: 12px;
    bottom: 10px;
    padding: 5px 9px;
    color: #f3f5f7;
    background: rgba(15,17,20,.78);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 7px;
    font-size: 12px;
    pointer-events: none;
}

@media (max-width: 850px) {
    .workspace { grid-template-columns: 1fr; }
    .sidepanel { display: none; }
    .topbar { grid-template-columns: auto 1fr; }
    .userbox span { display: none; }
}




/* WORLD-BOARD-LAYERS-14.5 */
.layer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 14px;
}

.layer-grid button {
    min-width: 0;
    padding: 6px 7px;
    border: 1px solid #3b434d;
    border-radius: 7px;
    background: #222831;
    color: #dfe6ed;
    font-size: 12px;
    cursor: pointer;
}

.layer-grid button:hover:not(:disabled) {
    background: #2d3640;
    border-color: #53606d;
}

.layer-grid button:disabled {
    opacity: .38;
    cursor: default;
}

.layers-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    margin: 4px 0 7px;
}

.layers-head strong {
    flex: 0 0 auto;
    font-size: 13px;
}

.layers-head .hint {
    min-width: 0;
    text-align: right;
    font-size: 9px;
    line-height: 1.2;
}

.layers-list {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 4px;
    margin: 0 -4px;
    border-radius: 8px;
    background: rgba(9, 12, 15, .22);
}

.layers-empty {
    padding: 10px 8px;
    border: 1px dashed #39424b;
    border-radius: 7px;
    color: #8995a1;
    font-size: 11px;
    text-align: center;
}

.layer-row {
    min-width: 0;
    min-height: 32px;
    display: grid;
    grid-template-columns: 13px 19px minmax(0, 1fr) 25px 25px;
    align-items: center;
    gap: 3px;
    padding: 3px 4px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: #1c2228;
    transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}

.layer-row:hover {
    background: #242c34;
    border-color: #35404a;
}

.layer-row.selected {
    background: #304052;
    border-color: #5d748b;
    box-shadow: inset 2px 0 0 #8aadc9;
}

.layer-row.locked:not(.selected) {
    background: #20242a;
}

.layer-row.hidden {
    opacity: .58;
}

.layer-row.dragging {
    opacity: .34;
}

.layer-row.drag-target {
    border-color: #8aadc9;
    background: #293a49;
}

.layer-drag {
    display: grid;
    place-items: center;
    width: 13px;
    color: #6f7b87;
    font-size: 11px;
    line-height: 1;
    cursor: grab;
    user-select: none;
}

.layer-row:active .layer-drag {
    cursor: grabbing;
}

.layer-icon {
    display: grid;
    place-items: center;
    width: 19px;
    overflow: hidden;
    color: #dbe4ec;
    font-size: 13px;
    line-height: 1;
    user-select: none;
}

.layer-label {
    min-width: 0;
    width: 100%;
    padding: 4px 5px;
    overflow: hidden;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #e1e7ed;
    font: inherit;
    font-size: 11px;
    line-height: 1.25;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.layer-label:hover {
    background: rgba(255,255,255,.055);
}

.layer-row.hidden .layer-label,
.layer-row.hidden .layer-icon {
    color: #87919a;
}

.layer-mini {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #aeb9c4;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
}

.layer-mini:hover {
    background: #313a43;
    border-color: #46525e;
    color: #f0f4f7;
}

.layer-row.selected .layer-mini {
    color: #d6e5f1;
}

/* WORLD-BOARD-FLOATING-PANELS-14.3 */

/* Drzewo katalogów */
.tree-panel {
    position: absolute;
    z-index: 40;
    top: 14px;
    left: 14px;
    width: min(340px, calc(100% - 28px));
    max-height: calc(100% - 28px);

    display: flex;
    flex-direction: column;

    background: rgba(23, 27, 32, .96);
    color: #e8edf2;

    border: 1px solid #3a434d;
    border-radius: 10px;

    box-shadow:
        0 12px 32px rgba(0, 0, 0, .34),
        0 2px 8px rgba(0, 0, 0, .25);

    overflow: hidden;
    backdrop-filter: blur(8px);
}

.tree-panel[hidden] {
    display: none !important;
}

.tree-title {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;

    padding: 11px 12px;

    background: #20262d;
    border-bottom: 1px solid #343d47;
}

.tree-title > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tree-title strong {
    font-size: 14px;
}

.tree-title span {
    color: #8996a3;
    font-size: 10px;
}

.tree-title button,
.minimap-title button {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;

    padding: 0;

    border: 1px solid #454f5b;
    border-radius: 6px;

    color: #dbe3eb;
    background: #2a3139;

    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.tree-title button:hover,
.minimap-title button:hover {
    background: #3a444f;
}

.tree-status {
    flex: 0 0 auto;
    padding: 7px 12px;

    color: #9eaab6;
    background: #1a1f24;

    border-bottom: 1px solid #303841;
    font-size: 11px;
}

.tree-list {
    flex: 1 1 auto;
    min-height: 0;

    padding: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.tree-node {
    min-width: 0;
}

.tree-row {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 30px;

    padding: 3px 7px 3px calc(6px + (var(--tree-depth, 0) * 16px));

    border-radius: 6px;

    color: #d9e0e7;
    cursor: pointer;
    user-select: none;
}

.tree-row:hover {
    background: #2c343d;
}

.tree-row.active {
    background: #354657;
}

.tree-expander {
    flex: 0 0 22px;
    width: 22px;
    padding: 0;

    color: #aeb9c4;
    background: transparent;
    border: 0;

    cursor: pointer;
}

.tree-icon {
    flex: 0 0 auto;
    margin-right: 6px;
}

.tree-label {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tree-children {
    min-width: 0;
}

.tree-separator {
    margin: 7px 8px;
    border-top: 1px solid #343d47;
}


/* Minimap */
.minimap-panel {
    position: absolute;
    z-index: 35;

    right: 14px;
    bottom: 42px;

    width: 282px;

    background: rgba(23, 27, 32, .96);
    color: #e8edf2;

    border: 1px solid #3a434d;
    border-radius: 10px;

    box-shadow:
        0 12px 32px rgba(0, 0, 0, .30),
        0 2px 8px rgba(0, 0, 0, .22);

    overflow: hidden;
    backdrop-filter: blur(8px);
}

.minimap-panel[hidden] {
    display: none !important;
}

.minimap-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;

    padding: 8px 9px 8px 11px;

    color: #dbe3eb;
    background: #20262d;

    border-bottom: 1px solid #343d47;
    font-size: 12px;
    font-weight: 600;
}

#minimapCanvas {
    display: block;

    width: 260px;
    height: 170px;

    margin: 10px;

    background: #ece8df;

    border: 1px solid #444d56;
    border-radius: 5px;

    cursor: crosshair;
}


/*
 * Stabilniejsze przewijanie lewego panelu.
 */
.sidepanel {
    min-height: 0;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

