* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #fff;
    color: #000;
    padding: 20px;
}

/* Only hide overflow on desktop - allow pull-to-refresh on mobile */
@media (min-width: 769px) {
    body:has(.modal.active) {
        overflow: hidden;
    }
}

header {
    margin-bottom: 30px;
    padding-bottom: 20px;
}

header h1 {
    font-size: 24px;
    margin-bottom: 10px;
}

#stats {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

.controls {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
}

.controls label {
    color: #666;
    font-size: 14px;
}

.controls select {
    padding: 5px 10px;
    background-color: #fff;
    color: #000;
    border: 1px solid #ddd;
    cursor: pointer;
    font-size: 14px;
}

.controls select:focus {
    outline: none;
    border-color: #999;
}

#versions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 10px 0;
}

.version-card {
    background-color: #fff;
    overflow: visible;
}

.iframe-container {
    width: 100%;
    padding-bottom: 56.25%;
    position: relative;
    overflow: hidden;
    background-color: #fff;
    cursor: pointer;
}

.iframe-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 400%;
    height: 400%;
    transform: scale(0.25);
    transform-origin: 0 0;
    border: none;
}

.iframe-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.iframe-click-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: pointer;
}

.card-info {
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
}

.version-info {
    font-weight: bold;
    font-size: 14px;
    color: #000;
}

.version-info:hover {
    color: #0066ff;
}

.score-badge {
    background-color: rgba(0, 100, 255, 0.9);
    padding: 4px 8px;
    font-weight: bold;
    font-size: 12px;
}

.feedback-controls {
    padding: 15px;
    background-color: #fff;
    position: relative;
}

.feedback-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    align-items: center;
}

.feedback-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.feedback-btn svg {
    width: 24px;
    height: 24px;
    fill: #666;
    transition: fill 0.2s;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.feedback-btn:hover svg {
    fill: #999;
}

.feedback-btn.active.like svg {
    fill: #0f9960;
}

.feedback-btn.active.dislike svg {
    fill: #ff4444;
}

.nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.nav-btn svg {
    width: 24px;
    height: 24px;
    fill: #666;
    transition: fill 0.2s;
}

.nav-btn:hover:not(:disabled) svg {
    fill: #999;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.comment-box {
    min-height: 60px;
    padding: 8px;
    background-color: #fff;
    border: 0.2px solid #d3d2d2;
    color: #000;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.comment-box.hidden {
    display: none;
}

.comment-box:focus {
    outline: none;
}

/* More button dropdown */
.feedback-buttons {
    position: relative;
}

.more-dropdown {
    display: none;
    position: absolute;
    right: 0;
    bottom: 100%;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 140px;
    z-index: 200;
    overflow: hidden;
    margin-bottom: 5px;
}

.more-dropdown.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 15px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f5f5f5;
}

.dropdown-item:first-child {
    border-bottom: 1px solid #eee;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
}

.modal.active {
    display: block;
}

.modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #fff;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

.modal-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 5px;
}

