body {
    display: block;
    padding: 0;
}

.app-page-light {
    background:
        linear-gradient(180deg, #fbfbf8 0%, #f7f8f5 100%);
}

.app-shell {
    width: min(1320px, calc(100% - 48px));
    margin: 0 auto;
}

.app-shell-light {
    padding: 26px 0 28px;
}

.panel {
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}

.page-login-link {
    position: fixed;
    top: 26px;
    right: 24px;
    z-index: 1100;
}

.page-top-link,
.admin-link-button,
.admin-edit-link,
.admin-delete-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.78);
    color: var(--primary);
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
    box-shadow: 0 8px 24px rgba(30, 52, 73, 0.05);
}

.page-top-link:hover,
.admin-link-button:hover,
.admin-edit-link:hover,
.admin-delete-button:hover {
    transform: translateY(-1px);
    background: #ffffff;
    border-color: rgba(67, 97, 125, 0.34);
}

.admin-delete-button {
    color: #9d4e4e;
    border-color: rgba(157, 78, 78, 0.24);
    background: rgba(255, 255, 255, 0.9);
}

.page-header,
.panel-header {
    padding: 0;
    margin-bottom: 34px;
    background: transparent;
    border-bottom: none;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.page-header-chat {
    align-items: center;
}

.page-brand-row,
.panel-title-group {
    display: flex;
    align-items: center;
    gap: 24px;
    min-width: 0;
}

.brand-logo-image {
    width: auto;
    height: 96px;
    flex: 0 0 auto;
    object-fit: contain;
}

.page-brand-text {
    color: #111315;
    font-size: clamp(1.15rem, 1vw + 0.95rem, 1.45rem);
    font-weight: 500;
    line-height: 1.2;
}

.page-header-actions,
.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.page-header-actions-chat {
    padding-top: 6px;
}

.header-control-button,
.header-language-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    color: var(--muted-text-color);
    background: transparent;
    border: none;
    padding: 0;
}

.header-control-button {
    cursor: pointer;
}

.header-control-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.header-divider {
    width: 1px;
    height: 34px;
    background: rgba(67, 97, 125, 0.28);
}

.panel-title {
    margin: 0;
    font-size: 1.95rem;
    font-weight: 500;
    color: var(--primary);
}

.panel-title-icon {
    width: 70px;
    height: 70px;
    flex: 0 0 70px;
}

.avatar-badge {
    border-radius: 18px;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
}

.avatar-badge img,
.panel-title-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: none;
}

.avatar-badge-hero {
    width: min(300px, 26vw);
    height: min(300px, 26vw);
    flex-basis: auto;
}

.chat-shell {
    min-height: 100vh;
}

.chat-panel {
    height: calc(var(--app-height, 100vh) - 54px);
    max-height: calc(var(--app-height, 100vh) - 54px);
    min-height: calc(var(--app-height, 100vh) - 54px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(220px, 0.8fr);
    gap: 36px;
    align-items: center;
    margin-bottom: 22px;
    max-height: 420px;
    overflow: hidden;
    transition: margin-bottom 0.42s ease, max-height 0.5s ease, opacity 0.36s ease, transform 0.5s ease;
}

.chat-hero-copy {
    display: grid;
    gap: 22px;
    align-content: start;
    transition: opacity 0.3s ease, transform 0.38s ease, max-height 0.42s ease;
    max-height: 420px;
    overflow: hidden;
}

.chat-hero-title,
.page-section-title {
    margin: 0;
    color: var(--primary);
    font-size: clamp(2.8rem, 4vw, 5.25rem);
    line-height: 1.05;
    font-weight: 400;
    letter-spacing: 0;
}

.chat-hero-text,
.page-section-text {
    margin: 0;
    max-width: 48ch;
    color: #111315;
    font-size: clamp(1.18rem, 0.8vw + 1rem, 1.45rem);
    line-height: 1.45;
}

.chat-hero-visual {
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.32s ease, transform 0.42s ease;
}

.chat-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.42s ease;
}

.chat-side-avatar {
    display: none;
}

.chat-side-avatar-inner {
    width: 96px;
    height: 96px;
}

