/* Platypus Poster — Visual Refresh */

:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --success-hover: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    --surface: #ffffff;
    --bg: #f8fafc;
    --bg-secondary: #f1f5f9;
    --border: #e2e8f0;
    --border-hover: #94a3b8;
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --transition: 0.2s ease;
}

* { box-sizing: border-box; }

html { overflow-x: clip; }
body { overflow-x: clip; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
}

/* Prevent images/videos/media from forcing horizontal scroll */
img, video { max-width: 100%; height: auto; }

h1 {
    color: var(--text);
    border-bottom: 3px solid var(--primary);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.diagnostic-link {
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: normal;
}
.diagnostic-link:hover { color: var(--primary); }

.card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}
.card h2 {
    margin-top: 0;
    color: var(--text);
    font-size: 18px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}

/* Auth */
.auth-section { display: flex; gap: 10px; align-items: center; }
.auth-status {
    padding: 8px 16px; border-radius: 20px;
    font-size: 13px; font-weight: 600; white-space: nowrap;
}
.auth-status.connected { background: #d4edda; color: #155724; }
.auth-status.disconnected { background: #f8d7da; color: #721c24; }

/* Platform Grid */
.platform-grid { display: flex; gap: 15px; flex-wrap: wrap; }
.platform-option {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border: 2px solid var(--border); border-radius: var(--radius);
    cursor: pointer; transition: all var(--transition); user-select: none;
}
.platform-option:hover { border-color: var(--primary); }
.platform-option.selected { border-color: var(--primary); background: #eff6ff; }
.platform-option.disabled { opacity: 0.4; cursor: not-allowed; }
.platform-option input { display: none; }
.platform-icon {
    width: 32px; height: 32px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 16px;
}
.platform-icon svg { width: 16px; height: 16px; }
.platform-icon.twitter { background: #000000; }
.platform-icon.bluesky { background: #0085FF; }
.platform-icon.threads { background: #000000; }
.platform-icon.linkedin { background: #0A66C2; }
.platform-icon.facebook { background: #1877F2; }
.platform-icon.instagram { background: #E4405F; }
.platform-icon.mastodon { background: #6364FF; }
.platform-icon.tiktok { background: #000000; }
.platform-icon.youtube { background: #FF0000; }
.platform-icon.pinterest { background: #E60023; }
.platform-icon.googlebusiness { background: #4285F4; }
.platform-icon.startpage { background: #2c3e50; }
.platform-info { display: flex; flex-direction: column; }
.platform-name { font-weight: 600; font-size: 14px; }
.platform-handle { font-size: 12px; color: var(--text-muted); }
.platform-checkbox {
    width: 20px; height: 20px;
    border: 2px solid var(--border); border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    margin-left: auto;
}
.platform-option.selected .platform-checkbox { background: var(--primary); border-color: var(--primary); }
.platform-option.selected .platform-checkbox::after { content: '\2713'; color: white; font-size: 14px; }
.no-channels { color: var(--text-muted); font-style: italic; }

/* Compose */
.compose-area { position: relative; }
.compose-textarea {
    width: 100%; min-height: 160px; padding: 15px;
    border: 2px solid var(--border); border-radius: var(--radius);
    font-size: 16px; font-family: inherit;
    resize: vertical; line-height: 1.5;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.compose-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.char-counter {
    position: absolute; bottom: 10px; right: 10px;
    font-size: 13px; color: var(--text-muted);
    background: white; padding: 2px 8px; border-radius: 4px;
}
.char-counter.warning { color: var(--warning); }
.char-counter.over { color: var(--danger); font-weight: bold; }
.char-limits { display: flex; gap: 15px; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.char-limit-item { display: flex; align-items: center; gap: 5px; }
.char-limit-item.over { color: var(--danger); }
.char-limit-item.ok { color: var(--success); }

/* Media */
.media-upload-area {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 30px; text-align: center; cursor: pointer; transition: all var(--transition);
}
.media-upload-area:hover { border-color: var(--primary); background: var(--bg-secondary); }
.media-upload-area.dragover { border-color: var(--primary); background: #eff6ff; }
.media-upload-area.has-media { border-style: solid; padding: 15px; cursor: default; }
.upload-icon { font-size: 48px; margin-bottom: 10px; }
.upload-text { color: var(--text-muted); margin-bottom: 10px; }
.upload-hint { font-size: 12px; color: var(--text-muted); }
.media-preview { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.media-item { position: relative; max-width: 200px; }
.media-item img, .media-item video { max-width: 100%; max-height: 200px; border-radius: 8px; }
.media-remove {
    position: absolute; top: -8px; right: -8px;
    width: 24px; height: 24px; background: var(--danger); color: white;
    border: none; border-radius: 50%; cursor: pointer;
    font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.alt-text-row {
    display: flex; gap: 4px; margin-top: 6px; width: 100%;
}
.alt-text-input {
    flex: 1; font-size: 11px; padding: 4px 6px; border: 1px solid var(--border);
    border-radius: 4px; resize: vertical; min-height: 32px; font-family: inherit;
    background: var(--bg); color: var(--text);
}
.alt-text-input:focus { border-color: var(--primary); outline: none; }
.alt-text-generate {
    flex-shrink: 0; font-size: 11px; padding: 4px 8px; white-space: nowrap; align-self: flex-start;
}
.alt-text-label {
    flex-shrink: 0; font-size: 11px; color: var(--text-muted); align-self: center;
    max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-add-more {
    display: flex; align-items: center; justify-content: center;
    min-width: 100px; min-height: 100px; max-height: 200px;
    border: 2px dashed var(--border); border-radius: 8px; cursor: pointer;
    transition: all var(--transition);
}
.media-add-more:hover { border-color: var(--primary); background: var(--bg-secondary); }
.media-add-more-inner { text-align: center; }
.media-add-more-icon { font-size: 28px; color: var(--text-muted); }
.media-add-more-text { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.hidden-input { display: none; }

/* Media size warnings */
.media-warnings { margin-top: 12px; }
.media-warning {
    padding: 8px 12px; border-radius: 6px; margin-top: 6px;
    background: #fff3cd; color: #856404; font-size: 13px;
    border: 1px solid var(--warning);
}

/* Buttons */
.post-actions { display: flex; gap: 12px; flex-wrap: wrap; }
button {
    padding: 13px 26px; border: none; border-radius: var(--radius);
    cursor: pointer; font-size: 14px; font-weight: 600; transition: all var(--transition);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); }
.btn-secondary { background: var(--text-muted); color: white; }
.btn-secondary:hover:not(:disabled) { background: var(--text-secondary); }

/* Clear Button */
.btn-clear { background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-clear:hover:not(:disabled) { background: var(--border); color: var(--text); }

/* Status */
.status-message {
    padding: 12px 16px; border-radius: var(--radius); margin-top: 15px; display: none;
}
.status-message.success { display: block; background: #d4edda; color: #155724; }
.status-message.error { display: block; background: #f8d7da; color: #721c24; }
.status-message.info { display: block; background: #eff6ff; color: #1e40af; }

.loading {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid #fff; border-top: 2px solid transparent;
    border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 8px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Diagnostic Modal */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    z-index: 1000; overflow-y: auto; padding: 20px;
}
.modal-overlay.visible { display: flex; justify-content: center; }
.modal-content {
    background: var(--surface); border-radius: var(--radius-lg); max-width: 1000px;
    width: 100%; max-height: 90vh; overflow-y: auto; margin: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--surface); z-index: 1;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header h2 { margin: 0; }
.modal-close {
    background: none; border: none; font-size: 24px;
    cursor: pointer; color: var(--text-muted); padding: 0;
}
.modal-body { padding: 20px; }
.diag-section { margin-bottom: 25px; }
.diag-section h3 { color: var(--text-secondary); margin-bottom: 15px; font-size: 16px; }
.button-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.input-group { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; }
.input-group label { min-width: 120px; font-weight: 600; font-size: 14px; }
.input-group input, .input-group select {
    flex: 1; padding: 8px 12px; border: 2px solid var(--border); border-radius: 6px; font-size: 14px;
}
.response-section { background: var(--bg-secondary); border-radius: 8px; overflow: hidden; margin-top: 20px; }
.response-header {
    background: #34495e; color: white; padding: 10px 15px;
    display: flex; justify-content: space-between; align-items: center; font-size: 14px;
}
.response-body { padding: 15px; max-height: 400px; overflow: auto; }
pre { margin: 0; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; line-height: 1.4; }
.json-key { color: #881391; }
.json-string { color: #1a1aa6; }
.json-number { color: #1a1aa6; }
.json-boolean { color: #0d22aa; }
.json-null { color: #808080; }
.copy-btn { background: var(--bg-secondary); color: var(--text-secondary); padding: 4px 10px; font-size: 12px; }

/* Platform Tabs */
.platform-tabs-container {
    margin-top: 15px;
}
.platform-tabs-header {
    display: flex; align-items: center; margin-bottom: 0;
}
.platform-tabs-label {
    font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap;
    padding: 8px 14px; background: var(--bg-secondary); border-radius: var(--radius) 0 0 0;
    border-bottom: 2px solid var(--primary); align-self: flex-end;
    display: none;
}
.platform-tabs-bar {
    display: flex; gap: 0; flex-wrap: wrap;
    border-bottom: 2px solid var(--border);
    width: 100%;
}
.platform-tab {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 16px; border: none; border-bottom: 3px solid transparent;
    border-radius: 0; background: transparent;
    cursor: pointer; font-size: 13px;
    font-weight: 500; transition: all var(--transition);
    margin-bottom: -2px; position: relative;
    color: var(--text-secondary);
}
.platform-tab:hover { background: var(--bg-secondary); border-bottom-color: var(--border-hover); }
.platform-tab.active {
    border-bottom-color: var(--primary); background: transparent;
    font-weight: 600; color: var(--text);
}
.platform-tab-icon {
    width: 20px; height: 20px; border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    color: white; font-size: 9px;
}
.platform-tab-icon svg { width: 12px; height: 12px; }
.platform-tab-name {
    max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.platform-tab-badge {
    font-size: 11px; padding: 1px 6px; border-radius: 10px; font-weight: 600;
}
.platform-tab-badge.ok { background: #d4edda; color: #155724; }
.platform-tab-badge.over { background: #f8d7da; color: #721c24; }
.platform-tab-badge.edited { background: #fff3cd; color: #856404; }

.platform-tab-content { margin-top: 0; }
.platform-tab-editor {
    border: 2px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius);
    padding: 14px; background: var(--bg-secondary);
}
.platform-tab-editor .post-preview-container { margin-top: 0; }
.platform-tab-editor .post-preview-body[contenteditable="true"] {
    min-height: 60px; outline: none; cursor: text;
}
.platform-tab-editor .post-preview-body[contenteditable="true"]:empty::before {
    content: attr(data-placeholder); color: var(--text-muted); font-style: italic;
}
.platform-tab-editor .post-preview-body[contenteditable="true"]:focus {
    background: rgba(52,152,219, 0.04);
}
.platform-textarea { min-height: 100px; font-size: 14px; }
.platform-tab-actions-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 8px; gap: 10px;
}
.platform-tab-actions {
    display: flex; gap: 10px; align-items: center;
}
.btn-shorten {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px; font-size: 13px;
}
.btn-small { padding: 6px 12px; font-size: 12px; }

/* Shorten Modal */
.shorten-modal-content { max-width: 700px; }
.shorten-instruction { color: var(--text-muted); font-size: 14px; margin-bottom: 15px; }
.shorten-options { display: flex; flex-direction: column; gap: 12px; }
.shorten-option {
    border: 2px solid var(--border); border-radius: var(--radius); padding: 15px;
    cursor: pointer; transition: all var(--transition);
}
.shorten-option:hover { border-color: var(--primary); background: var(--bg-secondary); }
.shorten-option-text {
    font-size: 14px; line-height: 1.5; margin-bottom: 8px; white-space: pre-wrap;
}
.shorten-option-meta {
    display: flex; justify-content: space-between; align-items: center;
}
.shorten-option-count { font-size: 12px; color: var(--text-muted); }
.shorten-option-count.over { color: var(--danger); font-weight: 600; }
.shorten-loading {
    text-align: center; padding: 20px; color: var(--text-muted); font-size: 14px;
}
.shorten-actions {
    display: flex; gap: 10px; margin-top: 15px; justify-content: flex-end;
}

/* Contacts Button */
.btn-contacts {
    background: #8e44ad; color: white;
    padding: 6px 14px; font-size: 13px; border-radius: var(--radius);
    font-weight: 600;
}
.btn-contacts:hover { background: #7d3c98; }
.btn-lookup {
    background: var(--primary-hover); color: white;
    padding: 6px 14px; font-size: 13px; border-radius: var(--radius);
    font-weight: 600;
}
.btn-lookup:hover { background: var(--primary); }

/* Handle Lookup Popup */
.lookup-popup {
    position: absolute; top: 100%; right: 0; z-index: 1500;
    background: var(--surface); border: 2px solid var(--primary); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 14px;
    width: 340px; display: none;
}
.lookup-popup.visible { display: block; }
.lookup-popup-input {
    width: 100%; padding: 10px 12px; border: 2px solid var(--border);
    border-radius: 6px; font-size: 14px; box-sizing: border-box;
    margin-bottom: 10px;
}
.lookup-popup-input:focus { outline: none; border-color: var(--primary); }
.lookup-results {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.lookup-results a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 5px;
    text-decoration: none; color: white; font-weight: 600;
    font-size: 12px; transition: opacity 0.15s;
}
.lookup-results a svg { width: 14px; height: 14px; }
.lookup-results a:hover { opacity: 0.8; }
.lookup-hint {
    font-size: 12px; color: var(--text-muted); text-align: center; padding: 4px 0;
}
.lookup-save-row {
    margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
    text-align: center;
}

/* ![Name] handle mention hint */
.handle-mention-hint {
    font-size: 12px; color: var(--text-secondary); background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: 6px;
    padding: 8px 12px; margin-top: 8px; line-height: 1.5;
}
.handle-mention-hint code {
    background: rgba(59, 130, 246, 0.1); color: var(--primary);
    padding: 1px 5px; border-radius: 3px; font-size: 11.5px;
}
.handle-mention-hint strong { color: var(--text); }

/* Resolve usernames bar */
.resolve-usernames-bar {
    display: flex; align-items: center; gap: 10px; margin-top: 8px;
}
.btn-resolve {
    background: var(--primary); color: white; border: none; cursor: pointer;
    padding: 7px 16px; font-size: 13px; font-weight: 600;
    border-radius: var(--radius); transition: background var(--transition);
}
.btn-resolve:hover { background: var(--primary-hover); }
.btn-resolve:disabled { opacity: 0.6; cursor: not-allowed; }
#resolve-status { font-size: 12px; color: var(--text-muted); font-style: italic; }

/* Handle preview results */
.handle-preview-results {
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 6px;
    padding: 10px 14px; margin-top: 8px; font-size: 12px;
}
.handle-preview-person { margin-bottom: 8px; }
.handle-preview-person:last-child { margin-bottom: 0; }
.handle-preview-person-name { font-weight: 700; margin-bottom: 4px; }
.handle-preview-handles {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.handle-preview-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
    padding: 2px 8px; font-size: 11px;
}
.handle-preview-badge svg { width: 12px; height: 12px; }
.handle-preview-badge a {
    color: var(--primary); font-family: monospace; text-decoration: none;
}
.handle-preview-badge a:hover { text-decoration: underline; }
.handle-preview-badge .handle-none { color: var(--text-muted); font-style: italic; }
.handle-dismiss-btn {
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    font-size: 14px; line-height: 1; padding: 0 2px; margin-left: 2px;
    opacity: 0.6; transition: opacity var(--transition), color var(--transition);
}
.handle-dismiss-btn:hover { opacity: 1; color: var(--danger, #e53e3e); }

/* Hover profile card */
.handle-hover-wrap {
    position: relative; display: inline;
}
.profile-hover-card {
    display: none; position: absolute; bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%); z-index: 2000;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); width: 280px; overflow: hidden;
    pointer-events: none;
}
.handle-hover-wrap:hover .profile-hover-card { display: block; }
.profile-hover-img {
    width: 100%; height: 120px; object-fit: cover; display: block;
    border-bottom: 1px solid var(--border);
}
.profile-hover-body { padding: 10px 12px; }
.profile-hover-name {
    font-weight: 700; font-size: 13px; color: var(--text);
    margin-bottom: 4px; line-height: 1.3;
}
.profile-hover-desc {
    font-size: 11.5px; color: var(--text-secondary); line-height: 1.4;
}

/* Contacts Modal */
.contacts-modal-content { max-width: 800px; }
.contacts-toolbar {
    display: flex; gap: 10px; margin-bottom: 15px; align-items: center;
}
.contacts-search-input {
    flex: 1; padding: 10px 14px; border: 2px solid var(--border);
    border-radius: var(--radius); font-size: 14px;
}
.contacts-search-input:focus { outline: none; border-color: var(--primary); }

/* Contact Form */
.contact-form {
    background: var(--bg-secondary); border: 2px solid var(--border);
    border-radius: var(--radius); padding: 15px; margin-bottom: 15px;
}
.contact-form h3 { margin: 0 0 12px 0; font-size: 16px; color: var(--text); }
.contact-form-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.contact-form-grid .form-field label {
    display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 3px;
}
.contact-form-grid .form-field input {
    width: 100%; padding: 8px 10px; border: 2px solid var(--border);
    border-radius: 6px; font-size: 13px; box-sizing: border-box;
}
.contact-form-grid .form-field input:focus { outline: none; border-color: var(--primary); }
.contact-form-actions {
    display: flex; gap: 10px; margin-top: 12px;
}

/* Contacts List */
.contacts-list { display: flex; flex-direction: column; gap: 10px; }
.contact-card {
    border: 2px solid var(--border); border-radius: var(--radius); padding: 12px;
    transition: border-color var(--transition);
}
.contact-card:hover { border-color: var(--primary); }
.contact-card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}
.contact-card-name { font-size: 15px; color: var(--text); }
.contact-card-actions { display: flex; gap: 6px; }
.contact-card-handles {
    display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px;
}
.contact-handle-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: 4px;
    font-size: 12px; font-weight: 600; color: white;
}
.contact-handle-badge svg { width: 12px; height: 12px; }
.contact-handle-badge.twitter { background: #000000; }
.contact-handle-badge.bluesky { background: #0085FF; }
.contact-handle-badge.threads { background: #000000; }
.contact-handle-badge.linkedin { background: #0A66C2; }
.contact-handle-badge.facebook { background: #1877F2; }
.contact-handle-badge.instagram { background: #E4405F; }
.contact-handle-badge.mastodon { background: #6364FF; }
.contact-handle-badge.tiktok { background: #000000; }
.contact-handle-badge.youtube { background: #FF0000; }
.contact-handle-badge.pinterest { background: #E60023; }
.contact-handle-badge.googlebusiness { background: #4285F4; }

/* Quick Search Links */
.contact-card-search {
    display: flex; align-items: center; gap: 6px;
    flex-wrap: wrap; margin-bottom: 4px;
}
.contact-search-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.contact-search-link {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 4px;
    text-decoration: none; color: white;
}
.contact-search-link svg { width: 12px; height: 12px; }
.contact-search-link.twitter { background: #000000; }
.contact-search-link.bluesky { background: #0085FF; }
.contact-search-link.threads { background: #000000; }
.contact-search-link.linkedin { background: #0A66C2; }
.contact-search-link.facebook { background: #1877F2; }
.contact-search-link.instagram { background: #E4405F; }
.contact-search-link.mastodon { background: #6364FF; }
.contact-search-link.tiktok { background: #000000; }
.contact-search-link.youtube { background: #FF0000; }
.contact-search-link.pinterest { background: #E60023; }
.contact-search-link.googlebusiness { background: #4285F4; }
.contact-search-link:hover { opacity: 0.8; }

.contact-card-notes {
    font-size: 12px; color: var(--text-muted); font-style: italic;
}

/* Small buttons for contact cards */
.btn-small {
    padding: 4px 10px; font-size: 12px;
}

/* Autocomplete Dropdown */
.contacts-autocomplete {
    position: fixed; z-index: 2000;
    background: var(--surface); border: 2px solid var(--primary);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    max-height: 250px; overflow-y: auto; min-width: 280px;
}
.autocomplete-item {
    padding: 8px 12px; cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.selected { background: #eff6ff; }
.autocomplete-item-main {
    display: flex; align-items: center; gap: 8px;
}
.autocomplete-item-main strong { font-size: 14px; color: var(--text); }
.autocomplete-handle { font-size: 13px; color: var(--primary); }
.autocomplete-no-handle { font-size: 12px; color: var(--danger); font-style: italic; }
.autocomplete-item-search { margin-top: 4px; }
.autocomplete-search-link {
    font-size: 11px; color: var(--primary); text-decoration: none; margin-right: 8px;
}
.autocomplete-search-link:hover { text-decoration: underline; }
.autocomplete-empty {
    padding: 12px; text-align: center; color: var(--text-muted); font-size: 13px;
}

/* Schedule picker */
.schedule-row {
    display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap;
}
.schedule-row label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.schedule-row input[type="datetime-local"] {
    padding: 8px 12px; border: 2px solid var(--border); border-radius: var(--radius);
    font-size: 14px; font-family: inherit;
}
.schedule-row input[type="datetime-local"]:focus { outline: none; border-color: var(--primary); }
.btn-schedule { background: #8e44ad; color: white; }
.btn-schedule:hover:not(:disabled) { background: #7d3c98; }

/* Drafts */
.btn-draft { background: #e67e22; color: white; }
.btn-draft:hover:not(:disabled) { background: #d35400; }
.btn-drafts-open { background: #f39c12; color: white; padding: 6px 14px; font-size: 13px; }
.btn-drafts-open:hover { background: #e67e22; }
.drafts-modal-content { max-width: 700px; }
.autosave-indicator {
    font-size: 12px; color: var(--text-muted); margin-left: auto; white-space: nowrap;
}
.autosave-indicator.saved { color: var(--success); }
.draft-save-row {
    display: flex; gap: 10px; align-items: center; margin-bottom: 15px;
}
.draft-save-row input {
    flex: 1; padding: 8px 12px; border: 2px solid var(--border);
    border-radius: 6px; font-size: 14px;
}
.draft-save-row input:focus { outline: none; border-color: var(--primary); }
.drafts-list { display: flex; flex-direction: column; gap: 10px; }
.draft-card {
    border: 2px solid var(--border); border-radius: var(--radius); padding: 12px;
    cursor: pointer; transition: border-color var(--transition);
}
.draft-card:hover { border-color: var(--primary); }
.draft-card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
}
.draft-card-name { font-weight: 600; font-size: 15px; color: var(--text); }
.draft-card-date { font-size: 12px; color: var(--text-muted); }
.draft-card-preview {
    font-size: 13px; color: var(--text-secondary); line-height: 1.4;
    max-height: 60px; overflow: hidden; white-space: pre-wrap;
}
.draft-card-meta {
    display: flex; gap: 8px; margin-top: 6px; align-items: center; flex-wrap: wrap;
}
.draft-card-platforms { display: flex; gap: 4px; flex-wrap: wrap; }
.draft-platform-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 10px; padding: 2px 6px; border-radius: 3px;
    font-weight: 600; color: white;
}
.draft-platform-badge svg { width: 10px; height: 10px; }
.draft-card-actions { display: flex; gap: 6px; }
.draft-autosave-badge {
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
    background: #fff3cd; color: #856404; font-weight: 600;
}

/* Content Type Chooser */
.content-type-bar {
    display: flex; gap: 8px; flex-wrap: wrap;
}
.content-type-btn {
    padding: 10px 18px; border: 2px solid var(--border); border-radius: var(--radius);
    background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 600;
    color: var(--text-secondary); transition: all var(--transition); display: flex; align-items: center; gap: 8px;
}
.content-type-btn:hover { border-color: var(--primary); color: var(--primary); }
.content-type-btn.active { border-color: var(--primary); background: #eff6ff; color: var(--primary-hover); }
.content-type-icon { font-size: 18px; }

/* Queue Viewer */
.queue-modal-content { max-width: 900px; }
.queue-controls { display: flex; gap: 10px; margin-bottom: 15px; align-items: center; flex-wrap: wrap; }
.queue-channel-select {
    padding: 8px 12px; border: 2px solid var(--border); border-radius: var(--radius);
    font-size: 14px; min-width: 200px;
}
.queue-channel-select:focus { outline: none; border-color: var(--primary); }
.queue-list { display: flex; flex-direction: column; gap: 10px; }
.queue-item {
    border: 2px solid var(--border); border-radius: var(--radius); padding: 14px;
    transition: border-color var(--transition); position: relative;
}
.queue-item:hover { border-color: var(--primary); }
.queue-item-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 8px;
}
.queue-item-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.queue-item-status {
    font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.queue-item-status.scheduled { background: #eff6ff; color: #1e40af; }
.queue-item-status.sent { background: #d4edda; color: #155724; }
.queue-item-status.draft { background: #fff3cd; color: #856404; }
.queue-item-status.error { background: #f8d7da; color: #721c24; }
.queue-item-time { font-size: 12px; color: var(--text-muted); }
.queue-item-channel {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
    color: white; font-weight: 600;
}
.queue-item-channel svg { width: 11px; height: 11px; }
.queue-item-text {
    font-size: 14px; line-height: 1.5; color: var(--text);
    white-space: pre-wrap; max-height: 120px; overflow: hidden;
}
.queue-item-actions { display: flex; gap: 6px; margin-top: 10px; }
.queue-loading { text-align: center; padding: 30px; color: var(--text-muted); }
.queue-empty { text-align: center; padding: 30px; color: var(--text-muted); font-style: italic; }
.queue-item-number {
    font-size: 12px; color: var(--text-muted); font-weight: 600; min-width: 24px;
}

/* Analytics Dashboard */
.analytics-modal-content { max-width: 1000px; }
.analytics-controls {
    display: flex; gap: 10px; margin-bottom: 20px; align-items: center; flex-wrap: wrap;
}
.analytics-stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.analytics-stat-card {
    background: var(--bg-secondary); border-radius: var(--radius); padding: 16px; text-align: center;
    border: 1px solid var(--border);
}
.analytics-stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.analytics-stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.analytics-chart {
    background: var(--bg-secondary); border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
    border: 1px solid var(--border);
}
.analytics-chart h3 { margin: 0 0 15px 0; font-size: 15px; color: var(--text); }
.analytics-bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 150px; }
.analytics-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.analytics-bar {
    width: 100%; min-width: 20px; background: var(--primary); border-radius: 4px 4px 0 0;
    transition: height 0.3s; position: relative;
}
.analytics-bar:hover { background: var(--primary-hover); }
.analytics-bar-label { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.analytics-bar-value {
    font-size: 10px; color: var(--text); font-weight: 600; white-space: nowrap;
}
.analytics-post-list { display: flex; flex-direction: column; gap: 10px; }
.analytics-post-item {
    border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
}
.analytics-post-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
}
.analytics-post-text {
    font-size: 13px; color: var(--text); white-space: pre-wrap;
    max-height: 60px; overflow: hidden; line-height: 1.4;
}
.analytics-post-stats {
    display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap;
}
.analytics-post-stat {
    font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px;
}
.analytics-post-stat strong { color: var(--text); }
.analytics-tabs { display: flex; gap: 4px; margin-bottom: 15px; }
.analytics-tab {
    padding: 8px 16px; border: 2px solid var(--border); border-radius: var(--radius);
    background: var(--bg-secondary); cursor: pointer; font-size: 13px; font-weight: 500;
}
.analytics-tab:hover { border-color: var(--primary); }
.analytics-tab.active { border-color: var(--primary); background: #eff6ff; }

/* Schedule Manager */
.schedule-mgr-modal-content { max-width: 900px; }
.schedule-mgr-channel-select {
    padding: 8px 12px; border: 2px solid var(--border); border-radius: var(--radius);
    font-size: 14px; min-width: 200px; margin-bottom: 15px;
}
.schedule-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}
.schedule-day-col {
    background: var(--bg-secondary); border-radius: var(--radius); padding: 10px;
    border: 1px solid var(--border); min-height: 120px;
}
.schedule-day-header {
    font-size: 13px; font-weight: 700; color: var(--text);
    text-align: center; margin-bottom: 8px;
    padding-bottom: 6px; border-bottom: 2px solid var(--border);
}
.schedule-time-slot {
    font-size: 12px; padding: 4px 8px; margin-bottom: 4px;
    background: var(--primary); color: white; border-radius: 4px;
    display: flex; justify-content: space-between; align-items: center;
}
.schedule-time-slot.paused { background: var(--text-muted); }
.schedule-time-remove {
    background: none; border: none; color: white; cursor: pointer;
    font-size: 14px; padding: 0 2px; opacity: 0.7;
}
.schedule-time-remove:hover { opacity: 1; }
.schedule-add-time {
    display: flex; gap: 6px; margin-top: 6px; align-items: center;
}
.schedule-add-time input[type="time"] {
    padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px;
    font-size: 12px; width: 90px;
}
.schedule-add-btn {
    padding: 4px 8px; font-size: 11px; background: var(--success); color: white;
    border: none; border-radius: 4px; cursor: pointer;
}
.schedule-add-btn:hover { background: var(--success-hover); }
.schedule-paused-badge {
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
    background: #fff3cd; color: #856404; font-weight: 600;
}

/* Thread toolbar under main compose textarea */
.thread-toolbar {
    display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap;
}
.btn-thread-add {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--bg-secondary); color: var(--text-secondary);
    border: 1px dashed var(--border-hover); border-radius: var(--radius);
    padding: 8px 14px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all var(--transition);
}
.btn-thread-add:hover {
    background: #eff6ff; color: var(--primary); border-color: var(--primary); border-style: solid;
}
.thread-add-icon { font-size: 14px; }
.thread-toolbar-hint {
    font-size: 12px; color: var(--text-muted); flex: 1 1 300px;
}

/* Compose-area thread preview (read-only overview shown when text has 2+ parts) */
.compose-thread-preview {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; margin-top: 12px;
}
.compose-thread-preview .thread-header h3 {
    margin: 0 0 4px 0; font-size: 14px; color: var(--text);
}
.compose-thread-preview .thread-info {
    font-size: 12px; color: var(--text-muted);
}
.compose-thread-preview .thread-parts {
    display: flex; flex-direction: column; gap: 8px; margin-top: 10px;
}
.compose-thread-preview .thread-part {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px 12px;
}

/* Editable thread parts inside platform tabs */
.thread-part-editor {
    border-top: 1px dashed var(--border);
    padding: 10px 0 0;
    margin-top: 10px;
}
.thread-part-editor:first-of-type {
    border-top: none; padding-top: 0; margin-top: 0;
}
.thread-part-editor .post-preview-body.thread-part-body {
    padding: 10px 14px 12px; min-height: 52px;
    font-size: 14px; line-height: 1.5;
    outline: none; cursor: text; white-space: pre-wrap; word-wrap: break-word;
}
.thread-part-editor .post-preview-body.thread-part-body[contenteditable="true"]:empty::before {
    content: attr(data-placeholder); color: var(--text-muted); font-style: italic;
}
.thread-part-editor .post-preview-body.thread-part-body:focus {
    background: rgba(52,152,219,0.04);
}
.thread-part-badge {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px; font-size: 11px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.thread-part-num {
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.thread-part-badge .char-counter {
    position: static; background: transparent; padding: 0;
    font-weight: 500; margin-left: auto;
}
.btn-thread-remove-part {
    background: transparent; border: none; color: var(--text-muted);
    font-size: 18px; line-height: 1; cursor: pointer;
    width: 22px; height: 22px; border-radius: 4px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.btn-thread-remove-part:hover { background: #f8d7da; color: var(--danger); }

.thread-indicator {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 1px 8px; border-radius: 10px;
    background: #eff6ff; color: var(--primary);
    font-size: 11px; font-weight: 600;
}

/* Legacy Thread Composer (kept for any fallback render) */
.thread-composer {
    border-top: 2px solid var(--border); padding-top: 15px; margin-top: 15px;
}
.thread-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
}
.thread-header h3 { margin: 0; font-size: 15px; color: var(--text); }
.thread-parts { display: flex; flex-direction: column; gap: 10px; }
.thread-part {
    border: 2px solid var(--border); border-radius: var(--radius); padding: 12px;
    position: relative;
}
.thread-part-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
}
.thread-part-label { font-size: 13px; font-weight: 600; color: var(--text); }
.thread-part-count { font-size: 12px; color: var(--text-muted); }
.thread-part-count.over { color: var(--danger); font-weight: 600; }
.thread-part-text {
    font-size: 14px; line-height: 1.5; white-space: pre-wrap;
    color: var(--text); padding: 8px; background: var(--bg-secondary); border-radius: 6px;
}
.thread-actions {
    display: flex; gap: 10px; margin-top: 10px; align-items: center;
}
.thread-info { font-size: 12px; color: var(--text-muted); }

/* Nav buttons for queue/analytics/schedule */
.nav-buttons {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 15px;
}
.btn-nav {
    padding: 10px 18px; border: 2px solid var(--border); border-radius: var(--radius);
    background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600;
    color: var(--text-secondary); transition: all var(--transition);
}
.btn-nav:hover { border-color: var(--primary); color: var(--primary); }

/* Post Preview */
.post-preview-container {
    margin-top: 12px; border: 2px solid var(--border); border-radius: var(--radius);
    overflow: hidden; background: var(--surface);
}
.post-preview-header {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px;
}
.post-preview-avatar {
    width: 40px; height: 40px; border-radius: 50%; background: var(--border);
    display: flex; align-items: center; justify-content: center; font-size: 18px;
    color: white; flex-shrink: 0;
}
.post-preview-name { font-weight: 600; font-size: 14px; }
.post-preview-handle { font-size: 13px; color: var(--text-muted); }
.post-preview-body {
    padding: 0 14px 14px; font-size: 14px; line-height: 1.5;
    white-space: pre-wrap; word-wrap: break-word;
}
.post-preview-media {
    padding: 0 14px 14px; position: relative;
}
.post-preview-media img,
.post-preview-media video {
    display: block; cursor: default;
}
/* Single image/video: styles come from inline platform specs */
.post-preview-media.media-grid-1 img,
.post-preview-media.media-grid-1 video {
    /* single item inherits inline singleStyle */
}
/* Multi-image grids */
.post-preview-media.media-grid-2,
.post-preview-media.media-grid-3,
.post-preview-media.media-grid-4,
.post-preview-media.media-grid-5 {
    display: grid; gap: 2px;
}
.post-preview-media.media-grid-2 { grid-template-columns: 1fr 1fr; }
.post-preview-media.media-grid-3 { grid-template-columns: 1fr 1fr; }
.post-preview-media.media-grid-4 { grid-template-columns: 1fr 1fr; }
.post-preview-media.media-grid-5 { grid-template-columns: 1fr 1fr 1fr; }
.media-grid-cell { position: relative; overflow: hidden; }
.media-grid-cell img,
.media-grid-cell video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-grid-overflow {
    position: absolute; inset: 0; background: rgba(0,0,0,0.5);
    color: white; display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700;
}
/* Media summary in upload area (when previews show in platform tabs) */
.media-summary {
    display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary);
}
.media-summary-names {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--text-muted); font-size: 12px;
}
.post-preview-meta {
    padding: 8px 14px; border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-muted); display: flex; gap: 16px;
}

/* Calendar */
.calendar-grid-container {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.calendar-day {
    min-height: 90px; border: 1px solid var(--border); border-radius: 4px;
    padding: 4px; font-size: 12px; background: var(--surface); overflow: hidden;
}
.calendar-day.other-month { background: var(--bg-secondary); opacity: 0.5; }
.calendar-day.today { border-color: var(--primary); border-width: 2px; }
.calendar-day-num { font-weight: 600; font-size: 13px; margin-bottom: 4px; color: var(--text); }
.calendar-post {
    font-size: 10px; padding: 2px 4px; border-radius: 3px; margin-bottom: 2px;
    color: white; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    cursor: default;
}
.calendar-day-header {
    text-align: center; font-weight: 600; font-size: 12px; color: var(--text-muted);
    padding: 6px 0; background: var(--bg-secondary); border-radius: 4px;
}

/* Hashtag chips */
.hashtag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 12px; border-radius: 20px; border: 2px solid var(--border);
    cursor: pointer; font-size: 13px; font-weight: 500; transition: all var(--transition);
    background: var(--surface); color: var(--text-secondary);
}
.hashtag-chip:hover { border-color: var(--primary); }
.hashtag-chip.selected { border-color: var(--success); background: #d4edda; color: #155724; }

/* Link Preview */
.link-preview-card {
    position: relative;
    display: flex;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-top: 12px;
    background: var(--bg-secondary);
    transition: border-color var(--transition);
}
.link-preview-card:hover { border-color: var(--border-hover); }
.link-preview-image {
    width: 120px;
    height: 80px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--border);
}
.link-preview-text { flex: 1; min-width: 0; }
.link-preview-site { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.link-preview-title { font-size: 14px; font-weight: 600; color: var(--text); margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-preview-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-preview-url { font-size: 11px; color: var(--text-muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-preview-dismiss {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Compression Progress */
.compression-progress {
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}
.compression-progress-label { font-weight: 600; margin-bottom: 6px; }
.compression-progress-status { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.compression-progress .loading { border-color: var(--primary); border-top-color: transparent; }
.compression-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.compression-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* PWA update banner */
.pwa-update-banner {
    background: var(--primary);
    color: white;
    text-align: center;
    padding: 10px 16px;
    font-size: 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.pwa-update-banner button {
    background: white;
    color: var(--primary);
    border: none;
    padding: 4px 14px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 10px;
}

/* Standalone PWA: hide browser-specific elements, add safe area insets */
@media (display-mode: standalone) {
    body { padding-top: env(safe-area-inset-top, 20px); }
}

/* Embedded mode (loaded as iframe from DataCharter) */
.embedded-mode { padding: 10px; max-width: 100%; }
.embedded-mode h1 { display: none; }
.embedded-mode .nav-buttons { display: none; }
.embedded-mode .diagnostic-link { display: none; }

/* Platform image previews from social posting integration */
.platform-image-previews {
    display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
    margin-top: 10px;
}

/* Clickable thumbnails (charts from DataCharter, uploaded images) */
.platform-image-previews img,
.media-preview img,
.post-preview-media img {
    cursor: zoom-in;
    transition: filter 0.15s ease;
}
.platform-image-previews img:hover,
.media-preview img:hover,
.post-preview-media img:hover {
    filter: brightness(0.92);
}

/* Lightbox overlay for full-size chart/image viewing */
.lightbox-modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 3000;
    align-items: center; justify-content: center;
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    cursor: zoom-out;
    animation: lightboxFadeIn 0.15s ease;
}
.lightbox-modal.visible { display: flex; }
.lightbox-img {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    cursor: zoom-out;
}
.lightbox-close {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border: none;
    width: 44px; height: 44px;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.15s ease;
    z-index: 3001;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }
@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =========================================================
   Responsive breakpoints
   - Desktop base: > 1024px (body max-width 900px centered)
   - Tablet:       600–1024px (Pixel Fold unfolded landscape,
                   iPad portrait, small laptops)
   - Mobile:       ≤ 768px (phones, Pixel Fold unfolded
                   portrait ~670px, folded ~411px)
   - Very small:   ≤ 380px (phones in portrait, folded Fold)
   ========================================================= */

/* ---- Tablet ---- */
@media (min-width: 600px) and (max-width: 1024px) {
    body { max-width: 100%; padding: 18px; }
    .card { padding: 20px; }
    .nav-buttons { gap: 8px; }
    .btn-nav { flex: 1 1 calc(33% - 8px); padding: 12px 10px; font-size: 13px; min-height: 44px; }
    .platform-option { flex: 1 1 calc(50% - 8px); min-width: 0; }
    .content-type-btn { flex: 1 1 calc(50% - 8px); justify-content: center; }
    .contact-form-grid { grid-template-columns: 1fr 1fr; }
    .analytics-stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
    .modal-content { max-width: 95%; }
    .schedule-grid { grid-template-columns: repeat(7, 1fr); gap: 6px; }
    .schedule-day-col { min-height: 110px; padding: 8px; }
    .calendar-grid-container { gap: 3px; }
    .calendar-day { min-height: 80px; }
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
    body {
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        max-width: 100%;
    }
    h1 { font-size: 20px; flex-direction: column; gap: 8px; align-items: stretch; padding-bottom: 8px; }
    h1 > span { width: 100%; justify-content: space-between; }
    .card { padding: 14px; margin-bottom: 14px; }
    .card h2 { font-size: 16px; flex-direction: column !important; gap: 8px; align-items: stretch !important; }
    .card h2 > span { width: 100%; justify-content: flex-start !important; flex-wrap: wrap; }

    /* Prevent iOS/Chrome auto-zoom on focus: all text inputs ≥16px */
    input[type="text"], input[type="email"], input[type="number"],
    input[type="search"], input[type="password"], input[type="url"],
    input[type="tel"], input[type="date"], input[type="time"],
    input[type="datetime-local"], select, textarea {
        font-size: 16px;
    }

    /* Larger touch targets for primary action buttons (not micro-icons) */
    .btn-primary, .btn-secondary, .btn-success, .btn-draft, .btn-clear,
    .btn-schedule, .post-actions button, .btn-nav, .content-type-btn,
    .analytics-tab, .platform-tab {
        min-height: 44px;
    }
    .modal-close { min-width: 44px; min-height: 44px; font-size: 26px; }

    /* Sticky nav so Queue/Analytics/etc. stay reachable while scrolling */
    .nav-buttons {
        gap: 6px; position: sticky; top: 0; z-index: 50;
        background: var(--bg); padding: 8px 12px;
        margin: 0 -12px 12px;
    }
    .btn-nav { flex: 1 1 calc(20% - 6px); text-align: center; padding: 10px 4px; font-size: 11px; min-height: 44px; }

    .platform-grid { gap: 8px; }
    .platform-option { padding: 12px; min-width: 0; flex: 1 1 calc(50% - 8px); }
    .platform-icon { width: 30px; height: 30px; }
    .platform-name { font-size: 13px; }
    .platform-handle { font-size: 11px; }

    .compose-textarea { font-size: 16px; min-height: 140px; padding: 14px; }
    .char-counter { bottom: 8px; right: 8px; }

    .post-actions { flex-direction: column; gap: 10px; }
    .post-actions button { width: 100%; }
    .autosave-indicator { margin-left: 0; text-align: center; }
    .schedule-row { flex-direction: column; align-items: stretch; }
    .schedule-row input[type="datetime-local"] { width: 100%; }

    .content-type-bar { gap: 6px; }
    .content-type-btn {
        padding: 10px 8px; font-size: 13px;
        flex: 1 1 calc(50% - 6px); justify-content: center; min-height: 48px;
    }

    .platform-tabs-bar {
        overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap;
        scroll-snap-type: x proximity;
        /* Fade edges to hint at horizontal scroll */
        mask-image: linear-gradient(to right, transparent 0, black 12px, black calc(100% - 12px), transparent 100%);
        -webkit-mask-image: linear-gradient(to right, transparent 0, black 12px, black calc(100% - 12px), transparent 100%);
        padding: 0 4px;
    }
    .platform-tab { scroll-snap-align: start; white-space: nowrap; padding: 10px 12px; font-size: 12px; min-height: 40px; }
    .platform-tab-name { max-width: 70px; }

    .media-upload-area { padding: 20px 10px; }
    .media-item { max-width: calc(50% - 10px); }
    .media-item img, .media-item video { max-height: 180px; }

    .char-limits { flex-wrap: wrap; gap: 8px; }

    .handle-mention-hint { font-size: 11.5px; padding: 8px 10px; }

    /* Link preview stacks vertically on narrow screens */
    .link-preview-card { flex-direction: column; gap: 10px; padding: 12px; }
    .link-preview-image { width: 100%; height: 160px; }

    /* ---- Modals: near-fullscreen on mobile ---- */
    .modal-overlay { padding: 0; align-items: stretch; }
    .modal-overlay.visible { justify-content: stretch; }
    .modal-content {
        max-width: 100%; width: 100%;
        max-height: 100dvh; min-height: 100dvh;
        border-radius: 0; margin: 0;
    }
    .modal-header {
        padding: 14px;
        padding-top: max(14px, env(safe-area-inset-top));
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }
    .modal-body {
        padding: 14px;
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    /* Diagnostic modal input groups stack */
    .input-group { flex-direction: column; align-items: stretch; gap: 6px; }
    .input-group label { min-width: 0; }
    .button-grid button { flex: 1 1 calc(50% - 10px); min-width: 0; }

    .queue-channel-select, .schedule-mgr-channel-select { min-width: 0; width: 100%; }
    .queue-controls { flex-direction: column; align-items: stretch; }
    .queue-controls button { width: 100%; }
    .analytics-controls { flex-direction: column; align-items: stretch; }
    .analytics-controls button { width: 100%; }
    .analytics-stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .analytics-stat-value { font-size: 22px; }
    .analytics-tabs { flex-wrap: wrap; }
    .analytics-tab { flex: 1 1 calc(33% - 4px); text-align: center; }

    .schedule-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .schedule-day-col { min-height: 100px; padding: 8px; }

    .contacts-toolbar { flex-direction: column; align-items: stretch; }
    .contact-form-grid { grid-template-columns: 1fr; }
    .contact-card-header { flex-direction: column; align-items: flex-start; gap: 6px; }
    .contact-card-actions { width: 100%; justify-content: flex-end; }

    /* Popups: keep inside viewport */
    .lookup-popup {
        position: fixed; top: 50%; left: 50%;
        right: auto; bottom: auto;
        transform: translate(-50%, -50%);
        width: calc(100vw - 32px); max-width: 360px;
    }
    .contacts-autocomplete {
        min-width: 0 !important;
        max-width: calc(100vw - 24px);
        left: 12px !important; right: 12px !important;
    }
    .profile-hover-card { width: 240px; }

    .draft-card-header { flex-direction: column; gap: 4px; align-items: flex-start; }
    .draft-save-row { flex-direction: column; align-items: stretch; }

    /* Calendar compact */
    .calendar-grid-container { gap: 2px; }
    .calendar-day { min-height: 64px; padding: 3px; font-size: 10px; }
    .calendar-day-num { font-size: 11px; margin-bottom: 2px; }
    .calendar-post { font-size: 9px; padding: 1px 3px; }
    .calendar-day-header { font-size: 10px; padding: 4px 0; }
}

/* ---- Small phones (e.g. iPhone SE, Pixel Fold folded) ---- */
@media (max-width: 480px) {
    h1 { font-size: 19px; }
    .auth-status { font-size: 12px; padding: 6px 12px; }
    .platform-option { flex: 1 1 100%; }
    .analytics-stat-grid { grid-template-columns: 1fr 1fr; }
    .schedule-grid { grid-template-columns: repeat(2, 1fr); }
    .content-type-btn { font-size: 12px; padding: 9px 6px; }
    .content-type-icon { font-size: 14px; }
    .btn-nav { flex: 1 1 calc(50% - 4px); font-size: 12px; }
    .button-grid button { flex: 1 1 100%; }
    .analytics-tab { flex: 1 1 100%; }
    .profile-hover-card { width: min(280px, calc(100vw - 24px)); }
    .compose-textarea { min-height: 120px; }
}

/* ---- Very small / folded Pixel Fold outer display ---- */
@media (max-width: 380px) {
    body { padding: 10px; }
    .card { padding: 12px; }
    .nav-buttons { margin: 0 -10px 10px; padding: 8px 10px; }
    h1 { font-size: 18px; }
    .content-type-btn { padding: 8px 4px; font-size: 11px; gap: 4px; }
    .content-type-icon { font-size: 13px; }
    .compose-textarea { min-height: 100px; }
    .analytics-stat-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .analytics-stat-value { font-size: 18px; }
    .analytics-stat-card { padding: 10px; }
    .schedule-grid { grid-template-columns: 1fr 1fr; gap: 4px; }
    .schedule-day-col { min-height: 80px; padding: 6px; }
    .schedule-day-header { font-size: 11px; }
    /* Calendar: stack to 4 columns on very narrow screens */
    .calendar-grid-container { grid-template-columns: repeat(4, 1fr); gap: 2px; }
    .calendar-day { min-height: 50px; padding: 2px; }
    .calendar-day-num { font-size: 10px; }
    .calendar-post { font-size: 8px; padding: 1px 2px; }
    .calendar-day-header { font-size: 9px; padding: 3px 0; }
    /* Profile card constrained */
    .profile-hover-card { width: calc(100vw - 24px); max-width: 260px; }
}

/* ---- Short viewports (phones in landscape) ---- */
@media (max-height: 500px) and (orientation: landscape) {
    .compose-textarea { min-height: 90px; }
    .media-upload-area { padding: 14px; }
    .upload-icon { font-size: 32px; margin-bottom: 4px; }
    .nav-buttons { position: static; }
}

/* ---- Pixel Fold unfolded landscape (~1080px wide, ~670px tall) ---- */
@media (min-width: 1000px) and (max-height: 750px) and (orientation: landscape) {
    .compose-textarea { min-height: 120px; }
    .media-upload-area { padding: 20px; }
    .nav-buttons { position: static; }
}

/* ---- Small interactive element touch targets ---- */
@media (hover: none) and (pointer: coarse) {
    .copy-btn { min-width: 36px; min-height: 36px; padding: 6px 12px; font-size: 13px; }
    .schedule-time-remove { min-width: 32px; min-height: 32px; font-size: 18px; padding: 4px; }
    .schedule-add-btn { min-height: 36px; padding: 6px 12px; font-size: 13px; }
    .link-preview-dismiss { width: 28px; height: 28px; font-size: 16px; }
    .media-remove { width: 32px; height: 32px; font-size: 18px; top: -10px; right: -10px; }
    .contact-search-link { width: 30px; height: 30px; }
    .lookup-results a { width: 36px; height: 36px; }
    .platform-checkbox { width: 24px; height: 24px; }
    .handle-dismiss-btn { min-width: 32px; min-height: 32px; font-size: 18px; padding: 4px; }
}

/* ---- Touch devices: soften hover styles that stick on tap ---- */
@media (hover: none) {
    .platform-option:hover { border-color: var(--border); }
    .platform-option.selected:hover { border-color: var(--primary); }
    .content-type-btn:hover { border-color: var(--border); color: var(--text-secondary); }
    .content-type-btn.active:hover { border-color: var(--primary); color: var(--primary-hover); }
    .btn-nav:hover { border-color: var(--border); color: var(--text-secondary); }
    .media-upload-area:hover { border-color: var(--border); background: transparent; }
}
