:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --tg-safe-area-top: 0px;
    --tg-safe-area-bottom: 0px;
    --tg-content-safe-area-top: 0px;
    --tg-content-safe-area-bottom: 0px;
    --tg-viewport-stable-height: 100vh;
    
    --bg-color: #050508;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.06);
    --card-hover: rgba(255, 255, 255, 0.05);
    --text-color: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.5);
    --text-tertiary: rgba(255, 255, 255, 0.3);
    --accent: #0A84FF;
    --accent-soft: rgba(10, 132, 255, 0.15);
    --success: #00d26a;
    --success-soft: rgba(0, 210, 106, 0.15);
    --danger: #ff4757;
    --danger-soft: rgba(255, 71, 87, 0.15);
    --border-radius: 16px;
    --border-radius-sm: 12px;
    --border-radius-xs: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    touch-action: pan-x pan-y;
}

::-webkit-scrollbar {
    width: 0px;
    background: transparent;
    display: none;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
    position: fixed;
    background: var(--bg-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: pan-y;
}

body {
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(10, 132, 255, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(10, 132, 255, 0.05), transparent),
        radial-gradient(ellipse 50% 30% at 0% 100%, rgba(10, 132, 255, 0.03), transparent);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    background-position: center center;
    pointer-events: none;
    z-index: 0;
}

#app {
    width: 100%;
    max-width: 480px;
    height: var(--tg-viewport-stable-height, 100vh);
    max-height: var(--tg-viewport-stable-height, 100vh);
    overflow: hidden;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

@media (min-width: 481px) {
    html, body {
        display: flex;
        align-items: flex-start;
        justify-content: center;
        position: relative;
        overflow: auto;
    }
    
    #app {
        height: auto;
        min-height: var(--tg-viewport-stable-height, 100vh);
        max-height: none;
        border-left: 1px solid var(--card-border);
        border-right: 1px solid var(--card-border);
    }
    
    .view {
        height: auto;
        min-height: 100%;
    }
    
    .template-form-view {
        height: auto;
        min-height: 100%;
    }
    
    .form-content {
        flex: none;
    }
}

body.mobile-fullscreen {
    overflow-anchor: none;
}

body.mobile-fullscreen #app {
    height: 100vh;
    max-height: 100vh;
}

.hidden {
    display: none !important;
}

.view {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.view.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    position: relative;
}

.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.templates-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.templates-sticky-header {
    flex-shrink: 0;
    padding: 20px 16px 0;
    padding-top: calc(20px + var(--tg-content-safe-area-top, 0px));
    position: relative;
    z-index: 10;
}

.header {
    margin-bottom: 16px;
}

.header-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

.templates-actions {
    margin-bottom: 20px;
}

.search-wrapper {
    width: 100%;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    color: var(--text-color);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:active {
    transform: scale(0.98);
    background: var(--card-hover);
}

.action-btn i {
    font-size: 20px;
    opacity: 0.7;
}

.action-btn-secondary {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
}

.action-btn-primary {
    background: var(--accent);
    border: none;
}

.search-container {
    width: 100%;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.search-input-wrapper:focus-within {
    border-color: var(--accent);
    background: rgba(10, 132, 255, 0.05);
}

.search-icon {
    font-size: 20px;
    color: var(--text-secondary);
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-color);
    font-size: 15px;
    font-family: inherit;
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.search-clear {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
}

.search-clear.visible {
    display: flex;
}

.templates-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 4px;
}

.templates-section-title-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.templates-section-title-content i {
    font-size: 18px;
}

.mamonts-count {
    color: var(--text-tertiary);
    font-weight: 500;
}

.header-refresh-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-refresh-btn:active {
    transform: scale(0.95);
}

.header-refresh-btn.rotating {
    color: var(--accent);
}

.header-refresh-btn.rotating svg {
    animation: spin 0.8s linear infinite;
}

.header-refresh-btn svg {
    width: 18px;
    height: 18px;
}

.templates-scrollable-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 16px 16px;
    padding-bottom: calc(16px + var(--tg-content-safe-area-bottom, 0px));
    min-height: 0;
}