.chat-side-avatar-inner img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-content {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
    height: 100%;
    padding-top: 8px;
}

.chat-page--conversation-active .chat-hero {
    margin-bottom: 0;
    max-height: 0;
    opacity: 0;
    transform: translateX(-120px);
}

.chat-page--conversation-active .chat-hero-copy {
    opacity: 0;
    transform: translateX(-160px);
    max-height: 0;
}

.chat-page--conversation-active .chat-hero-visual {
    opacity: 0;
    transform: translateX(-200px) scale(0.88);
    pointer-events: none;
}

.chat-page--conversation-active .chat-main {
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 22px;
    align-items: stretch;
    transform: translateY(-8px);
}

.chat-page--conversation-active .chat-side-avatar {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    animation: fadeIn 0.32s ease;
}

.page-footer-link-row {
    padding: 16px 0 0;
    border-top: 1px solid rgba(67, 97, 125, 0.22);
}

.page-footer-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 1.35rem;
}

.page-footer-link:hover {
    text-decoration: underline;
}

.login-modal {
    position: fixed;
    inset: 0;
    z-index: 1150;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(16, 26, 37, 0.22);
    backdrop-filter: blur(8px);
}

.login-modal__card,
.admin-modal {
    padding: 28px;
    border: 1px solid rgba(67, 97, 125, 0.18);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 28px 72px rgba(30, 52, 73, 0.12);
    display: grid;
    gap: 18px;
}

.login-modal__card {
    width: min(540px, 100%);
}

.login-modal__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.auth-shell {
    width: min(640px, 100%);
}

.auth-panel-body,
.info-panel-body,
.admin-panel-body,
.admin-modal-body {
    padding: 0;
    display: grid;
    gap: 22px;
}

.page-section-intro {
    display: grid;
    gap: 10px;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-field {
    display: grid;
    gap: 8px;
}

.auth-field span,
.admin-detail-label {
    color: var(--muted-text-color);
    font-size: 0.9rem;
    font-weight: 600;
}

.auth-field input,
.admin-textarea {
    width: 100%;
    min-height: 46px;
    padding: 0 16px;
    border: 1px solid rgba(67, 97, 125, 0.18);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-color);
    font: inherit;
    box-shadow: 0 6px 20px rgba(30, 52, 73, 0.04);
}

.admin-textarea {
    min-height: 160px;
    padding: 14px 16px;
    resize: vertical;
}

.auth-field input:focus,
.admin-textarea:focus {
    outline: none;
    border-color: rgba(67, 97, 125, 0.38);
    box-shadow: 0 0 0 4px rgba(67, 97, 125, 0.08);
}

.auth-submit {
    justify-self: start;
    border-color: rgba(67, 97, 125, 0.28);
}

.auth-error,
.auth-message {
    padding: 14px 16px;
    border-radius: 16px;
    font-size: 0.98rem;
    line-height: 1.55;
}

.auth-message {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(67, 97, 125, 0.12);
    color: var(--text-color);
}

.auth-error {
    border: 1px solid rgba(157, 78, 78, 0.22);
    background: rgba(201, 107, 107, 0.08);
    color: #9d4e4e;
}

.info-shell,
.admin-shell {
    width: min(1320px, calc(100% - 48px));
}

.info-content,
.admin-side-stack {
    display: grid;
    gap: 20px;
}

.info-meta-row,
.admin-tab-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.info-meta-item,
.admin-pagination-status {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(67, 97, 125, 0.14);
    background: rgba(255, 255, 255, 0.75);
    color: var(--muted-text-color);
    font-size: 0.88rem;
}

.info-section,
.admin-card {
    display: grid;
    gap: 16px;
    padding: 22px;
    border: 1px solid rgba(67, 97, 125, 0.14);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 12px 34px rgba(30, 52, 73, 0.05);
}

.info-section-text {
    color: var(--text-color);
    white-space: pre-wrap;
    line-height: 1.68;
}

.admin-tab-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid rgba(67, 97, 125, 0.14);
    background: rgba(255, 255, 255, 0.72);
    color: var(--muted-text-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

.admin-tab-link-active {
    color: var(--primary);
    border-color: rgba(67, 97, 125, 0.3);
    background: #ffffff;
}

.admin-content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(360px, 1fr);
    gap: 20px;
    align-items: start;
}

