html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    /* Prevent browser pinch-to-zoom - app handles its own pinch gestures */
    touch-action: none;
}

petri-view {
    display: block;
    width: 100%;
    height: 100vh;
    border: 1px solid #ddd;
    box-sizing: border-box;
}

.pv-root {
    position: relative;
    width: 100%;
    height: 100%;
    font-family: system-ui, Arial;
    background: #fafafa;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Prevent text selection and touch callouts during interactions */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Horizontal layout when toggled */
.pv-root.pv-layout-horizontal {
    flex-direction: row;
}

canvas.pv-canvas {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* nodes */
.pv-node {
    position: absolute;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}

/* place: outer container 72-80px, inner white circle with black stroke (r~16) */
.pv-place {
    width: 80px;
    height: 80px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.pv-place-inner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #000;
    box-shadow: none;
    box-sizing: border-box;
}

.pv-place-handle {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: transparent;
    pointer-events: auto;
    touch-action: none;
}

/* transition: 30x30 square */
.pv-transition {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid #000;
}

.pv-transition.pv-active {
    background: #62fa75;
}

.pv-transition.pv-firing {
    opacity: 0.6;
    pointer-events: none;
}

.pv-label {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #222;
    top: 100%;
    margin-top: 6px;
    pointer-events: none;
}

/* tokens: small circles inside place */
.pv-token {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    color: #000;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    padding: 0 6px;
    border: 1px solid #ccc;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    pointer-events: none;
}

.pv-token-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #000;
    box-shadow: none;
    pointer-events: none;
}

/* Token breakdown on hover */
.pv-token-breakdown {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1000;
}

.pv-token-breakdown-item {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
}

.pv-token-breakdown-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: relative;
}

.pv-token-breakdown-count {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 700;
    /* Background color is set dynamically to match token color */
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    pointer-events: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    /* Text color is set dynamically based on background color brightness */
}

.pv-inhibit {
    stroke: #c0392b;
}

.pv-weight {
    position: absolute;
    font-size: 11px;
    background: #fff;
    padding: 2px 6px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    pointer-events: none;
    border: 1px solid transparent;
}

.pv-weight-inhibit {
    font-style: italic;
}

/* Label-edit mode highlighting */
.pv-label-editable {
    outline: 3px dashed rgba(0, 120, 215, 0.6);
    cursor: pointer;
}

.pv-label-editable:hover {
    outline-color: rgba(0, 120, 215, 0.9);
}

/* Group-select mode highlighting */
.pv-group-selected {
    outline: 3px solid rgba(255, 165, 0, 0.8);
    box-shadow: 0 0 8px rgba(255, 165, 0, 0.5);
}

.pv-group-selected:hover {
    outline-color: rgba(255, 140, 0, 1);
}

/* Layout: Canvas container and JSON editor as peers */
.pv-canvas-container {
    flex: 1 1 auto;
    min-width: 200px;
    min-height: 150px;
    position: relative;
    overflow: hidden;
    background: #fafafa;
    /* Prevent default touch behaviors like scroll/zoom during pan/drag */
    touch-action: none;
}

.pv-stage {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
}