.templates-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.template-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-card:active {
    transform: scale(0.98);
    background: var(--card-hover);
}

.template-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
}

.mamont-item-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, rgba(10, 132, 255, 0.5) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.mamont-item-info {
    flex: 1;
    min-width: 0;
}

.template-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mamont-item-username {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.mamont-item-id {
    font-size: 12px;
    color: var(--text-tertiary);
    font-family: 'SF Mono', monospace;
}

.templates-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.templates-loading p {
    color: var(--text-secondary);
    font-size: 14px;
}

.templates-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--border-radius);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 28px;
    color: var(--text-tertiary);
}

.empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 6px;
}

.empty-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.mamonts-pagination {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn:active {
    transform: scale(0.98);
}

.pagination-btn i {
    font-size: 18px;
}

.template-form-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.form-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + var(--tg-content-safe-area-top, 0px));
    border-bottom: 1px solid var(--card-border);
    position: relative;
    z-index: 100;
    min-height: 56px;
    flex-shrink: 0;
}

.form-back-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-size: 20px;
}

.form-back-btn:active {
    transform: scale(0.95);
}

.form-title {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
    margin: 0;
}

.form-header-spacer {
    width: 40px;
    flex-shrink: 0;
}

.form-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 16px;
    padding-bottom: calc(20px + var(--tg-content-safe-area-bottom, 0px));
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.mamont-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
}

.mamont-card-header-compact {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--card-border);
}

.mamont-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, rgba(10, 132, 255, 0.5) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.mamont-info-compact {
    flex: 1;
    min-width: 0;
}

.mamont-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mamont-username {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 2px;
    cursor: pointer;
}

.mamont-username:hover {
    color: var(--accent);
}

.mamont-id {
    font-size: 11px;
    color: var(--text-tertiary);
}

.mamont-id code {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', monospace;
    font-size: 11px;
    cursor: pointer;
}

.mamont-id code:hover {
    color: var(--accent);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    padding: 12px 14px;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.stat-card-value {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card-value.primary {
    color: var(--accent);
}

.detail-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    padding: 2px 14px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--card-border);
    min-height: 44px;
}

.info-item:last-child,
.info-item:has(+ .info-item.hidden),
.info-item:has(+ .hidden) {
    border-bottom: none;
}

.info-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.info-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.action-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0;
    padding-bottom: 20px;
}

.action-buttons-grid .action-btn {
    padding: 14px 12px;
    font-size: 13px;
    gap: 8px;
}

.action-buttons-grid .action-btn i {
    font-size: 18px;
}

.reminder-template-btn.active {
    border-color: var(--accent);
    background: rgba(10, 132, 255, 0.12);
    color: #ffffff;
}

.form-step {
    margin-bottom: 20px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.form-label-icon {
    font-size: 20px;
    color: var(--accent);
}

.form-label-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
}

.form-label-required {
    color: var(--danger);
}

.form-input {
    width: 100%;
    padding: 14px 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-color);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.form-input:focus {
    border-color: var(--accent);
    background: rgba(10, 132, 255, 0.05);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.5;
}

.form-hint-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 12px;
}

.form-hint-info {
    margin-top: 12px;
    padding: 12px;
    background: var(--accent-soft);
    border-radius: var(--border-radius-xs);
    border-left: 3px solid var(--accent);
}

.form-hint-info strong {
    color: var(--accent);
    display: block;
    margin-bottom: 4px;
}

.form-hint-info span {
    color: var(--text-secondary);
    line-height: 1.5;
}

.webapp-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.webapp-toggle-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.webapp-toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.webapp-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.webapp-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    transition: 0.2s;
}

.webapp-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.2s;
}

.webapp-toggle input:checked + .webapp-toggle-slider {
    background: var(--accent);
}

.webapp-toggle input:checked + .webapp-toggle-slider:before {
    transform: translateX(20px);
    background: #fff;
}

.formatting-toolbar {
    display: flex;
    gap: 6px;
    padding: 10px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-xs);
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.format-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

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

.format-btn:active {
    transform: scale(0.95);
}