.header-left .version-title {
    font-size: 18px;
    font-weight: 600;
    color: #000;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.close {
    color: #666;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

.modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar styles */
.modal-sidebar {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-right: 1px solid #e0e0e0;
    transition: width 0.2s ease;
    overflow: hidden;
    flex-shrink: 0;
}

.modal-sidebar.collapsed {
    width: 50px;
}

.modal-sidebar.expanded {
    width: 240px;
}

.sidebar-toggle-container {
    padding: 10px 7px;
    display: flex;
}

.modal-sidebar.collapsed .sidebar-toggle-container {
    justify-content: center;
}

.modal-sidebar.expanded .sidebar-toggle-container {
    justify-content: flex-end;
}

.sidebar-toggle-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.sidebar-toggle-btn:hover {
    background: #e8e8e8;
}

.sidebar-toggle-btn svg {
    width: 20px;
    height: 20px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0 7px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    gap: 12px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-item:hover {
    background: #e8e8e8;
}

.modal-sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding: 10px;
}

.sidebar-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-label {
    font-size: 14px;
    font-weight: 500;
}

.modal-sidebar.collapsed .sidebar-label {
    display: none;
}

/* Sidebar user section */
.sidebar-user-section {
    margin-top: auto;
    padding: 7px;
    position: relative;
}

.sidebar-user-btn {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    gap: 12px;
}

.sidebar-user-initial {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #9ca3af;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 400;
    flex-shrink: 0;
    line-height: 1;
    text-align: center;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-sidebar.collapsed .sidebar-user-btn {
    justify-content: center;
    padding: 8px;
}

.modal-sidebar.collapsed .sidebar-user-name {
    display: none;
}

/* User dropdown */
.sidebar-user-dropdown {
    display: none;
    position: fixed;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10001;
    min-width: 200px;
    width: 220px;
}

.sidebar-user-dropdown.show {
    display: block;
}

.sidebar-user-dropdown-header {
    padding: 12px;
}

.dropdown-user-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.dropdown-user-email {
    font-size: 12px;
    color: #666;
}

.sidebar-user-dropdown-divider {
    height: 1px;
    background: #e0e0e0;
}

.sidebar-dropdown-btn {
    width: 100%;
    padding: 12px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-dropdown-btn:hover {
    background: #f5f5f5;
}

.sidebar-dropdown-icon {
    width: 18px;
    height: 18px;
    fill: #666;
}

.sidebar-logout-btn {
    width: 100%;
    padding: 12px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.sidebar-logout-btn:hover {
    background: #f5f5f5;
}

/* Sidebar chats container */
.sidebar-chats-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 7px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.sidebar-chats-container::-webkit-scrollbar {
    width: 6px;
}

.sidebar-chats-container::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-chats-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.sidebar-chats-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.modal-sidebar.collapsed .sidebar-chats-container {
    display: none;
}

.sidebar-chats-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Chat date group */
.sidebar-chat-group {
    margin-bottom: 8px;
}

.sidebar-chat-group-title {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    padding: 8px 10px 4px 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Individual chat item */
.sidebar-chat-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    gap: 8px;
    position: relative;
}

.sidebar-chat-item:hover {
    background: #f0f0f0;
}

.sidebar-chat-item.active {
    background: #e8e8e8;
}

.sidebar-chat-item-name {
    flex: 1;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat more button */
.sidebar-chat-more-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.sidebar-chat-item:hover .sidebar-chat-more-btn {
    opacity: 1;
}

.sidebar-chat-more-btn:hover {
    background: #ddd;
}

.sidebar-chat-more-btn svg {
    width: 16px;
    height: 16px;
    fill: #666;
}

/* Chat actions dropdown */
.sidebar-chat-actions-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 120px;
    overflow: hidden;
}

.sidebar-chat-actions-dropdown.show {
    display: block;
}

.sidebar-chat-action-btn {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 13px;
    color: #333;
    cursor: pointer;
}

.sidebar-chat-action-btn:hover {
    background: #f5f5f5;
}

.sidebar-chat-action-btn.danger {
    color: #e53935;
}

.sidebar-chat-action-btn.danger:hover {
    background: #ffebee;
}

/* Rename input */
.sidebar-chat-rename-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #4CAF50;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
}

.chat-panel {
    width: 30%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, #fafafa 0%, #ffffff 100%);
    border-right: 1px solid #e5e7eb;
    overflow: visible;
    position: relative;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f9fafb;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f9fafb;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Empty state for new users */
.chat-empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 20px;
}

.chat-empty-state.hidden {
    display: none;
}

.chat-empty-state.hidden + .chat-messages {
    flex: 1;
}

.chat-empty-state h2 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 24px;
}

.example-prompts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 320px;
}

.example-prompt-btn {
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    text-align: left;
    transition: all 0.2s;
}

.example-prompt-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

.input-pointer-arrow {
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 16px solid #e53935;
    margin-top: 24px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.assistant {
    align-items: flex-start;
}

.message-bubble {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 14px;
}

.chat-message.user .message-bubble {
    background-color: #f0f0f0;
    color: #000000;
}

.chat-message.assistant .message-bubble {
    background-color: transparent;
    color: #1e293b;
    max-width: 100%;
}

.message-label {
    display: none;
}

/* Tasks in chat bubbles */
.message-bubble .chat-tasks-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-bubble .chat-task-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
}

.message-bubble .chat-task-checkbox {
    width: 18px;
    height: 18px;
    min-width: 18px;
    cursor: pointer;
    border-radius: 4px;
    border: 2px solid #d1d5db;
    appearance: none;
    -webkit-appearance: none;
    transition: all 0.2s;
    margin-top: 2px;
}

.message-bubble .chat-task-checkbox:checked {
    background: #22c55e;
    border-color: #22c55e;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3"><polyline points="20 6 9 17 4 12"></polyline></svg>');
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}

.message-bubble .chat-task-checkbox:hover {
    border-color: #9ca3af;
}

.message-bubble .chat-task-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: inherit;
    user-select: none;
}