.admin-content-single {
    display: grid;
}

.admin-content-text-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}

.admin-content-text-grid > .admin-card {
    flex: 1 1 320px;
    max-width: 440px;
}

.admin-card-header,
.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-card-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
}

.admin-table-wrap {
    overflow: auto;
    border-radius: 18px;
    border: 1px solid rgba(67, 97, 125, 0.12);
    background: rgba(255, 255, 255, 0.92);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.admin-table th,
.admin-table td {
    padding: 14px 16px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(67, 97, 125, 0.08);
    color: var(--text-color);
    font-size: 0.92rem;
    line-height: 1.5;
    word-break: break-word;
}

.admin-table th {
    position: sticky;
    top: 0;
    background: #f8fafb;
    font-weight: 600;
    z-index: 1;
}

.admin-table th:nth-child(1),
.admin-table td:nth-child(1) {
    width: 150px;
}

.admin-table th:nth-child(2),
.admin-table td:nth-child(2),
.admin-table th:nth-child(3),
.admin-table td:nth-child(3) {
    width: 24%;
}

.admin-table th:nth-child(4),
.admin-table td:nth-child(4),
.admin-table th:nth-child(5),
.admin-table td:nth-child(5) {
    width: 120px;
}

.admin-table th:nth-child(6),
.admin-table td:nth-child(6) {
    width: 110px;
}

.admin-table-compact th:nth-child(1),
.admin-table-compact td:nth-child(1) {
    width: 150px;
}

.admin-table-compact th:nth-child(4),
.admin-table-compact td:nth-child(4) {
    width: 96px;
}

.admin-table-empty {
    text-align: center;
    color: var(--muted-text-color);
}

.admin-detail-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.admin-detail-link:hover {
    text-decoration: underline;
}

.admin-table-actions,
.admin-rag-upload-form,
.admin-rag-toolbar,
.admin-modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-file-input {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid rgba(67, 97, 125, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--muted-text-color);
    font-size: 0.9rem;
    cursor: pointer;
    overflow: hidden;
}

.admin-file-input-selected {
    border-color: rgba(89, 147, 96, 0.34);
    background: rgba(89, 147, 96, 0.12);
    color: #315b37;
}

.admin-file-input input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.admin-rag-feedback {
    margin: 0;
}

.admin-rag-list {
    display: grid;
    border: 1px solid rgba(67, 97, 125, 0.12);
    border-radius: 18px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.92);
}

.admin-rag-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(67, 97, 125, 0.08);
}

.admin-rag-item:last-child {
    border-bottom: none;
}

.admin-rag-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-rag-count {
    text-align: right;
    color: var(--muted-text-color);
    font-weight: 600;
}

.admin-rag-delete-form {
    justify-self: end;
}

.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.admin-pagination-spacer {
    width: 92px;
    height: 1px;
}

.admin-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.admin-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(16, 26, 37, 0.18);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.admin-modal {
    width: min(920px, 100%);
    max-height: min(88vh, 920px);
    overflow: auto;
}

.admin-detail-field {
    display: grid;
    gap: 8px;
}

.admin-detail-field-wide {
    grid-column: 1 / -1;
}

.admin-detail-value,
.admin-detail-block {
    color: var(--text-color);
}

.admin-detail-block {
    min-height: 120px;
    padding: 16px;
    border: 1px solid rgba(67, 97, 125, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.86);
    line-height: 1.58;
    white-space: pre-wrap;
    word-break: break-word;
}

