/* Maahir Studio - Responsive Accessible Styles */

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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Auth Screen */
.auth-container {
    max-width: 400px;
    margin: 10vh auto;
    padding: 2rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-container h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    margin-bottom: 1rem;
}

.auth-form input {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.switch-form {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-secondary);
}

.switch-form a {
    color: var(--primary);
    text-decoration: none;
}

.error-message {
    padding: 0.75rem;
    margin-top: 1rem;
    background: #fef2f2;
    color: var(--error);
    border-radius: var(--radius);
    display: none;
}

.error-message.show {
    display: block;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-small, .btn-icon {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border);
}

.btn-small:hover {
    background: var(--bg);
}

.btn-icon {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
}

.btn-icon:hover {
    background: var(--bg);
}

/* Dashboard */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-header h1 {
    font-size: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.role-badge {
    padding: 0.25rem 0.75rem;
    background: var(--primary);
    color: white;
    border-radius: 1rem;
    font-size: 0.875rem;
}

.dashboard-content {
    display: flex;
    height: calc(100vh - 73px);
}

.dashboard-sidebar {
    width: 250px;
    padding: 1.5rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.dashboard-main {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.welcome {
    max-width: 800px;
    margin: 0 auto;
}

.welcome h2 {
    margin-bottom: 1rem;
}

.starter-templates {
    margin-top: 3rem;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.template-card {
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.template-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.template-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

.template-name {
    font-weight: 600;
}

.project-list {
    margin-top: 1rem;
}

.project-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.project-item:hover {
    background: var(--border);
}

.project-item.active {
    background: var(--primary);
    color: white;
}

/* Editor */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.editor-content {
    display: flex;
    height: calc(100vh - 73px);
}

.editor-sidebar {
    flex: 0 0 250px;
    width: 250px;
    min-width: 250px;
    padding: 1rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.editor-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.editor-tabs {
    display: flex;
    flex-wrap: wrap;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 1rem;
}

.tab-btn.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.file-tree, .version-history {
    margin-bottom: 2rem;
}

.file-tree h3, .version-history h3 {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.file-item {
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: var(--bg);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: monospace;
    font-size: 0.875rem;
}

.file-item:hover {
    background: var(--border);
}

.file-item.active {
    background: var(--primary);
    color: white;
}

.version-item {
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: var(--bg);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.autosave-indicator {
    font-size: 0.875rem;
    color: var(--success);
}

#code-editor {
    flex: 1;
    padding: 1rem;
    border: none;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
}

#code-editor:focus {
    outline: none;
}

/* Chat */
.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.chat-message {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius);
}

.chat-message.user {
    background: var(--primary);
    color: white;
    margin-left: 2rem;
}

.chat-message.ai {
    background: var(--bg);
    margin-right: 2rem;
}

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
}

#chat-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: none;
    font-family: inherit;
}

/* Preview */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

#preview-frame {
    flex: 1;
    border: none;
    background: white;
}

/* Admin */
.admin-content {
    padding: 2rem;
}

.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.admin-tab-btn {
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.admin-tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

#users-list, #invites-list, #activity-list {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
}

.user-row, .invite-row, .activity-row {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.user-row:last-child, .invite-row:last-child, .activity-row:last-child {
    border-bottom: none;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-content, .editor-content {
        flex-direction: column;
    }
    
    .dashboard-sidebar, .editor-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .app-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .editor-actions {
        flex-wrap: wrap;
    }
}

/* Accessibility */
:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus, input:focus, textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Success/error states */
.success {
    color: var(--success);
}

.error {
    color: var(--error);
}

/* AI model selector and Model Arena */
.model-select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    max-width: 260px;
}

.arena-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.arena-controls input {
    flex: 1 1 320px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}

.arena-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    padding: 12px;
    overflow: auto;
}

.arena-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
}

.arena-card-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.arena-card pre {
    margin: 0;
    padding: 10px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
}

.arena-loading,
.arena-error {
    padding: 16px;
    color: var(--text-muted);
}

/* Email admin tab */
.email-status {
    padding: 10px 0;
    color: var(--text-muted);
}

.email-test {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}

.email-test input {
    flex: 1 1 260px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}

.email-test-result {
    min-height: 20px;
}

/* LLM Council */
.council-final {
    margin: 12px;
    padding: 14px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: var(--surface);
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 20px;
}

.council-final:empty {
    display: none;
}

