html, body { 
    height: 100%; 
    overflow: hidden; 
    font-family: 'Vazirmatn', sans-serif; 
    background-color: #f0f2f5; 
    color: #1c1c1e; 
}
.main-app-container { display: flex; flex-direction: column; height: 100vh; }
.content-layout { flex-grow: 1; display: flex; gap: 1.5rem; min-height: 0; padding: 1rem; padding-bottom: 5rem; }
@media (min-width: 768px) { .content-layout { padding-bottom: 1rem; } }
#formBriefContainer, #outputWrapper { background-color: #ffffff; border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border: 1px solid #e0e0e0; display: flex; flex-direction: column; overflow: hidden; }
#formBriefContainer { padding: 0; }
#geminiBriefForm { padding: 1.25rem 1.5rem; overflow-y: auto; flex-grow: 1; }
#outputContainer { padding: 1.25rem 1.5rem; overflow-y: auto; flex-grow: 1; display: flex; flex-direction: column; }
.form-section-collapsible { margin-bottom: 1.25rem; border: 1px solid #e0e0e0; border-radius: 12px; overflow: hidden; }
.form-section-header { background-color: #f7f7f7; padding: 0.875rem 1.25rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e0e0e0; }
.form-section-header h2 { font-size: 1.05rem; font-weight: 600; color: #333333; margin: 0; }
.form-section-content { padding: 1.25rem; background-color: white; max-height: 1500px; overflow: hidden; transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease-out; }
.form-section-content.collapsed { max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; border-top-width: 0; }
.form-section-toggle-icon { transition: transform 0.3s ease; color: #555555; width: 1.125rem; height: 1.125rem; }
.form-section-header.collapsed .form-section-toggle-icon { transform: rotate(-90deg); }
.form-label-container { display: flex; align-items: center; justify-content: flex-start; gap: 0.375rem; margin-bottom: 0.375rem; }
.form-label { font-weight: 500; color: #555555; font-size: 0.9rem; margin-bottom: 0; }
.help-icon { color: #6c757d; cursor: pointer; font-size: 0.75rem; border: 1px solid #adb5bd; border-radius: 50%; width: 1rem; height: 1rem; display: inline-flex; align-items: center; justify-content: center; transition: background-color 0.2s, color 0.2s; position: relative; order: -1; }
.help-icon:hover { background-color: #e9ecef; color: #007bff; }
.tooltip { position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%); background-color: #343a40; color: white; padding: 0.4rem 0.8rem; border-radius: 6px; font-size: 0.8rem; white-space: nowrap; z-index: 100; visibility: hidden; opacity: 0; transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out; pointer-events: none; }
.help-icon:hover > .tooltip { visibility: visible; opacity: 1; }
.form-input, .form-textarea, .form-select { width: 100%; padding: 0.75rem 1rem; border: 1px solid #cccccc; border-radius: 8px; box-shadow: inset 0 1px 2px rgba(0,0,0,0.04); transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out; background-color: #f9f9f9; font-size: 0.95rem; color: #1c1c1e; }
.form-input:focus, .form-textarea:focus, .form-select:focus { outline: none; border-color: #007bff; box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25); background-color: white; }
.form-select:disabled { background-color: #e9ecef; cursor: not-allowed; }
.form-textarea { min-height: 90px; }
.action-button { color: white; font-weight: 500; padding: 0.6rem 1.1rem; border-radius: 8px; transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out, box-shadow 0.2s ease-in-out; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin: 0 0.25rem; border: none; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 0.5rem; }
.action-button:hover { transform: translateY(-1px); box-shadow: 0 3px 6px rgba(0,0,0,0.1); }
.action-button:active { transform: translateY(0px); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.action-button:disabled { background-color: #ced4da !important; color: #6c757d !important; cursor: not-allowed; box-shadow: none; transform: translateY(0px); }
.submit-button-area { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #f0f0f0; display: flex; gap: 0.75rem; justify-content: stretch; align-items: stretch; text-align:center; }
.submit-button { background-color: #007bff; }
.submit-button:hover { background-color: #0069d9; }
.settings-button { background-color: #6c757d; }
.settings-button:hover { background-color: #5a6268; }
.submit-button-area .action-button { flex: 1 1 0; min-width: 0; height: 48px; display: flex; align-items: center; justify-content: center; text-align: center; }
.icon-btn { padding: 0.5rem; width: 2.25rem; height: 2.25rem; justify-content: center; }
.icon-btn svg { width: 1.25rem; height: 1.25rem; }
.regenerate-button { background-color: #ffc107; color: #212529; }
.regenerate-button:hover { background-color: #e0a800; }
.link-button { background-color: #17a2b8; }
.link-button:hover { background-color: #138496; }
.copy-button { background-color: #28a745; }
.copy-button:hover { background-color: #218838; }
.nav-button { background-color: #6c757d; }
.nav-button:hover { background-color: #5a6268; }
.applied-template-message { font-size: 0.875rem; color: #0f5132; background-color: #d1e7dd; border: 1px solid #badbcc; padding: 0.75rem; border-radius: 8px; margin-top: 0.75rem; }
#articleOutput { padding-bottom: 5rem;transition: opacity 0.3s ease-in-out; font-size: 0.95rem; line-height: 1.8; flex-grow: 1; overflow-y: auto; position: relative; }
#articleOutput h1, #articleOutput h2, #articleOutput h3, #articleOutput h4 { font-weight: 700; margin-top: 2em; margin-bottom: 0.8em; color: #1c1c1e; line-height: 1.4; }
#articleOutput h1 { font-size: 1.8rem; border-bottom: 2px solid #e0e0e0; padding-bottom: 0.4em; }
#articleOutput h2 { font-size: 1.5rem; border-bottom: 1px solid #e0e0e0; padding-bottom: 0.3em; }
#articleOutput h3 { font-size: 1.25rem; }
#articleOutput h4 { font-size: 1.1rem; }
#articleOutput p { margin-bottom: 1.2em; color: #333333; }
#articleOutput ul, #articleOutput ol { margin-bottom: 1.2em; margin-right: 2em; padding-right: 0.5em; list-style-position: outside; }
#articleOutput ul { list-style-type: disc; }
#articleOutput ol { list-style-type: decimal; }
#articleOutput li { margin-bottom: 0.6em; }
#articleOutput a { color: #0056b3; text-decoration: none; font-weight: 600; border-bottom: 1px dotted #0056b3; }
#articleOutput a:hover { color: #003d82; border-bottom-style: solid; }
#articleOutput table { width: 100%; border-collapse: collapse; margin-bottom: 1.5em; font-size: 0.9rem; }
#articleOutput th, #articleOutput td { border: 1px solid #dee2e6; padding: 0.75rem; text-align: right; }
#articleOutput thead th { background-color: #f8f9fa; font-weight: 600; color: #495057; }
#articleOutput tbody tr:nth-child(odd) { background-color: #fdfdff; }
#formMessagesContainer { position: fixed; bottom: 1rem; left: 1rem; z-index: 1050; max-width: 320px; }
.message-display { padding: 0.875rem 1rem; border-radius: 8px; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; box-shadow: 0 2px 10px rgba(0,0,0,0.1); transition: opacity 0.5s ease; }
.message-display.success { background-color: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }
.message-display.error { background-color: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.output-actions-container { padding: 0.75rem; background-color: #f8f9fa; border-bottom: 1px solid #e9ecef; margin-bottom: 1rem; border-radius: 12px 12px 0 0; }
.output-actions-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.output-actions-group-left { display: flex; gap: 0.5rem; order: 2; }
.output-actions-group-center { display: flex; align-items: center; gap: 0.5rem; margin: 0; order: 1; }
.output-actions-group-right { display: flex; gap: 0.5rem; order: 3; }
.version-info { font-size: 0.875rem; color: #6c757d; margin: auto 0.5rem; display: inline-flex; align-items: center; }
#loadingModalOverlay { position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.4); display: flex; justify-content: center; align-items: center; z-index: 2000; opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0.2s ease; }
#loadingModalOverlay.active { opacity: 1; visibility: visible; }
.loading-content-box { background-color: white; padding: 2rem; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); text-align: center; display: flex; flex-direction: column; align-items: center; width: 90%; max-width: 350px; }
.spinner { width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid #007bff; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 1rem; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-message { font-size: 1rem; color: #333; margin-bottom: 0.5rem; }
.loading-hint { font-size: 0.9rem; color: #6c757d; min-height: 2.5em; }
.modal-overlay { position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-content { background-color: white; padding: 1.5rem 2rem; border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); width: 90%; max-width: 600px; transform: translateY(20px) scale(0.95); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease; opacity: 0; max-height: 85vh; display: flex; flex-direction: column; }
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); opacity: 1; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e9ecef; padding-bottom: 1rem; margin-bottom: 1.5rem; }
.modal-title { font-size: 1.35rem; font-weight: 600; color: #1c1c1e; }
.modal-close-button { background: none; border: none; font-size: 1.75rem; cursor: pointer; color: #6c757d; padding: 0.25rem; line-height: 1; }
.modal-close-button:hover { color: #343a40; }
.modal-body { overflow-y: auto; flex-grow: 1; padding-right: 0.5rem; }
.modal-body .form-label { margin-top: 1rem; }
.modal-body .form-label:first-child { margin-top: 0; }
.modal-actions { margin-top: 2rem; text-align: left; padding-top: 1rem; border-top: 1px solid #e9ecef; }
.link-entry-group, .rewrite-selected-text-display { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.link-entry-group input { flex-grow: 1; }
.remove-link-button { background-color: #dc3545; padding: 0.5rem 0.75rem; font-size: 0.8rem; }
.remove-link-button:hover { background-color: #c82333; }
.rewrite-selected-text-display { background-color: #f8f9fa; padding: 0.75rem; border-radius: 8px; border: 1px solid #e0e0e0; font-style: italic; color: #495057; max-height: 100px; overflow-y: auto; }
#customContextMenu { position: absolute; background-color: white; border: 1px solid #ccc; box-shadow: 2px 2px 5px rgba(0,0,0,0.15); border-radius: 8px; padding: 0.5rem 0; z-index: 1001; min-width: 220px; }
#customContextMenu button { display: block; width: 100%; padding: 0.6rem 1rem; text-align: right; background: none; border: none; cursor: pointer; font-size: 0.9rem; }
#customContextMenu button:hover { background-color: #f0f2f5; }
#helpPanel { position: fixed; top: 0; left: -100%; width: 100%; max-width: 450px; height: 100%; background-color: #ffffff; box-shadow: 2px 0 15px rgba(0,0,0,0.1); z-index: 1050; transition: left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); display: flex; flex-direction: column; border-right: 1px solid #e0e0e0; }
#helpPanel.active { left: 0; }
.help-panel-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid #e9ecef; }
.help-panel-title { font-size: 1.25rem; font-weight: 600; }
.help-panel-close-button { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #6c757d; }
.help-panel-body { display: flex; flex-grow: 1; overflow: hidden; }
#helpPanelTabs { width: 200px; min-width: 200px; border-left: 1px solid #e9ecef; overflow-y: auto; padding: 1rem 0; background-color: #f8f9fa; }
#helpPanelTabs button { display: block; width: 100%; padding: 0.85rem 1.25rem; text-align: right; background: none; border: none; border-bottom: 1px solid #e9ecef; cursor: pointer; font-size: 0.95rem; color: #495057; white-space: normal; line-height: 1.4; }
#helpPanelTabs button:last-child { border-bottom: none; }
#helpPanelTabs button.active, #helpPanelTabs button:hover { background-color: #e9ecef; color: #007bff; font-weight: 500; }
#helpPanelContent { flex-grow: 1; padding: 1.5rem; overflow-y: auto; }
#helpPanelContent h4 { font-size: 1.1rem; font-weight: 600; color: #007bff; margin-bottom: 0.75rem; }
#helpPanelContent p, #helpPanelContent ul, #helpPanelContent ol { margin-bottom: 0.75rem; line-height: 1.6; font-size: 0.9rem; color: #343a40; }
#helpPanelContent ul, #helpPanelContent ol { margin-right: 1rem; }
#helpPanelContent li { margin-bottom: 0.3rem; }
.app-footer { margin-top: auto; padding: 1rem 1.5rem 0.75rem; text-align: center; font-size: 0.8rem; color: #6c757d; border-top: 1px solid #e9ecef; }
.app-footer a { color: #0056b3; text-decoration: none; font-weight: 500; }
.app-footer a:hover { text-decoration: underline; }
#imageSearchResults { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.5rem; margin-top: 1rem; }
#imageSearchResults img { width: 100%; height: 100px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 2px solid transparent; transition: border-color 0.2s; }
#imageSearchResults img:hover { border-color: #007bff; }
.mobile-nav { position: fixed; bottom: 0; left: 0; right: 0; background-color: #ffffff; box-shadow: 0 -2px 10px rgba(0,0,0,0.1); z-index: 100; }
.mobile-nav-btn { flex: 1; padding: 0.75rem; font-weight: 600; color: #6b7280; border-top: 3px solid transparent; }
.mobile-nav-btn.active { color: #4f46e5; border-top-color: #4f46e5; }
@media (max-width: 767px) {
    .main-app-container { position: relative; height: 100vh; overflow: hidden; }
    #formBriefContainer, #outputWrapper { position: fixed; top: 0; right: 0; left: 0; bottom: 56px; width: 100vw; height: calc(100vh - 56px); z-index: 10; background: #fff; overflow-y: auto; border-radius: 0 !important; margin: 0 !important; box-shadow: none !important; display: none; }
    #formBriefContainer.mobile-active, #outputWrapper.mobile-active { display: flex !important; flex-direction: column; }
    .mobile-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; height: 56px; background: #fff; border-top: 1px solid #e0e0e0; display: flex; }
    .output-actions-inner { flex-direction: column !important; gap: 0.75rem !important; align-items: center !important; justify-content: center !important; }
    .output-actions-group-center, .output-actions-group-right, .output-actions-group-left { width: 100%; justify-content: center !important; }
    .output-actions-group-center { order: 1; margin-bottom: 0.5rem; justify-content: center !important; }
    .output-actions-group-right { order: 2; margin-bottom: 0.5rem; justify-content: center !important; }
    .output-actions-group-left { order: 3; }
    .submit-button-area { flex-direction: row; gap: 0.75rem; }
}
@media (min-width: 768px) {
    .output-actions-inner { flex-direction: row !important; align-items: center !important; justify-content: flex-start !important; position: relative; }
    .output-actions-group-center { order: 1; margin: 0; justify-content: flex-end !important; }
    .output-actions-group-right { order: 2; position: absolute; left: 0; top: 0; height: 100%; margin-left: 0 !important; justify-content: flex-start !important; align-items: center; }
    .output-actions-group-left { order: 3; }
}
.usage-guide-box { padding: 1rem 0 5rem; background: none; border: none; box-shadow: none; max-width: none; margin: 0; }
.usage-guide-box h2 { font-size: 1.15rem; font-weight: bold; color: #2563eb; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.usage-guide-box table { border-collapse: collapse; width: 100%; margin-bottom: 1rem; }
.usage-guide-box th, .usage-guide-box td { border: 1px solid #e0e0e0; padding: 0.5rem 0.75rem; text-align: right; }
.usage-guide-box th { background: #f0f6ff; color: #2563eb; }
.usage-guide-box ul { margin-bottom: 1rem; color: #374151; }
.usage-guide-box button { margin-top: 0.5rem; }
.model-selection-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.model-radio-label { display: block; padding: 0.75rem; border: 1px solid #e0e0e0; border-radius: 8px; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s; }
.model-radio-label:has(input:checked) { border-color: #007bff; box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25); }