.language-modal {
    position: fixed;
    inset: 0;
    background: rgba(248, 248, 245, 0.86);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.language-modal[hidden] {
    display: none;
}

.language-modal__card {
    width: min(760px, 100%);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(67, 97, 125, 0.14);
    border-radius: 28px;
    box-shadow: 0 24px 70px rgba(30, 52, 73, 0.12);
    padding: 34px 36px;
}

.language-modal__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 7px 12px;
    border: 1px solid rgba(67, 97, 125, 0.18);
    border-radius: 999px;
    background: rgba(67, 97, 125, 0.08);
    color: var(--primary);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.language-modal__title {
    margin: 0 0 10px;
    color: var(--primary);
    font-size: 1.9rem;
    font-weight: 600;
    line-height: 1.1;
}

.language-modal__text {
    margin: 0 0 24px;
    color: var(--muted-text-color);
    line-height: 1.5;
    max-width: 34ch;
}

.language-modal__actions {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}

.language-modal__button {
    border: 1px solid rgba(67, 97, 125, 0.14);
    border-radius: 18px;
    background: #ffffff;
    color: var(--text-color);
    padding: 16px 18px;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    text-align: left;
    min-height: 126px;
    box-shadow: 0 10px 24px rgba(30, 52, 73, 0.05);
}

.language-modal__button:hover {
    transform: translateY(-1px);
    border-color: rgba(67, 97, 125, 0.28);
}

.language-modal__button-title {
    display: block;
    font-size: 1.08rem;
    font-weight: 700;
}

.language-modal__button-subtitle {
    display: block;
    margin-top: 8px;
    color: var(--muted-text-color);
    font-size: 0.92rem;
    line-height: 1.4;
}

@media (min-width: 640px) {
    .language-modal__actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 840px) {
    .language-modal__actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .chat-hero {
        grid-template-columns: 1fr;
    }

    .chat-hero-visual {
        justify-content: flex-start;
    }

    .avatar-badge-hero {
        width: 180px;
        height: 180px;
    }

    .chat-page--conversation-active .chat-main {
        grid-template-columns: 84px minmax(0, 1fr);
        gap: 18px;
    }

    .chat-side-avatar-inner {
        width: 72px;
        height: 72px;
    }
}

@media (max-width: 720px) {
    .app-shell,
    .info-shell,
    .admin-shell {
        width: min(100%, calc(100% - 24px));
    }

    .app-shell-light {
        padding: 18px 0 20px;
    }

    .page-login-link {
        top: 14px;
        right: 12px;
    }

    .page-header,
    .panel-header {
        margin-bottom: 24px;
        flex-direction: column;
        gap: 16px;
    }

    .page-brand-row,
    .panel-title-group {
        gap: 16px;
    }

    .brand-logo-image {
        height: 82px;
    }

    .page-brand-text {
        font-size: 1rem;
    }

    .chat-hero-title,
    .page-section-title {
        font-size: clamp(2.45rem, 9vw, 4rem);
    }

    .chat-hero-text,
    .page-section-text {
        font-size: 1.05rem;
    }

    .admin-content-grid,
    .admin-detail-grid {
        grid-template-columns: 1fr;
    }

    .admin-content-text-grid > .admin-card {
        max-width: none;
    }

    .admin-pagination {
        flex-wrap: wrap;
    }

    .admin-rag-toolbar,
    .admin-rag-upload-form,
    .panel-header-actions {
        align-items: stretch;
    }

    .admin-modal-backdrop,
    .login-modal {
        padding: 12px;
    }

    .admin-modal,
    .login-modal__card {
        padding: 20px;
    }
}

@media (max-width: 560px) {
    .page-login-link {
        display: none;
    }

    .page-header-actions-chat {
        width: 100%;
        justify-content: flex-start;
    }

    .header-divider {
        display: none;
    }

    .chat-hero {
        gap: 18px;
    }

    .chat-hero-visual {
        justify-content: center;
    }

    .avatar-badge-hero {
        width: 150px;
        height: 150px;
    }

    .chat-page--conversation-active .chat-main {
        grid-template-columns: 1fr;
    }

    .chat-page--conversation-active .chat-side-avatar {
        justify-content: flex-start;
        padding-bottom: 6px;
    }

    .chat-side-avatar-inner {
        width: 58px;
        height: 58px;
    }

    .info-section,
    .admin-card {
        padding: 18px;
        border-radius: 20px;
    }

    .admin-rag-item {
        grid-template-columns: minmax(0, 1fr);
        justify-items: start;
    }

    .admin-rag-count,
    .admin-rag-delete-form {
        justify-self: start;
        text-align: left;
    }
}
