.gic-app {
    --gic-blue: #1264d8;
    --gic-ink: #1e293b;
    --gic-muted: #64748b;
    --gic-line: #dbe3ee;
    --gic-bg: #f6f8fb;
    --gic-panel: #ffffff;
    --gic-soft: #edf3fa;
    --gic-green: #16a34a;
    --gic-red: #dc2626;
    color: var(--gic-ink);
    font-family: Inter, Roboto, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    width: 100%;
}

html.gic-page-scroll-lock,
body.gic-page-scroll-lock {
    overflow: hidden !important;
    overscroll-behavior: none !important;
}

.gic-app.dark-mode {
    --gic-blue: #2b7cff;
    --gic-ink: #e5edf7;
    --gic-muted: #93a4b8;
    --gic-line: #22324a;
    --gic-bg: #07111f;
    --gic-panel: #0d1828;
    --gic-soft: #17253a;
    --gic-green: #22c55e;
    --gic-red: #ef4444;
}

.gic-app *,
.gic-app *::before,
.gic-app *::after {
    box-sizing: border-box;
}

.gic-app.native-app {
    min-height: 100dvh;
    background: var(--gic-bg);
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

.gic-app.native-app .gic-shell,
.gic-app.native-app .gic-auth {
    min-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
}

.gic-loading,
.gic-empty,
.gic-mini-empty {
    color: var(--gic-muted);
    padding: 18px;
    text-align: center;
}

.gic-app a {
    color: inherit;
}

.gic-empty.error,
.gic-mini-empty.error {
    color: var(--gic-red);
}

.gic-auth {
    min-height: 620px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gic-bg);
    padding: 24px;
}

.gic-auth-panel {
    width: min(960px, 100%);
    background: var(--gic-panel);
    border: 1px solid var(--gic-line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
}

.gic-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.gic-brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--gic-blue);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
}

.gic-brand strong,
.gic-sidebar-head strong {
    display: block;
    font-size: 20px;
    line-height: 1.15;
}

.gic-brand span,
.gic-sidebar-head span {
    display: block;
    color: var(--gic-muted);
    font-size: 13px;
    margin-top: 2px;
}

.gic-auth-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    gap: 16px;
}

.gic-auth-card {
    border: 1px solid var(--gic-line);
    border-radius: 8px;
    padding: 18px;
    background: var(--gic-panel);
}

.gic-auth-card h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

.gic-auth-card label,
.gic-directory label {
    display: block;
    color: var(--gic-muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 10px;
}

.gic-auth-card input,
.gic-directory input,
.gic-modal-card input,
.gic-composer input {
    width: 100%;
    border: 1px solid var(--gic-line);
    background: var(--gic-panel);
    color: var(--gic-ink);
    border-radius: 8px;
    min-height: 42px;
    padding: 10px 12px;
    outline: none;
    font-size: 14px;
}

.gic-auth-card input:focus,
.gic-directory input:focus,
.gic-modal-card input:focus,
.gic-composer input:focus {
    border-color: var(--gic-blue);
    box-shadow: 0 0 0 3px rgba(18, 100, 216, 0.12);
}

.gic-auth-card button,
.gic-tools button,
.gic-chat-actions button,
.gic-composer button,
.gic-icon-btn {
    border: 0;
    background: var(--gic-blue);
    color: #fff;
    border-radius: 8px;
    min-height: 40px;
    padding: 10px 14px;
    font-weight: 800;
    cursor: pointer;
}

.gic-auth-card button:hover,
.gic-tools button:hover,
.gic-chat-actions button:hover,
.gic-composer button:hover,
.gic-icon-btn:hover {
    filter: brightness(0.96);
}

.gic-shell {
    height: min(780px, calc(100dvh - 118px));
    min-height: 620px;
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    background: var(--gic-bg);
    border: 1px solid var(--gic-line);
    border-radius: 8px;
    overflow: hidden;
}

.gic-top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.gic-sidebar {
    min-width: 0;
    background: var(--gic-panel);
    border-right: 1px solid var(--gic-line);
    display: flex;
    flex-direction: column;
}

.gic-sidebar-head,
.gic-chat-head {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--gic-line);
    background: var(--gic-panel);
}

.gic-icon-btn {
    background: var(--gic-soft);
    color: var(--gic-ink);
    min-height: 36px;
    padding: 8px 10px;
    white-space: nowrap;
}

.gic-chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.gic-chat-actions button {
    min-height: 34px;
    padding: 8px 10px;
    font-size: 12px;
}

.gic-chat-actions button:first-child {
    background: var(--gic-green);
}

.gic-chat-actions button:disabled,
.gic-composer button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gic-notice {
    margin: 10px 14px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
}

.gic-notice.info {
    background: #eff6ff;
    color: #1d4ed8;
}

.gic-app.dark-mode .gic-notice.info {
    background: #10294d;
    color: #9cc5ff;
}

.gic-notice.error {
    background: #fef2f2;
    color: var(--gic-red);
}

.gic-app.dark-mode .gic-notice.error {
    background: #39151b;
}