.council-final h3 {
    margin: 0 0 8px 0;
    font-size: 0.85rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Runtime / Terminal / IDE */
.run-controls,
.run-url-row,
.ide-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.run-url-row input {
    flex: 1 1 300px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}

.runtime-status {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.runtime-log-header {
    padding: 10px 12px 0 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.runtime-logs {
    margin: 0;
    padding: 12px;
    min-height: 200px;
    max-height: 400px;
    overflow: auto;
    background: #0d1117;
    color: #c9d1d9;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.terminal-output {
    min-height: 300px;
    max-height: 500px;
    overflow: auto;
    padding: 12px;
    background: #0d1117;
    color: #c9d1d9;
    font-family: monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.terminal-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}

.terminal-prompt {
    font-family: monospace;
    color: var(--primary);
}

.terminal-input-row input {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-family: monospace;
}

.ide-info {
    padding: 12px;
    color: var(--text-muted);
}

/* Database tab */
.db-schema-row {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.db-schema {
    margin: 6px 0 0 0;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: pre-wrap;
    max-height: 200px;
    overflow: auto;
}

.db-query-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 12px;
}

.db-query-row textarea {
    flex: 1;
    padding: 8px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: monospace;
    resize: vertical;
}

.db-result {
    padding: 12px;
    overflow: auto;
    max-height: 400px;
}

.db-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.85rem;
}

.db-table th,
.db-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
}

.db-table th {
    background: var(--surface);
}

.db-table code {
    color: var(--primary);
}

/* Documents tab */
.doc-upload-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.doc-list {
    padding: 12px;
}

.doc-item {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    padding: 10px;
    background: var(--surface);
}

.doc-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.doc-item-head .runtime-status {
    flex: 1;
}

.doc-content {
    margin: 0 12px 12px 12px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
}

.doc-content:empty {
    display: none;
}

/* Vision tab */
.vision-query-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.vision-query-row textarea {
    flex: 1 1 300px;
    padding: 8px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    resize: vertical;
}

.vision-result {
    margin: 12px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 40px;
}

/* QA / Browser tab */
.qa-report {
    padding: 12px;
}

.qa-check {
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.9rem;
}

.qa-check.ok {
    border-color: #2ea043;
    background: rgba(46, 160, 67, 0.1);
}

.qa-check.fail {
    border-color: #f85149;
    background: rgba(248, 81, 73, 0.1);
}

.qa-score {
    padding: 12px;
}

.score-badge {
    display: inline-block;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.score-badge span {
    font-size: 1rem;
    color: var(--text-muted);
}

.score-grade {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.issue-severity {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    margin-right: 6px;
}

.issue-severity.error { background: rgba(248,81,73,0.2); color: #f85149; }
.issue-severity.warning { background: rgba(210,153,34,0.2); color: #d29922; }
.issue-severity.info { background: rgba(88,166,255,0.2); color: #58a6ff; }

.issue-suggestion {
    margin-top: 5px;
    padding-left: 8px;
    border-left: 2px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.qa-errors {
    margin-top: 12px;
}

.qa-errors pre,
.qa-text {
    background: #0d1117;
    color: #c9d1d9;
    padding: 10px;
    border-radius: 6px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.qa-screenshot {
    padding: 0 12px 12px 12px;
}

.qa-screenshot img {
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* Git tab */
.git-section {
    padding: 4px 12px 12px 12px;
}

.git-section h4 {
    margin: 8px 0 4px 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#git-msg,
#git-branch-name {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}

/* Writer tab */
.writer-form {
    padding: 12px;
}

.writer-form > label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

#writer-brief {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    resize: vertical;
    font-family: inherit;
}

.writer-output {
    padding: 0 12px 12px 12px;
}

.writer-markdown {
    width: 100%;
    box-sizing: border-box;
    min-height: 320px;
    padding: 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    resize: vertical;
}

/* Settings tab */
.settings-env-list {
    margin: 8px 0;
}

.settings-env-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
}

.settings-env-row code {
    font-size: 0.82rem;
    word-break: break-all;
}

.settings-env-row code:first-child {
    color: #58a6ff;
    min-width: 90px;
}

.settings-env-row .btn-small {
    margin-left: auto;
}

#settings-env-key,
#settings-env-value,
#settings-prompt-title,
#settings-prompt-content {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}

.doc-item {
    padding: 8px 4px;
    border-bottom: 1px solid var(--border);
}

.doc-item-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Code map tab */
.codemap-graph {
    padding: 12px;
    overflow-x: auto;
}

/* Grades tab */
.grades-current {
    padding: 12px;
}

.grade-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.score-badge.grade-A, .grade-letter.grade-A { color: #2ea043; }
.score-badge.grade-B, .grade-letter.grade-B { color: #58a6ff; }
.score-badge.grade-C, .grade-letter.grade-C { color: #d29922; }
.score-badge.grade-D, .grade-letter.grade-D { color: #db6d28; }
.score-badge.grade-F, .grade-letter.grade-F { color: #f85149; }

.grade-letter {
    font-size: 1.2rem;
    min-width: 24px;
}

.grade-total {
    font-weight: 600;
}

.grade-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.grade-table th, .grade-table td {
    padding: 8px;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.grade-table th {
    background: var(--surface);
    color: var(--text-muted);
}

/* Design canvas tab */
.canvas-layout {
    display: grid;
    grid-template-columns: 150px 1fr 260px;
    gap: 12px;
    padding: 12px;
    min-height: 360px;
}

.canvas-palette {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    overflow-y: auto;
    max-height: 420px;
}

.canvas-palette-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: grab;
    font-size: 0.85rem;
    user-select: none;
}

.canvas-palette-item:hover { border-color: var(--primary); background: rgba(37,99,235,0.08); }
.canvas-palette-icon { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; background: rgba(37,99,235,0.12); border-radius: 4px; font-size: 0.7rem; font-weight: 700; }

.canvas-stage {
    padding: 16px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: #fff;
    overflow-y: auto;
    max-height: 420px;
    min-height: 240px;
}

.canvas-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: #8b949e;
    font-size: 0.9rem;
}

.canvas-node {
    position: relative;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    color: #1f2328;
}

.canvas-node:hover { border-color: #58a6ff; }
.canvas-node-selected { border: 2px solid #2563eb !important; background: rgba(37,99,235,0.05); }

.canvas-node-label {
    position: absolute;
    top: -9px;
    left: 6px;
    background: #2563eb;
    color: #fff;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
}

.canvas-node:hover .canvas-node-label,
.canvas-node-selected .canvas-node-label { opacity: 1; }

.canvas-drop-target { outline: 2px dashed #2563eb !important; background: rgba(37,99,235,0.08) !important; }

.canvas-props {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    overflow-y: auto;
    max-height: 420px;
    font-size: 0.85rem;
}

.canvas-props label { display: block; margin: 10px 0 4px; color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.canvas-props-empty { color: var(--text-muted); padding: 12px 0; }
.canvas-prop-head { display: flex; justify-content: space-between; align-items: center; }

.canvas-input { width: 100%; box-sizing: border-box; padding: 7px; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); color: var(--text); }

.canvas-style-row { display: flex; gap: 4px; margin-bottom: 4px; }
.canvas-style-row input { min-width: 0; flex: 1; padding: 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); font-size: 0.78rem; }

.canvas-preview-wrap { padding: 0 12px 12px 12px; }
.canvas-preview-wrap h4 { margin: 8px 0; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.canvas-preview { width: 100%; height: 320px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

/* Connectors tab */
.connector-item.selected { border-color: var(--primary); background: rgba(37,99,235,0.08); }
#conn-invoke-panel { padding-top: 4px; }

/* Plan tab */
.plan-stages { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; }
.plan-stage { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--surface); }
.plan-stage-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.plan-stage textarea { width: 100%; box-sizing: border-box; }
@media (max-width: 900px) { .plan-stages { grid-template-columns: 1fr; } }

/* CI/CD tab */
.pipeline-stage-row, .pipeline-run-row { padding: 8px 4px; }
.pipeline-stage-row label { display: inline-flex; align-items: center; gap: 4px; }

/* Desktop tab */
.desktop-frame-wrap { padding: 0 12px 12px 12px; }
.desktop-frame { width: 100%; height: 560px; border: 1px solid var(--border); border-radius: 8px; background: #000; }

/* Cookie consent & legal modal */
.cookie-banner[hidden], .legal-modal[hidden], .help-modal[hidden] { display: none !important; }
.cookie-banner { position: fixed; bottom: 0; left: 0; right: 0; z-index: 200; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 12px 20px; background: #1f2937; color: #f9fafb; font-size: 0.85rem; box-shadow: 0 -2px 12px rgba(0,0,0,0.2); }
.legal-links { display: flex; gap: 12px; justify-content: center; margin-top: 16px; font-size: 0.75rem; }
.legal-link { color: var(--text-muted); text-decoration: underline; cursor: pointer; }
.legal-modal, .help-modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.55); padding: 20px; }
.legal-modal-card, .help-modal-card { background: var(--surface); border-radius: 12px; max-width: 720px; width: 100%; max-height: 85vh; display: flex; flex-direction: column; }
.legal-modal-head, .help-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.legal-modal-head h3, .help-modal-head h3 { margin: 0; }
.legal-modal-body, .help-modal-body { padding: 16px 20px; overflow-y: auto; }
.legal-section, .help-section { margin-bottom: 16px; }
.legal-section h4, .help-section h3 { margin: 0 0 6px; }
.legal-section p, .help-section p { margin: 0; line-height: 1.6; color: var(--text-muted); font-size: 0.9rem; }
.help-modal-body { display: flex; gap: 16px; }
.help-nav { flex: 0 0 140px; display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--border); padding-right: 12px; }
.help-nav-btn { text-align: left; padding: 8px 12px; border: none; background: transparent; cursor: pointer; border-radius: 6px; font-size: 0.85rem; color: var(--text-muted); }
.help-nav-btn:hover { background: var(--border); }
.help-nav-btn.active { background: var(--primary); color: #fff; }
.help-content { flex: 1; }
.help-topic-title { margin: 0 0 16px; font-size: 1.3rem; }
@media (max-width: 640px) {
    .help-modal-body { flex-direction: column; }
    .help-nav { flex: none; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; }
}

/* Internationalization / RTL */
html[dir="rtl"] body, html[dir="rtl"] .app-header, html[dir="rtl"] .editor-header { text-align: right; }
html[dir="rtl"] .tabs, html[dir="rtl"] .run-controls, html[dir="rtl"] .user-info, html[dir="rtl"] .doc-item-head { flex-direction: row-reverse; }
html[dir="rtl"] .progress-bar-fill { transform-origin: right; }
html[dir="rtl"] .doc-item, html[dir="rtl"] .git-section h4 { direction: rtl; }
#lang-select { min-width: 90px; }

/* Progress / gamification tab */
.progress-summary { padding: 12px; }
.progress-level { display: flex; align-items: center; gap: 16px; border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: var(--surface); }
.progress-level-badge { font-size: 1.1rem; font-weight: 700; padding: 12px 16px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; border-radius: 10px; white-space: nowrap; }
.progress-level-info { flex: 1; }
.progress-bar { height: 8px; background: var(--border); border-radius: 999px; margin: 8px 0 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #7c3aed); border-radius: 999px; transition: width 0.3s; }
.progress-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.progress-badge { text-align: center; padding: 10px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.progress-badge.locked { opacity: 0.35; filter: grayscale(1); }
.progress-badge-icon { font-size: 1.8rem; }
.progress-badge-label { font-size: 0.75rem; font-weight: 600; margin-top: 4px; }

/* Monitor tab */
.monitor-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; padding: 12px; }
.monitor-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--surface); text-align: center; }
.monitor-card-val { font-size: 1.5rem; font-weight: 700; }
.monitor-card-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.monitor-services { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; padding: 0 12px 12px 12px; }

/* Collab tab */
.doc-item.resolved { opacity: 0.6; }
.doc-item.unread { border-left: 3px solid var(--primary); }

/* Billing tab */
.billing-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; padding: 12px; }
.billing-plan { border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: var(--surface); }
.billing-plan.current { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.billing-plan h4 { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; }
.billing-price { font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; }
.billing-price span { font-size: 0.8rem; font-weight: 400; color: var(--text-muted); }
.billing-plan ul { list-style: none; padding: 0; margin: 0 0 12px; font-size: 0.82rem; }
.billing-plan li { padding: 3px 0; }
.billing-plan li::before { content: "✓ "; color: #2ea043; }
.billing-plan .badge { font-size: 0.7rem; padding: 2px 8px; background: rgba(37,99,235,0.15); border-radius: 999px; }

/* Account tab */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; }
@media (max-width: 900px) { .account-grid { grid-template-columns: 1fr; } }
#key-new, #wh-result { overflow-x: auto; }

/* Browser agent tab */
.agent-screenshots { display: flex; flex-wrap: wrap; gap: 12px; padding: 8px 0; }
.agent-shot { border: 1px solid var(--border); border-radius: 6px; padding: 6px; max-width: 260px; }
.agent-shot img { width: 100%; border-radius: 4px; display: block; margin-top: 4px; }
.agent-session-row { padding: 8px 4px; }
