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

/* Mobile Warning Banner */
.mobile-warning-banner {
    display: none; /* Hidden by default, shown via JavaScript */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ff8c42, #ff6b35);
    color: white;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    animation: slideDown 0.3s ease-out;
}

.warning-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    max-width: 1200px;
    margin: 0 auto;
    gap: 12px;
}

.warning-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.warning-text {
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    flex: 1;
}

.dismiss-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.dismiss-btn:hover {
    background: rgba(255,255,255,0.3);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Adjust header when banner is shown */
body.has-mobile-warning .header {
    margin-top: 48px; /* Height of the banner */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background-color: white;
    color: #333;
    padding: 0.875rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
}

.header-content {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    height: 100%;
    max-width: 100%;
    overflow: hidden;
}

.logo-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    margin-right: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.logo-link:hover {
    transform: scale(1.05);
    opacity: 0.8;
}

.logo {
    height: auto;
    width: auto;
    max-height: 22px; /* 30% smaller than 32px */
    max-width: 100%;
    display: block;
    vertical-align: middle;
}

.header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
    margin: 0;
    line-height: 1;
    color: #333;
}

.toolbar {
    background: #f8f9fb;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.toolbar-group {
    display: flex;
    gap: 0.5rem;
    margin-right: 0.5rem;
    padding-right: 0.75rem;
    border-right: 1px solid #e5e7eb;
}

.toolbar-group:last-child {
    border-right: none;
    margin-right: 0;
    padding-right: 0;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 110px;
    justify-content: center;
}

.btn-primary {
    background: #4361ee;
    color: white;
    font-weight: 600;
    border: none;
    box-shadow: 0 2px 5px rgba(67, 97, 238, 0.3);
}

.btn-primary:hover {
    background: #3a56d4;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(67, 97, 238, 0.4);
}

.icon-white {
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    margin-right: 2px;
}

.icon-bracket {
    color: #4361ee;
    font-size: 1.1rem;
    font-weight: normal;
    margin-right: 3px;
    display: inline-block;
}

.btn-secondary {
    background: white;
    color: #4a5568;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-outline {
    background: transparent;
    color: #4361ee;
    border: 1px solid #4361ee;
}

.btn-outline:hover {
    background: rgba(67, 97, 238, 0.05);
    color: #3a56d4;
    border-color: #3a56d4;
}

.btn-destructive {
    background: white;
    color: #e53e3e;
    border: 1px solid #e2e8f0;
}

.btn-destructive:hover {
    background: #fff5f5;
    color: #c53030;
    border-color: #feb2b2;
}

.workspace {
    flex: 1;
    padding: 2rem;
    overflow: auto;
    position: relative;
    width: 100%;
    height: calc(100vh - 140px); /* Account for header, toolbar, and footer */
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.canvas {
    min-height: 800px;
    width: 100%; /* Make canvas expand to full width */
    max-width: 1400px; /* Set a reasonable max-width for very large screens */
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    padding: 4rem;
    padding-left: 6rem;
    position: relative;
    overflow: auto;
    height: 100%;
    margin: 0 auto; /* Center horizontally */
}

.bar-container {
    position: absolute;
}

.bar {
    background: #4ecdc4;
    border: 3px solid #2b7a78;
    border-radius: 8px;
    min-height: 60px;
    min-width: 100px;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.2s;
    position: relative;
    z-index: 1;
}

.bar:hover {
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
    z-index: 5;
}

.bar.selected {
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.7);
    border-color: #5a67d8;
    background: #4ecdc4;
    position: relative;
    z-index: 10;
}

/* Checkmark removed
.bar.selected::after {
    content: '✓';
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #5a67d8;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
*/

.bar-label {
    position: absolute;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #2d3748;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
    min-width: 50px;
    cursor: text;
    transition: all 0.2s;
    text-align: center;
}

.bar-label.left {
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
}

.bar-label.top {
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
}