.message-bubble .chat-task-text.done {
    text-decoration: line-through;
    opacity: 0.6;
}

.message-bubble .chat-task-summary {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 13px;
    opacity: 0.8;
}

/* Pulsing loading indicator (ChatGPT style) */
.chat-loading-pulse {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
}

.chat-loading-pulse .pulse-dot {
    width: 10px;
    height: 10px;
    background-color: #000;
    border-radius: 50%;
    animation: pulse-animation 1.2s ease-in-out infinite;
}

@keyframes pulse-animation {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
}

/* Message action buttons (like, dislike, bookmark, share) */
.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.chat-message.assistant:hover .message-actions {
    opacity: 1;
}

.msg-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.msg-action-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.msg-action-btn svg {
    width: 18px;
    height: 18px;
    fill: #888;
    transition: fill 0.2s;
}

.msg-action-btn .icon-active {
    display: none;
}

.msg-action-btn .icon-default {
    display: block;
}

.msg-action-btn.active .icon-active {
    display: block;
}

.msg-action-btn.active .icon-default {
    display: none;
}

.msg-action-btn.active.like-btn svg {
    fill: #22c55e;
}

.msg-action-btn.active.dislike-btn svg {
    fill: #ef4444;
}

.msg-action-btn.active.bookmark-btn svg {
    fill: #f59e0b;
}

.msg-action-btn.active.share-btn svg {
    fill: #3b82f6;
}

.msg-action-btn:hover svg {
    fill: #555;
}

.msg-action-btn.active:hover svg {
    opacity: 0.8;
}

.improve-submit-btn {
    margin-top: 12px;
    padding: 10px 20px;
    background-color: #007aff;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.improve-submit-btn:hover {
    background-color: #0056b3;
}

.improve-submit-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.chat-input-container {
    padding: 10px;
    margin: 10px;
    display: flex;
    gap: 10px;
    background-color: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 30px;
    overflow: visible;
}

/* Ensure dropdown menus in chat controls are not clipped */
.chat-bottom-controls {
    overflow: visible;
    position: relative;
    flex-wrap: wrap;
}

.chat-bottom-controls select {
    position: relative;
    z-index: 10;
}

/* Mobile responsive for chat bottom controls */
@media (max-width: 480px) {
    .chat-bottom-controls {
        gap: 6px !important;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .chat-bottom-controls .mode-toggle-container {
        order: 1;
    }

    .chat-bottom-controls #model-selector {
        order: 2;
        flex-shrink: 1;
        min-width: 0;
        max-width: 100px !important;
    }

    .chat-bottom-controls #build-mode-controls {
        order: 3;
    }
}

