/* ═══════════════════════════════════════════════════
   Lisan — Component Styles
   Cards, Inputs, Tables, Chat, Explore Panel
   ═══════════════════════════════════════════════════ */

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   CARDS
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-gold), transparent);
    opacity: 0;
    transition: var(--transition);
}

.card:hover::before {
    opacity: 1;
}

.card-title {
    font-family: var(--font-arabic);
    font-size: 1.2rem;
    color: var(--gold-primary);
    margin-bottom: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    direction: rtl;
}

.card-title .icon {
    font-size: 1rem;
    opacity: 0.7;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   INPUTS & TEXTAREA
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.input-section textarea,
.spell-input textarea {
    width: 100%;
    min-height: 110px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-arabic);
    font-size: 1.15rem;
    line-height: 2;
    padding: 1rem 1.15rem;
    resize: vertical;
    direction: rtl;
    transition: var(--transition);
}

.input-section textarea:focus,
.spell-input textarea:focus,
.meaning-search input:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 0 3px var(--gold-dim);
}

.input-section textarea::placeholder,
.spell-input textarea::placeholder,
.meaning-search input::placeholder {
    color: var(--text-dim);
    font-family: var(--font-arabic);
}

/* ── Power Level Selector ──────────────────────── */
.power-level-group {
    margin: 1.15rem 0 0.75rem;
}

.power-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.power-selector {
    display: flex;
    gap: 0.5rem;
}

.power-btn {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.power-btn:hover {
    border-color: var(--gold-dim);
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.power-btn.active[data-power="strong"] {
    background: rgba(201, 162, 39, 0.12);
    border-color: var(--gold-primary);
    color: var(--gold-primary);
    font-weight: 600;
}

.power-btn.active[data-power="med"] {
    background: rgba(52, 152, 219, 0.12);
    border-color: #5dade2;
    color: #5dade2;
    font-weight: 600;
}

.power-btn.active[data-power="low"] {
    background: rgba(39, 174, 96, 0.12);
    border-color: #27ae60;
    color: #27ae60;
    font-weight: 600;
}

/* ── Fallback Note ─────────────────────────────── */
.fallback-note {
    margin-top: 0.5rem;
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    color: #e67e22;
    background: rgba(230, 126, 34, 0.08);
    border: 1px solid rgba(230, 126, 34, 0.15);
    border-radius: 4px;
    direction: rtl;
    line-height: 1.5;
}

.fallback-note .extraction-label {
    display: inline-block;
    margin-top: 0.2rem;
    padding: 0.1rem 0.45rem;
    font-size: 0.72rem;
    border-radius: 3px;
    font-weight: 600;
}

.fallback-note .extraction-label.strong {
    color: var(--gold-primary);
    background: var(--gold-dim);
}

.fallback-note .extraction-label.low {
    color: #27ae60;
    background: rgba(39, 174, 96, 0.12);
}

/* ── Mode Selector ─────────────────────────────── */
.mode-selector {
    display: flex;
    gap: 0.6rem;
    margin: 0.75rem 0 1.15rem;
}

.mode-btn {
    flex: 1;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 0.92rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.mode-btn:hover {
    border-color: var(--gold-dim);
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--gold-dim);
    border-color: var(--gold-primary);
    color: var(--gold-primary);
    font-weight: 600;
}

/* ── Action Buttons ────────────────────────────── */
.actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.75rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-secondary));
    color: var(--bg-primary);
    flex: 1;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-gold), 0 6px 20px rgba(201, 162, 39, 0.25);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    border-color: var(--gold-dim);
    color: var(--text-primary);
}

