:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f0f2f5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: #f0f2f5;
}

a {
    text-decoration: none;
}

.moon-shell {
    display: grid;
    grid-template-columns: 228px minmax(0, 1fr);
    min-height: 100vh;
    background: #f0f2f5;
}

.moon-sidebar {
    min-height: 100vh;
    position: sticky;
    top: 0;
    align-self: start;
    background: #001529;
    color: #ffffff;
    overflow: hidden;
}

.moon-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 64px;
    padding: 0 20px;
    color: #ffffff;
    font-size: 17px;
    font-weight: 700;
}

.moon-logo:hover {
    color: #ffffff;
}

.moon-logo-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #1677ff;
    color: #ffffff;
    font-weight: 800;
}

.moon-menu {
    display: grid;
    gap: 4px;
    padding: 8px 0;
}

.moon-menu-item {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 0 20px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
}

.moon-menu-item:hover {
    color: #ffffff;
}

.moon-menu-item.selected,
.moon-menu-item.active {
    background: #1677ff;
    color: #ffffff;
}

.moon-main {
    min-width: 0;
}

.moon-topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 28px;
    background: #ffffff;
    border-bottom: 1px solid #f0f0f0;
}

.moon-topbar strong,
.moon-topbar span {
    display: block;
}

.moon-topbar span {
    color: #8c8c8c;
    font-size: 13px;
    margin-top: 2px;
}

.moon-topbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.moon-content {
    padding: 24px;
}

.stream-page {
    display: grid;
    gap: 16px;
}

.stream-page-header {
    background: #ffffff;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    padding: 18px 24px;
}

.ant-page-header-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.ant-page-header-heading-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.ant-page-header-heading-title {
    color: rgba(0, 0, 0, 0.88);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
}

.ant-page-header-heading-sub-title {
    color: #8c8c8c;
    font-size: 14px;
}

.ant-page-header-heading-extra {
    display: flex;
    gap: 8px;
}

.stream-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.metric-card .ant-card-body {
    display: grid;
    gap: 6px;
    padding: 18px 20px;
}

.metric-label {
    color: #8c8c8c;
    font-size: 13px;
}

.metric-card strong {
    color: rgba(0, 0, 0, 0.88);
    font-size: 28px;
    line-height: 1;
}

.stream-workspace {
    display: grid;
    grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.ome-live-workspace {
    display: grid;
    grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.ome-live-form {
    display: grid;
    gap: 18px;
}

.ome-live-form .ant-form-item {
    margin-bottom: 0;
}

.ome-live-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.live-start-button {
    border-color: #52c41a;
    color: #237804;
}

.live-start-button:hover {
    border-color: #73d13d;
    color: #389e0d;
}

.live-stop-button {
    border-color: #ff4d4f;
    color: #cf1322;
}

.live-stop-button:hover {
    border-color: #ff7875;
    color: #a8071a;
}

.live-metric-text {
    font-size: 22px !important;
    line-height: 1.15 !important;
    overflow-wrap: anywhere;
}

.ome-live-list-card {
    min-width: 0;
}

.ome-live-table-shell {
    border: 0;
    overflow-x: auto;
}

.ome-live-table-shell table {
    min-width: 1180px;
    width: 100%;
}

.ome-live-table-shell th,
.ome-live-table-shell td {
    white-space: nowrap;
}

.stream-form {
    display: grid;
    gap: 18px;
}

.stream-form .ant-form-item {
    margin-bottom: 0;
}

.validation-message {
    color: #ff4d4f;
    display: block;
    font-size: 13px;
    margin-top: 6px;
}

.orientation-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.orientation-option {
    min-height: 86px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    display: grid;
    gap: 4px;
    padding: 14px;
    text-align: left;
    transition: all 0.2s ease;
}

.orientation-option:hover {
    border-color: #4096ff;
}

.orientation-option.selected {
    border-color: #1677ff;
    background: #e6f4ff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
}

.orientation-title {
    color: rgba(0, 0, 0, 0.88);
    font-size: 15px;
    font-weight: 700;
}

.orientation-note {
    color: #8c8c8c;
    font-size: 12px;
}

.create-button {
    width: 100%;
}

.record-create-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 12px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}

.record-create-option input {
    width: 16px;
    height: 16px;
    margin-top: 2px;
}

.record-create-option span {
    display: grid;
    gap: 3px;
}

.record-create-option strong {
    color: rgba(0, 0, 0, 0.88);
    font-size: 14px;
}

.record-create-option small {
    color: #8c8c8c;
    font-size: 12px;
    line-height: 1.4;
}

.streams-card .ant-card-body,
.table-card-body {
    padding: 0;
}

.stream-table-shell {
    border: 0;
    overflow-x: auto;
}

.stream-table-shell table {
    min-width: 1480px;
    width: 100%;
}

.stream-table-shell th,
.stream-table-shell td {
    white-space: nowrap;
}

.stream-name-cell {
    display: grid;
    gap: 2px;
}

.stream-name-cell strong {
    color: rgba(0, 0, 0, 0.88);
}

.stream-name-cell span {
    color: #8c8c8c;
    font-size: 12px;
}

.copy-cell {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) auto;
    gap: 8px;
    align-items: center;
    max-width: 320px;
}