#chat-input {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 18px;
    resize: none;
    max-height: 150px;
    line-height: 1.4;
    overflow-y: hidden;
}

#chat-input:focus {
    outline: none;
}

#attach-btn {
    width: 36px;
    height: 36px;
    background-color: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

#attach-btn svg {
    width: 20px;
    height: 20px;
    fill: #000;
}

#attach-btn:hover {
    background-color: #f0f0f0;
}

#chat-send-btn {
    width: 40px;
    height: 40px;
    background-color: #0066ff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#chat-send-btn svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

#chat-send-btn:hover {
    background-color: #0066ff;
}

#chat-send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.website-panel {
    width: 70%;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.website-panel::-webkit-scrollbar {
    width: 12px;
}

.website-panel::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.website-panel::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 6px;
}

.website-panel::-webkit-scrollbar-thumb:hover {
    background: #666;
}

#modal-iframe-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    background-color: #e5e5e5;
    padding: 0;
    transition: background-color 0.3s;
}

#modal-iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: #fff;
    transition: width 0.3s, max-width 0.3s, box-shadow 0.3s;
}

/* Device view modes */
#modal-iframe-container.device-desktop {
    background-color: #fff;
    padding: 0;
}

#modal-iframe-container.device-desktop iframe {
    width: 100%;
    max-width: none;
    box-shadow: none;
}

#modal-iframe-container.device-tablet {
    background-color: #e5e5e5;
    padding: 20px;
}

#modal-iframe-container.device-tablet iframe {
    width: 768px;
    max-width: 768px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

#modal-iframe-container.device-mobile {
    background-color: #e5e5e5;
    padding: 20px;
}

#modal-iframe-container.device-mobile iframe {
    width: 375px;
    max-width: 375px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

/* Device toggle button */
.device-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.device-toggle-btn svg {
    width: 24px;
    height: 24px;
    fill: #666;
    transition: fill 0.2s;
}

.device-toggle-btn:hover {
    background-color: #f0f0f0;
}

.device-toggle-btn:hover svg {
    fill: #333;
}

.device-toggle-btn.active {
    background-color: #e0e7ff;
}

.device-toggle-btn.active svg {
    fill: #4f46e5;
}

/* Mobile Tab Bar - hidden on desktop */
.mobile-tab-bar {
    display: none;
}

/* Mobile menu button - hidden on desktop */
.mobile-menu-btn {
    display: none;
}

/* Mobile Responsive Styles */

/* Tablet breakpoint */
@media (max-width: 1024px) {
    #versions-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    .chat-panel {
        width: 35%;
    }

    .website-panel {
        width: 65%;
    }
}