/* ── Upload Zone ───────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 1.75rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 1rem;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--gold-primary);
    background: var(--gold-dim);
}

.upload-zone .upload-icon {
    font-size: 2.2rem;
    color: var(--gold-dim);
    margin-bottom: 0.5rem;
    display: block;
    transition: var(--transition);
}

.upload-zone:hover .upload-icon {
    color: var(--gold-primary);
    transform: scale(1.05);
}

.upload-zone p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.upload-zone .supported {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.35rem;
}

.upload-zone input[type="file"] {
    display: none;
}

/* ── Upload Preview ────────────────────────────── */
.upload-preview {
    display: none;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.upload-preview.visible {
    display: flex;
}

.preview-thumbnail {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.preview-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.upload-preview .filename {
    color: var(--gold-secondary);
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-show-btn {
    background: var(--gold-dim);
    border: 1px solid var(--border-gold);
    color: var(--gold-primary);
    padding: 0.18rem 0.55rem;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    cursor: pointer;
    transition: var(--transition);
    align-self: flex-start;
}

.preview-show-btn:hover {
    background: var(--gold-primary);
    color: var(--bg-primary);
}

.upload-preview .remove-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.2rem;
    transition: var(--transition);
    flex-shrink: 0;
}

.upload-preview .remove-btn:hover {
    transform: scale(1.2);
}

/* ── Image Modal ───────────────────────────────── */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.image-modal.visible {
    display: flex;
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius);
    border: 2px solid var(--border-color);
    object-fit: contain;
}

.image-modal-close {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.image-modal-close:hover {
    transform: scale(1.1);
    background: #c0392b;
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   TIER BADGE
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tier-badge.advanced {
    background: rgba(201, 162, 39, 0.12);
    color: var(--gold-primary);
    border: 1px solid rgba(201, 162, 39, 0.25);
}

.tier-badge.standard {
    background: rgba(52, 152, 219, 0.12);
    color: #5dade2;
    border: 1px solid rgba(52, 152, 219, 0.25);
}

.tier-badge.local {
    background: rgba(39, 174, 96, 0.12);
    color: #27ae60;
    border: 1px solid rgba(39, 174, 96, 0.25);
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   RESULTS SECTION
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.results-section {
    display: none;
}

.results-section.visible {
    display: block;
    animation: fadeInUp 0.45s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.15rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sentence-display {
    font-family: var(--font-arabic);
    font-size: 1.3rem;
    color: var(--gold-secondary);
    padding: 0.9rem 1.15rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border-right: 3px solid var(--gold-primary);
    margin-bottom: 1.15rem;
    line-height: 2.2;
    direction: rtl;
}

.sentence-type {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

/* ── Analysis Table ────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.analysis-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 480px;
}

.analysis-table thead {
    background: var(--bg-secondary);
}

.analysis-table th {
    padding: 0.75rem 0.85rem;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gold-primary);
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.analysis-table td {
    padding: 0.75rem 0.85rem;
    font-family: var(--font-arabic);
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    transition: var(--transition);
}

.analysis-table tbody tr {
    transition: var(--transition);
}

.analysis-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.analysis-table tbody tr:last-child td {
    border-bottom: none;
}

.word-cell {
    font-weight: 700;
    color: var(--gold-secondary);
    cursor: pointer;
}

.word-cell:hover {
    color: var(--gold-primary);
    text-decoration: underline;
    text-decoration-color: var(--gold-dim);
    text-underline-offset: 4px;
}

.explain-btn {
    background: var(--gold-dim);
    border: 1px solid var(--border-gold);
    color: var(--gold-primary);
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.explain-btn:hover {
    background: var(--gold-primary);
    color: var(--bg-primary);
}

.explanation-row {
    display: none;
}

.explanation-row.visible {
    display: table-row;
}

.explanation-cell {
    background: var(--bg-input) !important;
    padding: 1rem !important;
    border-right: 3px solid var(--gold-dim);
}

.explanation-text {
    font-family: var(--font-arabic);
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.9;
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   WORD EXPLORATION PANEL
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.explore-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 380px;
    max-width: 90vw;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.5);
    z-index: 500;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 1.75rem;
}

.explore-panel.open {
    transform: translateX(0);
}

.explore-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

.explore-header h3 {
    font-family: var(--font-arabic);
    color: var(--gold-primary);
    font-size: 1.15rem;
}

.explore-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.explore-close:hover {
    color: var(--text-primary);
}

.panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 499;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.panel-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.explore-word-title {
    font-family: var(--font-arabic);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gold-primary);
    margin-bottom: 1.25rem;
    text-align: center;
}

.explore-field {
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

.explore-label {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-weight: 600;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.explore-value {
    font-family: var(--font-arabic);
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.8;
}

.explore-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.explore-tag {
    background: var(--gold-dim);
    color: var(--gold-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: var(--font-arabic);
}

.explore-loading {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-dim);
    font-family: var(--font-arabic);
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   CHAT SECTION
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.chat-section {
    display: none;
    direction: rtl;
}

.chat-section.visible {
    display: block;
    animation: fadeInUp 0.45s ease;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
    direction: rtl;
}

.chat-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.chat-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    cursor: pointer;
    transition: var(--transition);
}

.chat-clear-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(231, 76, 60, 0.08);
}

.chat-power-select {
    padding: 0.3rem 0.65rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    direction: rtl;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.5rem center;
    padding-left: 1.4rem;
}

.chat-power-select:focus {
    outline: none;
    border-color: var(--gold-primary);
}

.chat-messages {
    max-height: 380px;
    overflow-y: auto;
    padding: 0.85rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    direction: rtl;
}

.chat-message {
    max-width: 85%;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-arabic);
    font-size: 0.92rem;
    line-height: 1.85;
    animation: fadeIn 0.3s ease;
    direction: rtl;
    text-align: right;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    align-self: flex-end;
    background: var(--gold-dim);
    color: var(--text-primary);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-sm) var(--radius-sm) 4px var(--radius-sm);
}

.chat-message.assistant {
    align-self: flex-start;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm) var(--radius-sm) var(--radius-sm) 4px;
}

/* ── Message Actions ───────────────────────────── */
.msg-actions {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.35rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chat-message:hover .msg-actions {
    opacity: 1;
}

.msg-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-dim);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}

.msg-action-btn:hover {
    border-color: var(--gold-primary);
    color: var(--gold-primary);
    background: var(--gold-dim);
}

.msg-action-btn.copied {
    border-color: var(--success);
    color: var(--success);
    background: rgba(39, 174, 96, 0.08);
}

/* ── Chat Markdown ─────────────────────────────── */
.chat-message.assistant h1,
.chat-message.assistant h2,
.chat-message.assistant h3 {
    color: var(--gold-secondary);
    margin: 0.4rem 0 0.25rem;
    font-family: var(--font-arabic);
}

.chat-message.assistant h1 {
    font-size: 1.05rem;
}

.chat-message.assistant h2 {
    font-size: 0.98rem;
}

.chat-message.assistant h3 {
    font-size: 0.92rem;
}

.chat-message.assistant p {
    margin: 0.25rem 0;
}

.chat-message.assistant ul,
.chat-message.assistant ol {
    padding-right: 1.15rem;
    margin: 0.25rem 0;
}

.chat-message.assistant li {
    margin: 0.1rem 0;
}

.chat-message.assistant code {
    background: rgba(255, 255, 255, 0.06);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.88em;
    font-family: monospace;
    color: var(--gold-secondary);
}

.chat-message.assistant pre {
    background: rgba(0, 0, 0, 0.25);
    padding: 0.7rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.4rem 0;
    direction: ltr;
    text-align: left;
}

.chat-message.assistant pre code {
    background: none;
    padding: 0;
}

.chat-message.assistant strong {
    color: var(--gold-secondary);
    font-weight: 700;
}

.chat-message.assistant blockquote {
    border-right: 3px solid var(--gold-dim);
    padding-right: 0.7rem;
    margin: 0.4rem 0;
    color: var(--text-dim);
    font-style: italic;
}

/* ── Typing Indicator ──────────────────────────── */
.chat-message.typing {
    align-self: flex-start;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 0.8rem 1.2rem;
    display: flex;
    gap: 0.35rem;
    border-radius: var(--radius-sm) var(--radius-sm) var(--radius-sm) 4px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* ── Chat Input Area ───────────────────────────── */
.chat-input-area {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.85rem;
    direction: rtl;
}

.chat-input-area input {
    flex: 1;
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-arabic);
    font-size: 0.92rem;
    transition: var(--transition);
    direction: rtl;
}

.chat-input-area input:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 0 3px var(--gold-dim);
}

.chat-send-btn {
    padding: 0.7rem 1.25rem;
    background: var(--gold-dim);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-sm);
    color: var(--gold-primary);
    font-family: var(--font-ui);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.chat-send-btn:hover {
    background: var(--gold-primary);
    color: var(--bg-primary);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   SPELLING PAGE
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.spell-results {
    display: none;
}

.spell-results.visible {
    display: block;
    animation: fadeInUp 0.45s ease;
}

.spell-summary {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.spell-stat {
    flex: 1;
    min-width: 120px;
    padding: 0.85rem;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border-color);
}

.spell-stat .stat-num {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: var(--font-arabic);
}

.spell-stat .stat-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.15rem;
}

.spell-stat.correct {
    background: rgba(39, 174, 96, 0.08);
    border-color: rgba(39, 174, 96, 0.2);
}

.spell-stat.correct .stat-num {
    color: var(--success);
}

.spell-stat.wrong {
    background: rgba(231, 76, 60, 0.08);
    border-color: rgba(231, 76, 60, 0.2);
}

.spell-stat.wrong .stat-num {
    color: var(--danger);
}

.spell-word-card {
    padding: 1rem;
    margin-bottom: 0.65rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    transition: var(--transition);
}

.spell-word-card:hover {
    background: var(--bg-card-hover);
}

.spell-word-card.incorrect {
    border-color: rgba(231, 76, 60, 0.25);
    border-right: 3px solid var(--danger);
}

.spell-word-card.correct-word {
    border-color: rgba(39, 174, 96, 0.25);
    border-right: 3px solid var(--success);
}

.spell-word-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.spell-original {
    font-family: var(--font-arabic);
    font-size: 1.15rem;
    font-weight: 700;
}

.spell-original.wrong {
    color: var(--danger);
    text-decoration: line-through;
}

.spell-original.ok {
    color: var(--success);
}

.spell-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}

.spell-badge.error {
    background: rgba(231, 76, 60, 0.12);
    color: var(--danger);
}

.spell-badge.pass {
    background: rgba(39, 174, 96, 0.12);
    color: var(--success);
}

.spell-correction {
    font-family: var(--font-arabic);
    font-size: 1.05rem;
    color: var(--gold-secondary);
    margin: 0.3rem 0;
}

.spell-correction strong {
    color: var(--success);
}

.spell-reason {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.7;
    font-family: var(--font-arabic);
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MEANINGS PAGE
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.meaning-search {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.meaning-search input {
    flex: 1;
    padding: 0.85rem 1.15rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-arabic);
    font-size: 1.15rem;
    direction: rtl;
    transition: var(--transition);
}

.meaning-results {
    display: none;
}

.meaning-results.visible {
    display: block;
    animation: fadeInUp 0.45s ease;
}

.meaning-word-title {
    font-family: var(--font-arabic);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold-primary);
    text-align: center;
    margin-bottom: 0.5rem;
}

.meaning-word-type {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
}

.meaning-block {
    margin-bottom: 1.5rem;
}

.meaning-block-title {
    font-family: var(--font-arabic);
    font-size: 1rem;
    font-weight: 600;
    color: var(--gold-primary);
    margin-bottom: 0.65rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.meaning-text {
    font-family: var(--font-arabic);
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 2;
    padding: 0.85rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border-right: 3px solid var(--gold-dim);
}

.meaning-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.meaning-tag {
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-family: var(--font-arabic);
    font-size: 0.92rem;
    transition: var(--transition);
    cursor: default;
}

.meaning-tag.synonym {
    background: rgba(52, 152, 219, 0.1);
    border: 1px solid rgba(52, 152, 219, 0.2);
    color: #5dade2;
}

.meaning-tag.antonym {
    background: rgba(231, 76, 60, 0.08);
    border: 1px solid rgba(231, 76, 60, 0.15);
    color: #e67e73;
}

.meaning-example {
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border-right: 3px solid rgba(52, 152, 219, 0.3);
    margin-bottom: 0.5rem;
    font-family: var(--font-arabic);
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.9;
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   RESPONSIVE
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 768px) {
    .card {
        padding: 1.25rem;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .power-selector {
        flex-wrap: wrap;
    }

    .power-btn {
        flex: 1 1 30%;
    }

    .mode-selector {
        flex-direction: column;
        gap: 0.4rem;
    }

    .analysis-table {
        min-width: 400px;
    }

    .explore-panel {
        width: 320px;
    }

    .chat-message {
        max-width: 92%;
    }

    .meaning-search {
        flex-direction: column;
    }

    .spell-summary {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 0.85rem;
    }

    .card-title {
        font-size: 1rem;
    }

    .sentence-display {
        font-size: 1.05rem;
    }

    .explore-panel {
        width: 100%;
        max-width: 100%;
    }

    .dict-checkboxes {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.4rem;
    }

    .tashkeel-full-text {
        font-size: 1.2rem;
        padding: 0.85rem 1rem;
    }
}

@media (max-width: 360px) {
    .card {
        padding: 0.7rem;
        border-radius: 10px;
    }

    .card-title {
        font-size: 0.92rem;
        gap: 0.35rem;
    }

    .dict-checkboxes {
        grid-template-columns: 1fr;
    }

    .power-selector {
        gap: 0.25rem;
    }

    .power-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    .rule-item {
        padding: 0.75rem 0.85rem;
    }

    .tab-btn {
        padding: 0.45rem 0.85rem;
        font-size: 0.8rem;
    }
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   TASHKEEL PAGE
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.tashkeel-results { display: none; }
.tashkeel-results.visible { display: block; animation: fadeInUp 0.45s ease; }

.tashkeel-full-text {
    font-family: var(--font-arabic);
    font-size: 1.5rem;
    line-height: 2.5;
    color: var(--gold-primary);
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 1.25rem 1.5rem;
    border-right: 4px solid var(--gold-primary);
    direction: rtl;
    text-align: right;
    letter-spacing: 0.5px;
}

.tashkeel-results textarea {
    width: 100%;
    min-height: 110px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-arabic);
    font-size: 1.15rem;
    line-height: 2;
    padding: 1rem 1.15rem;
    resize: vertical;
    direction: rtl;
    transition: var(--transition);
}

.tashkeel-results textarea:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 0 3px var(--gold-dim);
}

.copy-btn {
    font-family: var(--font-ui);
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MORPHOLOGY PAGE
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.morph-results { display: none; }
.morph-results.visible { display: block; animation: fadeInUp 0.45s ease; }

.morph-word-title {
    font-family: var(--font-arabic);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gold-primary);
    margin-bottom: 0.35rem;
}

.morph-word-type {
    font-family: var(--font-arabic);
    font-size: 0.95rem;
    color: var(--text-dim);
    margin-bottom: 1.25rem;
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   DICTIONARY PAGE
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.dict-results { display: none; }
.dict-results.visible { display: block; animation: fadeInUp 0.45s ease; }

.dict-word-title {
    font-family: var(--font-arabic);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gold-primary);
    margin-bottom: 1.25rem;
}

.dict-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.dict-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-arabic);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.dict-checkbox:hover {
    border-color: var(--gold-dim);
    color: var(--text-primary);
}

.dict-checkbox input[type="checkbox"] {
    accent-color: var(--gold-primary);
    width: 16px;
    height: 16px;
}

.dict-checkbox input[type="checkbox"]:checked + span {
    color: var(--gold-primary);
    font-weight: 600;
}

.dict-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.btn-link {
    background: none;
    border: none;
    color: var(--gold-primary);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: underline;
    text-underline-offset: 3px;
    padding: 0;
}

.btn-link:hover {
    color: var(--gold-secondary);
}