body {
    margin: 0;
    background: rgb(255, 245, 235);          /* = COLOR_CANVAS */
    text-align: center;
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
}

#petrinetCanvas {
    background-color: rgb(255, 245, 235);    /* = COLOR_CANVAS */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* tool palette */
.palette {
    position: fixed;
    left: 8px;
    top: 80px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 4px;
    background: rgb(255, 245, 235);          /* the canvas colour */
    border: 1px solid rgba(0,0,0,0.14);
    border-radius: 9px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}
.palette button {
    position: relative;
    width: 34px; height: 34px;
    display: grid; place-items: center;
    padding: 0;
    border: 0; border-radius: 6px;
    background: transparent;
    cursor: pointer;
}
.palette button svg { fill: #1a2130; stroke: #1a2130; }
.palette button span {
    position: absolute; right: 2px; bottom: 0;
    font: 9px Arial, sans-serif; color: #8a93a3;
}
.palette button:hover { background: rgba(0,0,0,0.07); }
.palette button.on { background: #2c56c9; }
.palette button.on svg { fill: #fff; stroke: #fff; }
.palette button.on span { color: #dfe6f8; }

/* bigger targets for fingers */
@media (pointer: coarse) {
    .palette button { width: 44px; height: 44px; }
    .palette button svg { width: 24px; height: 24px; }
    .ctxmenu .item { padding: 11px 14px; font-size: 15px; }
    .ctxmenu .sw { width: 26px; height: 26px; }
    .dlg button { padding: 10px 18px; font-size: 15px; }
}

/* self-test panel */
.st-cover { position: fixed; inset: 0; z-index: 300; }
.st-panel {
    position: absolute; right: 12px; top: 12px; bottom: 36px;
    width: min(440px, calc(100vw - 24px));
    display: flex; flex-direction: column;
    padding: 14px 16px;
    background: #fff; border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    font: 13px Arial, Helvetica, sans-serif; color: #1a2130; text-align: left;
}
.st-panel h3 { margin: 0 0 6px; font-size: 16px; }
.st-sum { margin: 0 0 8px; color: #5b6577; }
.st-sum.good { color: #23804f; font-weight: bold; }
.st-sum.bad { color: #c13a25; font-weight: bold; }
.st-list { flex: 1; overflow-y: auto; margin: 0 0 10px; padding-left: 26px; }
.st-list > li { padding: 2px 0; }
.st-list > li.run { color: #2c56c9; }
.st-list > li.pass { color: #23804f; }
.st-list > li.fail { color: #c13a25; font-weight: bold; }
.st-list small { color: #9aa4b4; font-weight: normal; }
.st-list ul { margin: 2px 0 4px; padding-left: 16px; font-weight: normal; color: #7a2a1d; }
.st-panel .btns { display: flex; justify-content: flex-end; }
.st-panel button { padding: 7px 14px; border-radius: 6px; border: 1px solid #2c56c9; background: #2c56c9; color: #fff; font: inherit; cursor: pointer; }
.st-panel button:disabled { opacity: 0.4; cursor: default; }

/* in-app value entry */
.dlg label { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.dlg label span { font-weight: bold; }
.dlg input {
    font: 16px Arial, Helvetica, sans-serif;     /* 16px: no auto-zoom on iOS */
    padding: 8px 10px;
    border: 1px solid rgba(0,0,0,0.25);
    border-radius: 6px;
}

/* in-app confirmation dialog */
.dlg-back {
    position: fixed; inset: 0; z-index: 200;
    display: grid; place-items: center;
    background: rgba(20,24,32,0.28);
}
.dlg {
    min-width: 320px; max-width: 440px;
    padding: 20px 22px 16px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    font: 14px Arial, Helvetica, sans-serif;
    color: #1a2130;
    text-align: left;
}
.dlg p { margin: 0 0 18px; line-height: 1.45; }
.dlg .btns { display: flex; justify-content: flex-end; gap: 8px; }
.dlg button {
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.18);
    background: #fff;
    font: inherit;
    cursor: pointer;
}
.dlg button.ok { background: #2c56c9; border-color: #2c56c9; color: #fff; }
.dlg button:hover { filter: brightness(0.95); }
.dlg button:focus-visible { outline: 2px solid #2c56c9; outline-offset: 2px; }

/* right-click context menu */
.ctxmenu {
    position: fixed;
    z-index: 100;
    min-width: 210px;
    padding: 5px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.14);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    font: 13px Arial, Helvetica, sans-serif;
    text-align: left;
    user-select: none;
}
.ctxmenu .item {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
    padding: 6px 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    font: inherit;
    color: #1a2130;
    text-align: left;
    white-space: pre;
    cursor: pointer;
}
.ctxmenu .item kbd {
    font: 11px Arial, Helvetica, sans-serif;
    color: #8a93a3;
}
.ctxmenu .item:hover:not(:disabled), .ctxmenu .item.active:not(:disabled) {
    background: #2c56c9;
    color: #fff;
}
.ctxmenu .item:hover:not(:disabled) kbd, .ctxmenu .item.active:not(:disabled) kbd { color: #dfe6f8; }
.ctxmenu .item:disabled { color: #b4b9c2; cursor: default; }
.ctxmenu .sep { height: 1px; margin: 4px 6px; background: rgba(0,0,0,0.1); }
.ctxmenu .title {
    padding: 4px 10px 6px;
    font-size: 11px;
    color: #6b7383;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ctxmenu .swatches { display: flex; gap: 5px; padding: 6px 10px; }
.ctxmenu .sw {
    width: 16px; height: 16px; padding: 0;
    border: 1px solid rgba(0,0,0,0.25);
    border-radius: 50%;
    cursor: pointer;
}
.ctxmenu .sw:hover { transform: scale(1.2); }
.ctxmenu .sw.on { outline: 2px solid #2c56c9; outline-offset: 1px; }