.gic-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px 14px;
}

.gic-tools button:nth-child(2) {
    background: var(--gic-green);
}

.gic-invite-box {
    margin: 0 14px 12px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    border-radius: 8px;
    padding: 12px;
}

.gic-app.dark-mode .gic-invite-box {
    border-color: #254b7c;
    background: #10294d;
    color: #d8eaff;
}

.gic-invite-box strong,
.gic-invite-box span {
    display: block;
}

.gic-app.dark-mode .gic-invite-box span {
    color: #adc9eb;
}

.gic-invite-box span {
    margin-top: 4px;
    color: #315589;
    font-size: 12px;
    line-height: 1.45;
}

.gic-directory {
    padding: 0 14px 12px;
    border-bottom: 1px solid var(--gic-line);
}

.gic-directory-results {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.gic-directory-results button {
    border: 1px solid var(--gic-line);
    background: var(--gic-panel);
    color: var(--gic-ink);
    border-radius: 8px;
    padding: 9px 10px;
    text-align: left;
    cursor: pointer;
}

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

.gic-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: grid;
    place-items: center;
    padding: 18px;
}

.gic-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
}

.gic-modal-card {
    position: relative;
    z-index: 1;
    width: min(520px, 100%);
    max-height: min(680px, 86vh);
    overflow: auto;
    background: var(--gic-panel);
    border: 1px solid var(--gic-line);
    border-radius: 8px;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.2);
    padding: 16px;
}

.gic-modal-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.gic-modal-card header strong,
.gic-modal-card header span {
    display: block;
}

.gic-modal-card header span {
    color: var(--gic-muted);
    font-size: 12px;
    margin-top: 2px;
}

.gic-modal-card label {
    display: block;
    color: var(--gic-muted);
    font-size: 12px;
    font-weight: 800;
}

.gic-modal-card select {
    width: 100%;
    border: 1px solid var(--gic-line);
    background: var(--gic-panel);
    color: var(--gic-ink);
    border-radius: 8px;
    min-height: 42px;
    padding: 10px 12px;
    outline: none;
    font-size: 14px;
    margin-top: 6px;
}

.gic-modal-card select:focus {
    border-color: var(--gic-blue);
    box-shadow: 0 0 0 3px rgba(18, 100, 216, 0.12);
}

.gic-settings-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

.gic-settings-actions .gic-icon-btn:last-child {
    background: var(--gic-blue);
    color: #fff;
}

.gic-modal-close {
    border: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--gic-soft);
    color: var(--gic-ink);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.gic-member-results {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.gic-member-result {
    width: 100%;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--gic-line);
    background: var(--gic-panel);
    color: var(--gic-ink);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    text-align: left;
}

.gic-member-result:hover {
    background: var(--gic-soft);
}

.gic-member-result-body {
    min-width: 0;
}

.gic-member-result strong,
.gic-member-result small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gic-member-result small {
    color: var(--gic-muted);
    margin-top: 2px;
}

.gic-member-result b {
    color: var(--gic-blue);
    font-size: 12px;
}

.gic-directory-results span,
.gic-directory-results small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gic-directory-results span {
    color: var(--gic-ink);
    font-weight: 800;
}

.gic-directory-results small {
    color: var(--gic-muted);
}

.gic-channel-list {
    overflow-y: auto;
    min-height: 0;
    padding: 8px;
}

.gic-channel {
    width: 100%;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    padding: 10px;
    color: var(--gic-ink);
    cursor: pointer;
    text-align: left;
}

.gic-channel:hover,
.gic-channel.active {
    background: var(--gic-soft);
}

.gic-avatar {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #fff;
    background: #334155;
    font-weight: 900;
}

.gic-channel-body {
    min-width: 0;
}

.gic-channel-body strong,
.gic-channel-body small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gic-channel-body strong {
    font-size: 14px;
}

.gic-channel-body small {
    color: var(--gic-muted);
    font-size: 12px;
    margin-top: 2px;
}

.gic-channel b {
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--gic-red);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 12px;
}

.gic-chat {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--gic-bg);
}

.gic-mobile-back {
    display: none;
    border: 0;
    background: transparent;
    color: var(--gic-blue);
    width: 42px;
    height: 42px;
    border-radius: 8px;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
}