/* Small tablet / large phone - TABBED INTERFACE */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    #versions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* Browse page controls - wrap and simplify */
    .controls {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
    }

    .controls label {
        font-size: 12px;
        min-width: auto;
    }

    .controls select {
        flex: 0 1 auto;
        min-width: 100px;
        padding: 8px;
        font-size: 14px;
    }

    /* Hide less essential controls on tablet */
    #columns {
        display: none !important;
    }

    .controls-divider {
        display: none;
    }

    /* Modal takes full screen */
    .modal-content {
        border-radius: 0;
    }

    /* HIDE SIDEBAR COMPLETELY ON MOBILE */
    .modal-sidebar {
        display: none !important;
    }

    /* Show mobile menu button */
    .mobile-menu-btn {
        display: flex;
        width: 36px;
        height: 36px;
        border: none;
        background: transparent;
        cursor: pointer;
        border-radius: 6px;
        align-items: center;
        justify-content: center;
        color: #333;
        margin-right: 8px;
    }

    .mobile-menu-btn:hover {
        background: #f0f0f0;
    }

    .mobile-menu-btn svg {
        width: 22px;
        height: 22px;
        fill: currentColor;
    }

    /* Mobile sidebar overlay */
    .modal-sidebar.mobile-open {
        display: flex !important;
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px !important;
        z-index: 10002;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
        animation: slideInLeft 0.2s ease;
    }

    .modal-sidebar.mobile-open .sidebar-label {
        display: block;
    }

    .modal-sidebar.mobile-open .sidebar-chats-container {
        display: flex;
    }

    .modal-sidebar.mobile-open .sidebar-toggle-container {
        justify-content: flex-end;
    }

    @keyframes slideInLeft {
        from {
            transform: translateX(-100%);
        }
        to {
            transform: translateX(0);
        }
    }

    /* Mobile sidebar backdrop */
    .mobile-sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 10001;
    }

    .mobile-sidebar-backdrop.show {
        display: block;
    }

    .modal-header {
        padding: 8px 10px;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .header-left {
        flex-wrap: nowrap;
        gap: 6px;
        flex: 1;
        min-width: 0;
    }

    .header-left .mode-toggle {
        margin-left: 0 !important;
        display: none !important;
    }

    .header-right {
        gap: 5px;
        flex-wrap: nowrap;
    }

    /* Hide non-essential header items on mobile */
    #toggleVisualEditorBtn,
    #saveEditsBtn,
    #modal-like-btn,
    #modal-dislike-btn,
    #modal-prev-btn,
    #modal-next-btn {
        display: none !important;
    }

    /* Mobile Tab Bar */
    .mobile-tab-bar {
        display: flex;
        background: #f5f5f5;
        border-bottom: 1px solid #e0e0e0;
        padding: 0;
    }

    .mobile-tab {
        flex: 1;
        padding: 12px 16px;
        border: none;
        background: transparent;
        font-size: 14px;
        font-weight: 600;
        color: #666;
        cursor: pointer;
        position: relative;
        transition: color 0.2s;
    }

    .mobile-tab.active {
        color: #007aff;
        background: #fff;
    }

    .mobile-tab.active::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: #007aff;
    }

    /* Modal body - tabbed layout */
    .modal-body {
        flex-direction: column;
        position: relative;
    }

    /* Chat panel - full screen when active */
    .chat-panel {
        width: 100% !important;
        height: 100% !important;
        flex: 1 !important;
        border-right: none;
        border-bottom: none;
        display: flex;
        flex-direction: column;
        padding-bottom: 70px; /* Space for fixed input */
    }

    /* Website panel - hidden by default on mobile */
    .website-panel {
        width: 100% !important;
        height: 100% !important;
        flex: 1 !important;
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }

    /* Show preview when tab is active */
    .modal-body.preview-active .chat-panel {
        display: none;
    }

    .modal-body.preview-active .website-panel {
        display: flex;
        position: relative;
    }

    /* Chat messages take remaining space */
    .chat-messages {
        flex: 1;
        padding: 12px 10px;
        padding-bottom: 10px;
    }

    /* Fixed input at bottom */
    .chat-input-container {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0 !important;
        padding: 10px !important;
        background: #fff;
        border-top: 1px solid #e0e0e0;
        border-radius: 0 !important;
        z-index: 1001;
    }

    /* Hide chat controls on mobile - keep it clean */
    .chat-controls {
        display: none !important;
    }

    #chat-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Feedback buttons */
    .feedback-btn, .nav-btn {
        width: 32px;
        height: 32px;
    }

    .feedback-btn svg, .nav-btn svg {
        width: 18px;
        height: 18px;
    }

    .close {
        font-size: 24px;
        padding: 0 5px;
    }
}