/* Divider between canvas and editor */
.pv-layout-divider {
    flex: 0 0 8px;
    background: linear-gradient(180deg, #e0e0e0 0%, #f0f0f0 50%, #e0e0e0 100%);
    cursor: row-resize;
    position: relative;
    z-index: 50;
    transition: background 0.2s;
}

.pv-layout-divider:hover,
.pv-layout-divider:active {
    background: linear-gradient(180deg, #c0c0c0 0%, #d0d0d0 50%, #c0c0c0 100%);
}

.pv-layout-divider::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 3px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

/* Horizontal divider when layout is horizontal */
.pv-root.pv-layout-horizontal .pv-layout-divider {
    background: linear-gradient(90deg, #e0e0e0 0%, #f0f0f0 50%, #e0e0e0 100%);
    cursor: col-resize;
}

.pv-root.pv-layout-horizontal .pv-layout-divider:hover,
.pv-root.pv-layout-horizontal .pv-layout-divider:active {
    background: linear-gradient(90deg, #c0c0c0 0%, #d0d0d0 50%, #c0c0c0 100%);
}

.pv-root.pv-layout-horizontal .pv-layout-divider::before {
    width: 3px;
    height: 40px;
}

/* JSON Editor as peer component */
.pv-json-editor {
    flex: 1 1 auto;
    min-width: 200px;
    min-height: 150px;
    padding: 12px;
    background: rgba(250, 250, 250, 0.98);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: auto;
    border-radius: 0;
    box-shadow: none;
    position: relative;
    z-index: 10;
}

/* Override fixed positioning when in split layout */
.pv-root .pv-json-editor {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    height: auto;
    max-height: none;
}

/* Layout toggle button */
.pv-layout-toggle {
    position: absolute;
    top: 10px;
    right: 70px;
    width: 44px;
    height: 36px;
    border-radius: 6px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    font-size: 16px;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: background 0.2s;
}

.pv-layout-toggle:hover {
    background: rgba(255, 255, 255, 1);
}

.pv-layout-toggle:active {
    background: rgba(240, 240, 240, 1);
}

/* Remove focus outline on toolbar buttons to avoid visual inconsistency */
.pv-tool:focus,
.pv-play:focus {
    outline: none;
}

/* Keep keyboard navigation accessible with visible focus for keyboard users */
.pv-tool:focus-visible,
.pv-play:focus-visible {
    outline: 2px solid rgba(42, 111, 184, 0.5);
    outline-offset: 2px;
}

/* ============================================
   ACE Editor Toolbar & Components
   ============================================ */

.pv-ace-toolbar {
    display: flex;
    gap: 6px;
    padding: 6px 4px;
    align-items: center;
    background: transparent;
}

.pv-ace-toolbar-btn {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
}

.pv-ace-editor-wrapper {
    width: 100%;
    flex: 1 1 auto;
    min-height: 120px;
    box-sizing: border-box;
    border-radius: 6px;
    border: 1px solid #ccc;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pv-ace-editor {
    width: 100%;
    flex: 1 1 auto;
    min-height: 120px;
}

/* ============================================
   Modal Overlays & Dialogs
   ============================================ */

.pv-modal-overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2147483646;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pv-modal-dialog {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pv-modal-dialog-wide {
    max-width: 700px;
    max-height: 85vh;
    overflow: auto;
}

.pv-modal-dialog-xl {
    max-width: 900px;
    max-height: 90vh;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.pv-modal-title {
    margin: 0 0 16px 0;
    font-size: 20px;
    font-weight: bold;
    color: #333;
}

.pv-modal-title-lg {
    font-size: 22px;
}

.pv-modal-description {
    margin: '0 0 16px 0';
    font-size: 14px;
    color: #666;
}

/* ============================================
   Dialog Headers
   ============================================ */

.pv-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    border-radius: 12px 12px 0 0;
}

.pv-dialog-header-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.pv-dialog-close-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: background 0.2s, color 0.2s;
}

.pv-dialog-close-icon:hover {
    background: #e0e0e0;
    color: #333;
}

.pv-dialog-close-icon:active {
    background: #d0d0d0;
}

/* ============================================
   Form Elements
   ============================================ */

.pv-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    font-family: inherit;
}

.pv-input:focus {
    outline: none;
    border-color: #2a6fb8;
}

.pv-input-mono {
    font-family: monospace;
}

.pv-input-sm {
    padding: 6px 10px;
    font-size: 13px;
}

.pv-textarea {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    font-family: monospace;
    resize: vertical;
    background: #f9f9f9;
}

.pv-textarea:focus {
    outline: none;
    border-color: #2a6fb8;
}

.pv-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    display: block;
    margin-bottom: 6px;
}

.pv-label-sm {
    font-size: 13px;
    margin-bottom: 4px;
}

/* ============================================
   Buttons
   ============================================ */

.pv-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #ddd;
    background: #f6f8fa;
    color: #333;
}

.pv-btn:hover {
    background: #e9ecef;
}

.pv-btn-primary {
    color: #fff;
    background: #2a6fb8;
    border: none;
}

.pv-btn-primary:hover {
    background: #235d9c;
}

.pv-btn-success {
    color: #fff;
    background: #28a745;
    border: none;
}

.pv-btn-success:hover {
    background: #218838;
}

.pv-btn-danger {
    color: #fff;
    background: #dc3545;
    border: none;
}

.pv-btn-danger:hover {
    background: #c82333;
}

.pv-btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.pv-btn-lg {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
}

.pv-btn-block {
    width: 100%;
}

/* ============================================
   Button Containers
   ============================================ */

.pv-btn-container {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

.pv-btn-container-center {
    justify-content: center;
}

/* ============================================
   Fallback Editor Toolbar
   ============================================ */

.pv-editor-toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.pv-editor-toolbar-btn {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
}

.pv-editor-toolbar-btn:hover {
    background: #f0f0f0;
}

.pv-editor-textarea {
    width: 100%;
    flex: 1 1 auto;
    min-height: 120px;
    font-family: monospace;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 10px;
    box-sizing: border-box;
    resize: none;
}

/* ============================================
   Open URL Dialog
   ============================================ */

.pv-url-dialog {
    max-width: 500px;
}

.pv-url-dialog-title {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.pv-headers-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    max-height: 150px;
    overflow-y: auto;
}

.pv-header-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pv-header-input {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.pv-header-remove-btn {
    padding: 6px 10px;
    font-size: 12px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    cursor: pointer;
}

.pv-header-remove-btn:hover {
    background: #f1b0b7;
}

.pv-add-header-btn {
    padding: 6px 12px;
    font-size: 12px;
    background: #e7f3ff;
    color: #0066cc;
    border: 1px solid #b3d7ff;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 16px;
}

.pv-add-header-btn:hover {
    background: #cce5ff;
}

/* ============================================
   Share Dialog
   ============================================ */

.pv-share-textarea {
    width: 100%;
    height: 60px;
    padding: 12px;
    font-size: 13px;
    font-family: monospace;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
    resize: none;
    box-sizing: border-box;
}

.pv-share-preview-container {
    text-align: center;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 6px;
    margin-bottom: 16px;
}

.pv-share-preview-img {
    max-width: 100%;
    max-height: 200px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* ============================================
   Scale Meter
   ============================================ */

.pv-scale-meter {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 160px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.94);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    user-select: none;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

.pv-scale-label {
    font-size: 12px;
    color: #333;
    line-height: 1;
}

.pv-scale-reset {
    width: 36px;
    height: 20px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    color: #333;
    margin-bottom: 4px;
    padding: 0;
}

.pv-scale-reset:hover {
    background: #f0f0f0;
    border-color: #999;
}

.pv-scale-track {
    position: relative;
    width: 10px;
    flex: 1 1 auto;
    height: 100%;
    background: #eee;
    border-radius: 6px;
    overflow: hidden;
    align-self: center;
}

.pv-scale-fill {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 10px;
    height: 0%;
    background: linear-gradient(180deg, #4A90E2, #2A6FB8);
    border-radius: 6px;
}

.pv-scale-thumb {
    position: absolute;
    left: 50%;
    transform: translate(-50%, 50%);
    bottom: 0%;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #2a6fb8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.pv-scale-legend {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #666;
}

/* ============================================
   Help Dialog
   ============================================ */

.pv-help-title {
    margin: 0 0 16px 0;
    font-size: 22px;
    font-weight: bold;
    color: #333;
}

.pv-help-content {
    font-size: 14px;
    line-height: 1.6;
    color: #444;
}

.pv-help-content h3 {
    margin: 16px 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #000;
}

.pv-help-content h4 {
    margin: 12px 0 6px 0;
    font-size: 14px;
    font-weight: 600;
}

.pv-help-content p {
    margin: 0 0 12px 0;
}

.pv-help-content ul {
    margin: 6px 0 12px 20px;
    padding: 0;
}

.pv-help-content ul ul {
    margin: 4px 0 4px 20px;
}

.pv-help-close-btn {
    display: block;
    margin: 20px auto 0;
    padding: 10px 32px;
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    background: #007bff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.pv-help-close-btn:hover {
    background: #0056b3;
}

/* ============================================
   Simulation Dialog
   ============================================ */

.pv-sim-overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2147483646;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pv-sim-dialog {
    background: #fff;
    border-radius: 12px;
    padding: 0;
    max-width: 900px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    position: relative;
}

.pv-sim-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.pv-sim-title {
    margin: 0;
    font-size: 22px;
    font-weight: bold;
    color: #333;
}

.pv-sim-close-btn {
    background: transparent;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.pv-sim-close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.pv-sim-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 0;
}

.pv-sim-description {
    margin: 0 0 20px 0;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

.pv-sim-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.pv-sim-section {
    margin-bottom: 16px;
}

.pv-sim-section-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.pv-sim-field-label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
    color: #444;
}

.pv-sim-field-input {
    width: 100%;
    padding: 6px;
    font-size: 13px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.pv-sim-field-input-mb {
    margin-bottom: 8px;
}

.pv-sim-field-input:focus {
    outline: none;
    border-color: #2a6fb8;
}

.pv-sim-variables-container {
    max-height: 150px;
    overflow: auto;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px;
    background: #fafafa;
}

.pv-sim-no-items {
    margin: 0;
    font-size: 13px;
    color: #999;
    font-style: italic;
}

.pv-sim-checkbox-wrapper {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
}

.pv-sim-checkbox {
    margin-right: 8px;
    cursor: pointer;
}

.pv-sim-checkbox-label {
    font-size: 13px;
    cursor: pointer;
    color: #444;
}

.pv-sim-rate-wrapper {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pv-sim-rate-label {
    font-size: 13px;
    color: #444;
    flex: 1;
    margin-right: 8px;
}

.pv-sim-rate-input {
    width: 80px;
    padding: 4px;
    font-size: 13px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.pv-sim-rate-input:focus {
    outline: none;
    border-color: #2a6fb8;
}

.pv-sim-plot-container {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pv-sim-plot-placeholder {
    margin: 0;
    font-size: 14px;
    color: #999;
    font-style: italic;
}

.pv-sim-buttons {
    margin-top: 20px;
    padding: 16px 24px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: #fafafa;
}

.pv-sim-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.pv-sim-btn-primary {
    color: #fff;
    background: #0366d6;
}

.pv-sim-btn-primary:hover {
    background: #0256b3;
}

.pv-sim-btn-export {
    color: #fff;
    background: #6f42c1;
}

.pv-sim-btn-export:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pv-sim-btn-secondary {
    color: #24292e;
    background: #fafbfc;
    border: 1px solid #d1d5da;
}

.pv-sim-btn-secondary:hover {
    background: #f3f4f6;
}

/* ============================================
   Layout Algorithm Dialog
   ============================================ */

.pv-layout-overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2147483646;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pv-layout-dialog {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-height: 85vh;
    overflow: auto;
}

.pv-layout-dialog-title {
    margin: 0 0 16px 0;
    font-size: 22px;
    font-weight: bold;
    color: #333;
}

.pv-layout-dialog-desc {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: #666;
}

.pv-layout-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pv-layout-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    background: #f8f9fa;
    border: 2px solid #e1e4e8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.pv-layout-option:hover {
    background: #e9ecef;
    border-color: #007bff;
}

.pv-layout-option-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.pv-layout-option-icon {
    font-size: 20px;
}

.pv-layout-option-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.pv-layout-option-desc {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.pv-layout-close-btn {
    margin-top: 20px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    background: #f3f3f3;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.pv-layout-close-btn:hover {
    background: #e0e0e0;
}

/* ============================================
   My Diagrams Dialog
   ============================================ */

.pv-diagrams-overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2147483646;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pv-diagrams-dialog {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    max-width: 800px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pv-diagrams-title {
    margin: 0 0 16px 0;
    font-size: 22px;
    font-weight: bold;
    color: #333;
}

.pv-diagrams-loading {
    padding: 20px;
    text-align: center;
    color: #666;
}

.pv-diagrams-empty {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.pv-diagrams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.pv-diagram-card {
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
}

.pv-diagram-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.pv-diagram-thumbnail {
    width: 100%;
    height: 120px;
    background: #f6f8fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pv-diagram-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.pv-diagram-info {
    padding: 12px;
}

.pv-diagram-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pv-diagram-desc {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.pv-diagram-date {
    font-size: 11px;
    color: #999;
}

.pv-diagram-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.pv-diagram-open-btn {
    flex: 1;
    padding: 6px 12px;
    font-size: 12px;
    color: #fff;
    background: #2a6fb8;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.pv-diagram-open-btn:hover {
    background: #235d9c;
}

.pv-diagram-actions {
    display: flex;
    border-top: 1px solid #e1e4e8;
}

.pv-diagram-action-btn {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
}

.pv-diagram-action-btn-open {
    color: #0366d6;
}

.pv-diagram-action-btn-open:hover {
    background: #f0f7ff;
}

.pv-diagram-action-btn-delete {
    color: #cb2431;
    border-left: 1px solid #e1e4e8;
}

.pv-diagram-action-btn-delete:hover {
    background: #fff5f5;
}

.pv-diagrams-close-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.pv-diagrams-close-btn:hover {
    background: #5a6268;
}

/* ============================================
   Edit Details Dialog
   ============================================ */

.pv-edit-dialog {
    max-width: 450px;
}

.pv-edit-dialog-title {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.pv-edit-field-label {
    font-size: 14px;
    font-weight: 500;
    color: #555;
    display: block;
    margin-bottom: 6px;
}

.pv-edit-field-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    margin-bottom: 16px;
}

.pv-edit-field-input:focus {
    outline: none;
    border-color: #2a6fb8;
}

/* Edit Remote Diagram Details Dialog */
.pv-edit-diagram-overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pv-edit-diagram-dialog {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pv-edit-diagram-title {
    margin: 0 0 16px 0;
    font-size: 22px;
    font-weight: bold;
    color: #333;
}

.pv-edit-diagram-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #24292e;
    margin-bottom: 4px;
}

.pv-edit-diagram-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.pv-edit-diagram-input:focus {
    outline: none;
    border-color: #2a6fb8;
}

.pv-edit-diagram-textarea {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    margin-bottom: 20px;
    box-sizing: border-box;
    resize: vertical;
}

.pv-edit-diagram-textarea:focus {
    outline: none;
    border-color: #2a6fb8;
}

.pv-edit-diagram-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.pv-edit-diagram-btn-cancel {
    padding: 10px 20px;
    font-size: 14px;
    background: #f6f8fa;
    color: #24292e;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.pv-edit-diagram-btn-cancel:hover {
    background: #e1e4e8;
}

.pv-edit-diagram-btn-save {
    padding: 10px 20px;
    font-size: 14px;
    background: #2ea44f;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.pv-edit-diagram-btn-save:hover {
    background: #2c974b;
}

.pv-edit-diagram-btn-save:disabled {
    background: #94d3a2;
    cursor: not-allowed;
}

/* ============================================
   Hamburger Menu
   ============================================ */

.pv-hamburger-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    font-size: 20px;
    z-index: 1300;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: background 0.2s;
}

.pv-hamburger-btn:hover {
    background: rgba(255, 255, 255, 1);
}

.pv-hamburger-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1299;
}

.pv-hamburger-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100%;
    background: #fff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 1300;
}

.pv-hamburger-header {
    padding: 16px 16px 16px 60px;
    border-bottom: 1px solid #e1e4e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.pv-hamburger-header-btn {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #586069;
}

.pv-hamburger-title {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
}

.pv-hamburger-close-btn {
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    color: #586069;
}

.pv-hamburger-content {
    padding: 8px 0;
    flex: 1 1 auto;
    overflow: auto;
}

.pv-hamburger-dropdown {
    position: absolute;
    top: 55px;
    left: 10px;
    min-width: 180px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1300;
    padding: 6px 0;
    user-select: none;
}

.pv-hamburger-separator {
    height: 1px;
    background: #e1e4e8;
    margin: 8px 0;
}

.pv-hamburger-user-info {
    padding: 10px 16px;
    font-size: 13px;
    color: #586069;
    border-bottom: 1px solid #e1e4e8;
}

/* ============================================
   Top-Right User/Login Button
   ============================================ */

.pv-top-right-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    height: 40px;
    padding: 0 16px;
    border-radius: 6px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    font-size: 14px;
    font-family: system-ui, Arial;
    z-index: 1300;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: background 0.2s;
    white-space: nowrap;
}

.pv-top-right-btn:hover {
    background: rgba(255, 255, 255, 1);
}

/* Legacy menu classes for compatibility */
.pv-menu-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    font-size: 20px;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.pv-menu-btn:hover {
    background: #fff;
}

.pv-menu-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2100;
    display: flex;
}

.pv-menu-panel {
    width: 280px;
    max-width: 80vw;
    height: 100%;
    background: #fff;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pv-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.pv-menu-header-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.pv-menu-header-btn:hover {
    background: #f0f0f0;
}

.pv-menu-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.pv-menu-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.pv-menu-close-btn:hover {
    background: #e0e0e0;
}

.pv-menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.pv-menu-backdrop {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.pv-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    color: #333;
}

.pv-menu-item:hover {
    background: #f5f5f5;
}

.pv-menu-item-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.pv-menu-separator {
    height: 1px;
    background: #eee;
    margin: 8px 16px;
}

.pv-menu-user-info {
    padding: 12px 16px;
    font-size: 13px;
    color: #666;
    background: #f9f9f9;
    border-radius: 6px;
    margin: 8px 16px;
}

/* ============================================
   Mode Toolbar
   ============================================ */

.pv-mode-menu {
    position: absolute;
    display: flex;
    flex-direction: row;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 1200;
    align-items: center;
    user-select: none;
    font-size: 14px;
}

.pv-mode-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.pv-mode-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.pv-mode-btn.pv-active {
    background: rgba(0, 0, 0, 0.1);
}

.pv-play-btn {
    width: 44px;
    height: 36px;
    border-radius: 6px;
    border: none;
    background: linear-gradient(180deg, #fff, #f3f3f3);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pv-play-btn:hover {
    background: linear-gradient(180deg, #f5f5f5, #e8e8e8);
}

/* ============================================
   Invalid Flash Animation
   ============================================ */

.pv-invalid {
    animation: pv-flash-invalid 0.35s ease;
}

@keyframes pv-flash-invalid {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.5); }
}