.bar-label:hover {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.bar-label.editing {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    outline: none;
}

.bar-label .delete-btn {
    position: absolute;
    right: -8px;
    top: -8px;
    width: 16px;
    height: 16px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: bold;
}

.bar-label:hover .delete-btn {
    display: flex;
}

.bar-section {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.bar-value {
    font-size: 1rem;
    font-weight: 500;
    color: #2d3748;
    background: transparent;
    border: 1px solid transparent;
    padding: 4px 8px;
    border-radius: 4px;
    min-width: 80px;
    text-align: center;
    cursor: text;
    transition: all 0.2s;
}

.bar-value:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.bar-value:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.9);
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.resize-handle {
    position: absolute;
    width: 20px;
    height: 100%;
    right: -10px;
    top: 0;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resize-handle::after {
    content: '';
    width: 4px;
    height: 30px;
    background: rgba(255,255,255,0.6);
    border-radius: 2px;
}

.split-handle {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #667eea;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 20;
}

.bar:hover .split-handle {
    opacity: 1;
}

.split-handle:hover {
    transform: translateX(-50%) scale(1.1);
}

.part-divider {
    position: absolute;
    width: 5px;
    height: 100%;
    background: #2b7a78;
    cursor: ew-resize;
    z-index: 15;
    transition: all 0.2s;
}

.part-divider:hover {
    background: #1a4d4a;
    width: 7px;
}

.part-divider .remove-btn {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 100;
    transition: transform 0.2s, background-color 0.2s;
}

.part-divider:hover .remove-btn {
    display: flex;
}

.part-divider .remove-btn:hover {
    background: #dc2626;
    transform: translateX(-50%) scale(1.1);
}

.remove-btn::before {
    content: '';
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    z-index: -1;
}

.remove-btn.active {
    display: flex;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 400px;
    width: 90%;
}

.modal h2 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.modal input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.modal input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.instructions {
    background: #edf2f7;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #4a5568;
}

.instructions h3 {
    margin-bottom: 0.5rem;
    color: #2d3748;
}

.instructions ul {
    margin-left: 1.5rem;
}

.instructions li {
    margin-bottom: 0.25rem;
}

/* Bracket styles */
.bracket-container {
    position: absolute;
    cursor: move;
    z-index: 5;
}

.bracket {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bracket-horizontal {
    height: 60px;
}

.bracket-vertical {
    width: 60px;
}

.bracket-line {
    background: #667eea;
    border-radius: 3px;
    position: absolute;
}

.bracket-horizontal .bracket-line {
    height: 4px;
}

.bracket-vertical .bracket-line {
    width: 4px;
}

.bracket-horizontal .bracket-line.main {
    width: 100%;
    top: 50%;
    transform: translateY(-50%);
}

.bracket-vertical .bracket-line.main {
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
}

.bracket-end {
    position: absolute;
    background: #667eea;
    border-radius: 3px;
}

.bracket-horizontal .bracket-end {
    width: 4px;
    height: 20px;
}

.bracket-vertical .bracket-end {
    height: 4px;
    width: 20px;
}

.bracket-horizontal .bracket-end.left {
    left: 0;
    top: calc(50% - 10px);
}

.bracket-horizontal .bracket-end.right {
    right: 0;
    top: calc(50% - 10px);
}

.bracket-vertical .bracket-end.top {
    top: 0;
    left: calc(50% - 10px);
}

.bracket-vertical .bracket-end.bottom {
    bottom: 0;
    left: calc(50% - 10px);
}

.bracket-horizontal .bracket-label {
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
}

.bracket-vertical .bracket-label {
    left: calc(100% + 2px);
    top: 50%;
    transform: translateY(-50%);
}

.bracket-resize-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #667eea;
    border-radius: 50%;
    cursor: nesw-resize;
    z-index: 10;
    transition: transform 0.2s;
}

.bracket-resize-handle:hover {
    transform: scale(1.2);
}

.bracket-horizontal .bracket-resize-handle.start {
    left: -8px;
    top: calc(50% - 8px);
    cursor: ew-resize;
}

.bracket-horizontal .bracket-resize-handle.end {
    right: -8px;
    top: calc(50% - 8px);
    cursor: ew-resize;
}

.bracket-vertical .bracket-resize-handle.start {
    top: -8px;
    left: calc(50% - 8px);
    cursor: ns-resize;
}

.bracket-vertical .bracket-resize-handle.end {
    bottom: -8px;
    left: calc(50% - 8px);
    cursor: ns-resize;
}

.bracket.selected {
    z-index: 10;
    position: relative;
}

.bracket.selected .bracket-line,
.bracket.selected .bracket-end {
    border-color: #5a67d8;
    border-width: 3px;
}

/* Checkmark removed
.bracket.selected::after {
    content: '✓';
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #5a67d8;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
*/

.bracket-value {
    font-size: 1rem;
    font-weight: 500;
    color: #2d3748;
    background: transparent;
    border: 1px solid transparent;
    padding: 4px 8px;
    border-radius: 4px;
    min-width: 80px;
    text-align: center;
    cursor: text;
    transition: all 0.2s;
}

.bracket-value:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.bracket-value:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.9);
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.bracket-end.bottom {
    bottom: 0;
    transform: translateY(50%);
}

.bracket-label {
    position: absolute;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #2d3748;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
    min-width: 60px;
    cursor: text;
    transition: all 0.2s;
    text-align: center;
}

.bracket-horizontal .bracket-label {
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
}

.bracket-vertical .bracket-label {
    left: calc(100% + 2px);
    top: 50%;
    transform: translateY(-50%);
}

/* Remove the global hiding rules */
.delete-btn, .remove-btn {
    display: none;
}

/* Override any hover effects */
/* Part divider remove button disabled */
.bar-label:hover .delete-btn {
    display: flex;
}

.remove-btn.active {
    display: flex;
}

.footer {
    text-align: center;
    padding: 1rem;
    background-color: #fafafa;
    margin-top: auto;
    width: 100%;
    position: relative;
    border-top: 1px solid #eaeaea;
}

.footer p {
    margin-bottom: 0.25rem;
    font-size: 0.65rem;
    color: #888;
    text-align: center;
    width: 100%;
    display: block;
}

.footer-link {
    color: #6b7280;
    text-decoration: none;
    font-size: 0.65rem;
    text-align: center;
    display: block;
    width: 100%;
}

.footer-link:hover {
    color: #4361ee;
    text-decoration: underline;
}

/* Text Element Styles */
.text-element-container {
    position: absolute;
    max-width: 80%;
}

.text-element {
    padding: 8px;
    min-width: 100px;
    min-height: 40px;
    cursor: move;
    position: relative;
    border: 2px solid transparent;
    border-radius: 4px;
    display: inline-block;
    max-width: 100%;
}

.text-element:hover {
    background-color: rgba(240, 240, 240, 0.5);
    border: 2px dashed #ccc;
}

.text-element.selected {
    border: 2px solid #5a67d8;
    background-color: rgba(240, 240, 240, 0.7);
}

.text-content {
    outline: none;
    min-width: 50px;
    min-height: 20px;
    padding: 4px;
    white-space: pre-wrap;
    cursor: text;
    width: 100%;
    display: block;
}

.text-content * {
    cursor: text;
}

.icon-text {
    font-family: serif;
    font-weight: bold;
    font-size: 1.1rem;
    color: #4361ee;
    margin-right: 3px;
}

/* Media Queries */
@media (max-width: 768px) {
    .canvas {
        min-width: unset; /* Remove fixed min-width */
        width: 100%;
        padding: 2rem;
        padding-left: 3rem;
    }
    
    .header {
        padding: 0.75rem 1rem;
    }
    
    .header h1 {
        font-size: 1.1rem;
    }
    
    .logo {
        max-height: 20px;
    }
    
    .toolbar {
        padding: 0.75rem 1rem;
    }
    
    .toolbar-group {
        margin-right: 0.25rem;
        padding-right: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .btn {
        min-width: 100px;
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
        min-height: 44px; /* Ensure touch-friendly size */
    }

    /* Adjust bar and bracket sizes for better touch interaction */
    .bar {
        min-height: 70px; /* Larger touch target */
    }

    .bracket-resize-handle {
        width: 24px; /* Larger touch target */
        height: 24px;
    }

    .split-handle {
        width: 36px; /* Larger touch target */
        height: 36px;
    }

    .workspace {
        padding: 1rem; /* Reduce padding on mobile */
    }
}

@media (max-width: 576px) {
    .toolbar-group {
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 0.5rem;
        margin-bottom: 0.5rem;
        width: 100%;
    }
    
    .toolbar-group:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    .btn {
        min-width: 0;
        flex: 1;
        font-size: 0.8rem;
        padding: 0.5rem; /* Ensure adequate touch target */
    }
    
    .canvas {
        padding: 1rem;
        min-width: unset;
        width: 100%;
        max-width: 100%;
    }
    
    .workspace {
        padding: 0.5rem;
    }

    /* Enhance touch targets for mobile */
    .bar-label {
        padding: 8px 12px; /* Larger touch target */
        font-size: 1rem; /* Larger text for readability */
    }

    .delete-btn, .remove-btn {
        width: 24px; /* Larger touch target */
        height: 24px;
    }

    .part-divider {
        width: 8px; /* Slightly wider for easier touch */
    }

    /* Improve text input usability on mobile */
    .text-element {
        min-width: 120px;
        min-height: 48px;
        padding: 12px;
    }

    .text-content {
        font-size: 1rem; /* Larger text for readability */
    }
}

/* Add styles for resizable text input */
.resizable-text-input {
    resize: horizontal;
    overflow: auto;
    min-width: 50px;
    max-width: 100%;
    padding: 8px 12px; /* Comfortable touch target */
    font-size: 1rem; /* Readable text size */
} 