.gic-chat-head h2 {
    margin: 0;
    font-size: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gic-chat-head span {
    display: block;
    color: var(--gic-muted);
    font-size: 13px;
    margin-top: 3px;
}

.gic-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gic-message {
    width: fit-content;
    max-width: min(620px, 82%);
    border: 1px solid var(--gic-line);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--gic-panel);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.gic-message.mine {
    align-self: flex-end;
    background: var(--gic-blue);
    border-color: var(--gic-blue);
    color: #fff;
}

.gic-message.mine a {
    color: #fff;
}

.gic-message.theirs {
    align-self: flex-start;
}

.gic-message strong {
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
    opacity: 0.86;
}

.gic-message p {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.42;
}

.gic-attachment {
    display: grid;
    gap: 8px;
    min-width: min(260px, 64vw);
}

.gic-attachment img,
.gic-attachment video {
    display: block;
    width: 100%;
    max-width: 360px;
    max-height: min(280px, 42vh);
    border-radius: 8px;
    object-fit: contain;
    background: rgba(15, 23, 42, 0.08);
}

.gic-attachment audio {
    display: block;
    width: min(330px, 64vw);
}

.gic-attachment > a {
    display: block;
    font-size: 12px;
    font-weight: 800;
    overflow-wrap: anywhere;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gic-file-card a {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    min-height: 46px;
    padding: 10px;
    border: 1px solid var(--gic-line);
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.14);
    text-decoration: none;
}

.gic-file-card b {
    color: var(--gic-blue);
    font-size: 12px;
}

.gic-file-card span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gic-message time {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.72;
}

.gic-composer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--gic-line);
    background: var(--gic-panel);
}

.gic-attach-btn {
    width: 42px;
    padding: 0;
    display: grid;
    place-items: center;
    font-size: 22px;
    line-height: 1;
    background: var(--gic-soft);
    color: var(--gic-ink);
}

.gic-composer input:disabled,
.gic-composer button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 820px) {
    .gic-app {
        position: relative;
        min-height: 100dvh;
        background: var(--gic-bg);
        overflow: hidden;
    }

    .gic-shell {
        position: relative;
        display: block;
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
        overflow: hidden;
        border: 0;
        border-radius: 0;
    }

    .gic-sidebar,
    .gic-chat {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        min-height: 0;
    }

    .gic-sidebar {
        z-index: 1;
        border-right: 0;
        border-bottom: 0;
        display: flex;
        flex-direction: column;
        background: var(--gic-panel);
    }

    .gic-chat {
        z-index: 2;
        display: flex;
        flex-direction: column;
        transform: translateX(100%);
        transition: transform 180ms ease;
        background: var(--gic-bg);
    }

    .gic-app.mobile-chat-active .gic-chat {
        transform: translateX(0);
    }

    .gic-app.mobile-chat-active .gic-sidebar {
        pointer-events: none;
    }

    .gic-sidebar-head,
    .gic-chat-head,
    .gic-composer {
        flex-shrink: 0;
    }

    .gic-chat-head {
        min-height: 76px;
        justify-content: flex-start;
    }

    .gic-chat-head > div:first-of-type {
        min-width: 0;
        flex: 1;
    }

    .gic-chat-actions {
        flex-shrink: 0;
    }

    .gic-mobile-back {
        display: grid;
        place-items: center;
        flex-shrink: 0;
    }

    .gic-channel-list {
        flex: 1;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: max(18px, env(safe-area-inset-bottom));
    }

    .gic-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 14px 12px;
    }

    .gic-composer {
        grid-template-columns: 42px minmax(0, 1fr) 52px;
        gap: 8px;
    }

    .gic-composer button[type="submit"] {
        min-width: 52px;
        padding-left: 8px;
        padding-right: 8px;
    }
}

@media (max-width: 820px) {
    .gic-app {
        min-height: 100dvh;
    }

    .gic-auth {
        padding: 10px;
        align-items: stretch;
        min-height: 100dvh;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .gic-auth-grid,
    .gic-shell {
        grid-template-columns: 1fr;
    }

    .gic-shell {
        height: 100dvh;
        min-height: 0;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .gic-sidebar {
        min-height: 330px;
        border-right: 0;
        border-bottom: 1px solid var(--gic-line);
    }

    .gic-channel-list {
        max-height: 230px;
    }

    .gic-chat {
        min-height: 0;
    }

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

    .gic-sidebar-head,
    .gic-chat-head,
    .gic-composer {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .gic-composer {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .gic-top-actions {
        max-width: 170px;
    }

    .gic-icon-btn,
    .gic-chat-actions button {
        min-height: 34px;
        padding: 7px 9px;
    }

    .gic-messages {
        padding: 12px;
    }

    .gic-attachment {
        min-width: min(220px, 78vw);
    }

    .gic-attachment audio {
        width: min(270px, 78vw);
    }
}

@media (max-height: 760px) and (min-width: 821px) {
    .gic-shell {
        height: calc(100dvh - 96px);
        min-height: 520px;
    }

    .gic-attachment img,
    .gic-attachment video {
        max-height: min(220px, 36vh);
    }
}

@media (max-width: 820px) {
    .gic-shell {
        position: relative;
        display: block;
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
        overflow: hidden;
        border: 0;
        border-radius: 0;
    }

    .gic-sidebar,
    .gic-chat {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        min-height: 0;
    }

    .gic-sidebar {
        z-index: 1;
        border-right: 0;
        border-bottom: 0;
        display: flex;
        flex-direction: column;
    }

    .gic-chat {
        z-index: 2;
        display: flex;
        flex-direction: column;
        transform: translateX(100%);
        transition: transform 180ms ease;
    }

    .gic-app.mobile-chat-active .gic-chat {
        transform: translateX(0);
    }

    .gic-channel-list {
        flex: 1;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
    }
}