.format-btn-clear {
    flex: 1;
    min-width: 36px;
}

.textarea-editor-wrapper {
    position: relative;
}

.form-textarea-editor {
    width: 100%;
    min-height: 120px;
    max-height: 400px;
    padding: 14px 18px;
    padding-bottom: 40px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-color);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.6;
    outline: none;
    overflow-y: auto;
    transition: border-color 0.2s ease, background 0.2s ease;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.form-textarea-editor:focus {
    border-color: var(--accent);
    background: rgba(10, 132, 255, 0.05);
}

.form-textarea-editor:empty:before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
    pointer-events: none;
}

.form-textarea-editor b { font-weight: bold; }
.form-textarea-editor i { font-style: italic; }
.form-textarea-editor u { text-decoration: underline; }
.form-textarea-editor s { text-decoration: line-through; }
.form-textarea-editor code {
    font-family: 'SF Mono', monospace;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
}
.form-textarea-editor a {
    color: var(--accent);
    text-decoration: underline;
}
.form-textarea-editor blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 12px;
    margin: 8px 0;
    background: var(--accent-soft);
    border-radius: 4px;
    font-style: italic;
}

.resize-handle {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: 6px;
    cursor: nwse-resize;
    opacity: 0.6;
    transition: opacity 0.2s;
    font-size: 14px;
    color: var(--accent);
}

.resize-handle:hover {
    opacity: 1;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--card-border);
}

.form-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    border-radius: var(--border-radius-sm);
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-btn:active {
    transform: scale(0.98);
}

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

.form-btn-primary {
    background: var(--accent);
    color: #fff;
}

.form-btn i {
    font-size: 18px;
}

.messages-history-section {
    margin-top: 24px;
}

.messages-history-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.messages-history-header i {
    font-size: 16px;
    color: var(--accent);
}

.messages-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-history-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
}

.message-history-text {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.message-history-text b, .message-history-text strong { font-weight: 600; color: var(--text-color); }
.message-history-text i, .message-history-text em { font-style: italic; }
.message-history-text u { text-decoration: underline; }
.message-history-text s { text-decoration: line-through; }
.message-history-text code {
    font-family: 'SF Mono', monospace;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 12px;
}
.message-history-text a { color: var(--accent); }
.message-history-text blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 12px;
    margin: 8px 0;
    background: var(--accent-soft);
    border-radius: 4px;
}

.message-history-use {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.message-history-use:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

.message-history-use:active {
    transform: scale(0.95);
}

.messages-loading, .messages-empty, .messages-error {
    padding: 30px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.messages-pagination {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.messages-pagination .pagination-btn {
    padding: 12px;
    font-size: 13px;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(5, 5, 8, 0.9);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.modal-content {
    position: relative;
    background: #0d0d10;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 24px;
    max-width: 320px;
    width: 100%;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-title-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-title-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: var(--border-radius-sm);
    color: var(--accent);
    font-size: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
}

.modal-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn:active {
    transform: scale(0.98);
}

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

.modal-btn-primary {
    background: var(--accent);
    color: #fff;
}

.modal-btn i {
    font-size: 16px;
}

.notifications-container {
    position: fixed;
    top: calc(70px + var(--tg-content-safe-area-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: calc(100% - 32px);
    width: 100%;
    padding: 0 16px;
    align-items: center;
}

.notification {
    background: #0d0d10;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    animation: notificationIn 0.3s ease;
    max-width: 340px;
    width: 100%;
}

@keyframes notificationIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.notification.slide-out {
    animation: notificationOut 0.3s ease forwards;
}

@keyframes notificationOut {
    to {
        transform: translateY(-20px);
        opacity: 0;
    }
}

.notification-content {
    flex: 1;
}

.notification-message {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    text-align: center;
}

.notification-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
}

.notification-progress-bar {
    height: 100%;
    width: 100%;
    transform-origin: left;
    animation: notificationProgress linear;
}

.notification.success .notification-progress-bar {
    background: var(--success);
}

.notification.error .notification-progress-bar {
    background: var(--danger);
}

@keyframes notificationProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}