.copy-cell code {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: #262626;
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.action-group {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

.record-toggle {
    display: inline-grid;
    grid-template-columns: 18px minmax(0, auto);
    gap: 7px;
    align-items: center;
    min-width: 112px;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid #d9d9d9;
    border-radius: 999px;
    background: #ffffff;
    color: #595959;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.record-toggle.enabled {
    border-color: #52c41a;
    background: #f6ffed;
    color: #237804;
}

.record-toggle-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #bfbfbf;
}

.record-toggle.enabled .record-toggle-dot {
    background: #52c41a;
}

.monitor-actions {
    align-items: center;
    flex-wrap: wrap;
}

.monitor-filter {
    display: inline-grid;
    grid-template-columns: 16px minmax(0, auto);
    align-items: center;
    gap: 7px;
    min-height: 32px;
    color: #595959;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.monitor-filter input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.monitor-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
    gap: 16px;
    align-items: start;
}

.monitor-current-card,
.monitor-detail-card,
.monitor-history-card {
    min-width: 0;
}

.monitor-table-shell,
.monitor-history-table-shell {
    border: 0;
    overflow-x: auto;
}

.monitor-table-shell table {
    min-width: 900px;
    width: 100%;
}

.monitor-history-table-shell table {
    min-width: 720px;
    width: 100%;
}

.monitor-table-shell th,
.monitor-table-shell td,
.monitor-history-table-shell th,
.monitor-history-table-shell td {
    white-space: nowrap;
}

.monitor-row-selected td {
    background: #e6f4ff;
}

.monitor-managed-cell {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.monitor-managed-cell strong {
    color: rgba(0, 0, 0, 0.88);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monitor-managed-cell span {
    color: #8c8c8c;
    font-size: 12px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border: 1px solid #d9d9d9;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

.status-pill.online {
    border-color: #b7eb8f;
    background: #f6ffed;
    color: #237804;
}

.status-pill.offline {
    border-color: #ffccc7;
    background: #fff2f0;
    color: #a8071a;
}

.monitor-detail-card .ant-card-body {
    display: grid;
    gap: 16px;
}

.monitor-detail-empty {
    min-height: 280px;
}

.monitor-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.monitor-detail-grid > div {
    display: grid;
    gap: 5px;
    min-height: 72px;
    padding: 12px;
    border: 1px solid #f0f0f0;
    border-radius: 6px;
    background: #fafafa;
}

.monitor-detail-grid span {
    color: #8c8c8c;
    font-size: 12px;
}

.monitor-detail-grid strong {
    min-width: 0;
    color: rgba(0, 0, 0, 0.88);
    font-size: 14px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.monitor-subsection {
    display: grid;
    gap: 10px;
}

.monitor-subsection > strong {
    color: rgba(0, 0, 0, 0.88);
    font-size: 14px;
}

.monitor-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.monitor-chip {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border: 1px solid #d9d9d9;
    border-radius: 999px;
    background: #ffffff;
    color: #595959;
    font-size: 12px;
}

.monitor-variant-list {
    display: grid;
    gap: 8px;
}

.monitor-variant {
    display: grid;
    grid-template-columns: minmax(96px, 0.45fr) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid #f0f0f0;
    border-radius: 6px;
    background: #ffffff;
}

.monitor-variant span {
    color: #595959;
    font-size: 13px;
    font-weight: 600;
}

.monitor-variant strong {
    min-width: 0;
    color: rgba(0, 0, 0, 0.88);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.danger-link,
.danger-link:hover {
    color: #ff4d4f;
}

.config-descriptions table {
    width: 100%;
}

.config-descriptions .ant-descriptions-item-label {
    width: 136px;
    color: #595959;
    font-weight: 600;
}

.stream-preview-block {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.stream-preview-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.stream-preview-heading strong {
    color: rgba(0, 0, 0, 0.88);
    font-size: 15px;
}

.stream-preview-heading span {
    min-width: 0;
    overflow: hidden;
    color: #8c8c8c;
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.webrtc-preview {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 220px;
    overflow: hidden;
    border-radius: 8px;
    background: #111111;
    color: #ffffff;
}

.webrtc-preview:not(.portrait) {
    aspect-ratio: 16 / 9;
}

.webrtc-preview.portrait {
    aspect-ratio: 9 / 16;
    max-width: 300px;
    min-height: 0;
    margin-inline: auto;
}

.webrtc-preview.unavailable {
    min-height: 180px;
    border: 1px dashed #d9d9d9;
    background: #fafafa;
    color: #8c8c8c;
}

.webrtc-preview-video,
.webrtc-preview video {
    width: 100%;
    height: 100%;
    background: #111111;
    object-fit: contain;
}

.webrtc-preview-placeholder,
.webrtc-preview-status {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
    text-align: center;
    pointer-events: none;
}

.config-empty,
.table-empty,
.table-state {
    min-height: 180px;
}

.table-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #8c8c8c;
}

.simple-empty-mark {
    width: 72px;
    height: 48px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    background: linear-gradient(180deg, #ffffff, #f5f5f5);
    margin: 0 auto 12px;
}

.ant-alert {
    border-radius: 8px;
}

@media (max-width: 1100px) {
    .stream-workspace,
    .ome-live-workspace {
        grid-template-columns: 1fr;
    }

    .monitor-workspace {
        grid-template-columns: 1fr;
    }

    .stream-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .moon-shell {
        grid-template-columns: 1fr;
    }

    .moon-sidebar {
        width: 100%;
        min-height: auto;
        position: static;
    }

    .moon-logo {
        height: 56px;
    }

    .moon-topbar,
    .ant-page-header-heading {
        align-items: flex-start;
        flex-direction: column;
        height: auto;
        padding: 16px;
    }

    .moon-content {
        padding: 16px;
    }

    .moon-topbar-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .stream-stats {
        grid-template-columns: 1fr;
    }

    .ant-page-header-heading-left,
    .ant-page-header-heading-extra {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .ant-page-header-heading-extra .ant-btn {
        width: 100%;
    }

    .monitor-filter {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .orientation-options,
    .copy-cell {
        grid-template-columns: 1fr;
    }

    .stream-preview-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .config-descriptions .ant-descriptions-item-label {
        width: 110px;
    }

    .monitor-detail-grid,
    .monitor-variant {
        grid-template-columns: 1fr;
    }
}