/* Phone breakpoint */
@media (max-width: 480px) {
    body {
        padding: 8px;
        padding-left: 0;
        padding-right: 0;
    }

    header {
        margin-bottom: 10px;
        padding: 0 8px 10px 8px;
    }

    .controls {
        padding: 0 8px;
    }

    header h1 {
        font-size: 20px;
    }

    #versions-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 0;
    }

    /* Version cards full width on mobile */
    .version-card {
        width: 100%;
        margin: 0;
    }

    .iframe-container {
        width: 100%;
        padding-bottom: 56.25%; /* 16:9 aspect ratio */
    }

    /* Mobile browse page controls - simplified grid layout */
    .controls {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        align-items: center;
    }

    .controls label {
        display: none !important;
    }

    .controls select {
        width: 100%;
        padding: 10px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 6px;
    }

    .controls .browse-btn {
        padding: 10px 12px;
        font-size: 14px;
    }

    .controls-divider {
        display: none !important;
    }

    /* Hide Rename buttons on mobile - keep + buttons */
    .browse-btn-text {
        display: none !important;
    }

    /* Hide Filter and Columns on very small screens */
    #filter,
    #columns,
    #dashboard-version-selector {
        display: none !important;
    }

    /* Modal header mobile */
    .modal-header {
        padding: 8px;
    }

    .header-left {
        gap: 5px;
    }

    #modal-version-selector {
        font-size: 12px !important;
        padding: 5px 8px !important;
        max-width: 120px;
    }

    /* Hide less essential elements */
    #chat-session-selector,
    #new-chat-btn {
        display: none !important;
    }

    /* Card styling */
    .card-info {
        padding: 8px 10px;
    }

    .version-info {
        font-size: 12px;
    }

    .feedback-controls {
        padding: 10px;
    }

    .feedback-buttons {
        gap: 10px;
    }

    /* Gallery modal mobile */
    #gallery-modal > div {
        width: 95% !important;
        margin: 2% auto !important;
        max-height: 90vh !important;
        padding: 15px !important;
    }

    #gallery-content {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    /* Attachment dropdown */
    #attach-dropdown {
        min-width: 150px !important;
    }

    #attach-dropdown button {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }

    /* Mobile tabs smaller */
    .mobile-tab {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Name editor modal mobile */
    #name-editor-modal > div {
        min-width: 90vw !important;
        margin: 0 10px;
    }

    /* Move/copy modal mobile */
    #movecopy-modal > div {
        min-width: 90vw !important;
        margin: 0 10px;
    }

    /* Bulk select on mobile */
    .bulk-checkbox {
        top: 8px !important;
        left: 8px !important;
    }

    .bulk-checkbox input {
        width: 20px !important;
        height: 20px !important;
    }
}

/* Bulk Selection Styles */
.bulk-checkbox {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 4px;
    padding: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.bulk-checkbox input {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: #2196F3;
}

.version-card {
    position: relative;
}

.version-card.bulk-selected {
    border: 3px solid #2196F3 !important;
    box-sizing: border-box;
}

/* Lasso hover state - highlight cards during drag selection */
.version-card.lasso-hover {
    outline: 2px dashed #2196F3;
    outline-offset: -2px;
}

/* In select mode, show checkboxes */
body.select-mode .bulk-checkbox {
    display: flex;
}

/* In select mode, clicking card should toggle selection, not open modal */
body.select-mode .iframe-click-overlay {
    pointer-events: none;
}

body.select-mode .version-info {
    pointer-events: none;
}

/* Bulk action buttons styling */
.bulk-action-btn {
    transition: opacity 0.2s;
}

.bulk-action-btn:hover {
    opacity: 0.9;
}

/* Settings Modal */
#settings-modal {
    display: none;
    position: fixed;
    z-index: 10002;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
}

#settings-modal .settings-modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 24px;
    border: 1px solid #ddd;
    width: 400px;
    max-width: 90%;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

#settings-modal .settings-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

#settings-modal .settings-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

#settings-modal .settings-modal-close {
    color: #666;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

#settings-modal .settings-modal-close:hover {
    color: #333;
}

#settings-modal .settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid #f0f0f0;
}

#settings-modal .settings-item:last-child {
    border-bottom: none;
}

#settings-modal .settings-item-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#settings-modal .settings-item-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

#settings-modal .settings-item-desc {
    font-size: 12px;
    color: #666;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #4CAF50;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

