.pd-widget-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1100;
    width: min(326px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    color: rgba(236, 253, 255, 0.92);
    font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    pointer-events: none;
}

.pd-widget-panel {
    width: 100%;
    pointer-events: auto;
    border: 1px solid rgba(91, 219, 225, 0.22);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(8, 17, 28, 0.58), rgba(4, 9, 16, 0.48)),
        repeating-linear-gradient(90deg, rgba(91, 219, 225, 0.04) 0 1px, transparent 1px 34px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24), inset 0 0 28px rgba(38, 198, 218, 0.04);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
    transition: width 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.pd-widget-panel.is-collapsed {
    width: 44px;
}

.pd-widget-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 34px;
    padding: 7px 9px;
    border: 0;
    border-bottom: 1px solid rgba(91, 219, 225, 0.12);
    background: rgba(6, 18, 30, 0.28);
    color: inherit;
    cursor: pointer;
    text-align: left;
}

.pd-widget-panel.is-collapsed .pd-widget-toggle {
    justify-content: center;
    padding: 7px 5px;
    border-bottom: 0;
}

.pd-widget-panel.is-collapsed .pd-toggle-title,
.pd-widget-panel.is-collapsed .pd-toggle-action,
.pd-widget-panel.is-collapsed .pd-widget-code,
.pd-widget-panel.is-collapsed .pd-summary-label {
    display: none;
}

.pd-widget-panel.is-collapsed .pd-toggle-meta {
    width: 100%;
    justify-content: center;
    gap: 0;
}

.pd-widget-toggle:hover,
.pd-widget-toggle:focus-visible {
    background: rgba(91, 219, 225, 0.08);
    outline: 1px solid rgba(91, 219, 225, 0.28);
}

.pd-toggle-title {
    min-width: 0;
    color: rgba(232, 253, 255, 0.9);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.pd-toggle-meta {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 7px;
    min-width: 0;
}

.pd-toggle-action,
.pd-widget-code {
    color: rgba(144, 235, 241, 0.72);
    font-size: 10px;
    line-height: 1;
    font-family: "Consolas", "SFMono-Regular", monospace;
    letter-spacing: 0;
    white-space: nowrap;
}

.pd-message-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(231, 76, 60, 0.9);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 12px rgba(231, 76, 60, 0.35);
}

.pd-message-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    min-height: 18px;
}

.pd-message-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: rgba(144, 235, 241, 0.86);
    background: rgba(91, 219, 225, 0.09);
    box-shadow: inset 0 0 0 1px rgba(91, 219, 225, 0.18);
}

.pd-message-icon svg {
    display: block;
    width: 14px;
    height: 14px;
}

.pd-summary-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 20px;
    padding: 3px 6px;
    border-radius: 6px;
    color: rgba(237, 254, 255, 0.94);
    background: rgba(255, 255, 255, 0.045);
    box-shadow: inset 0 0 0 1px rgba(91, 219, 225, 0.16);
}

.pd-summary-label {
    color: rgba(226, 250, 252, 0.78);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    text-transform: uppercase;
    white-space: nowrap;
}

.pd-widget-monitor .pd-widget-toggle {
    background:
        linear-gradient(90deg, rgba(47, 210, 119, 0.08), rgba(6, 18, 30, 0.26) 42%),
        rgba(6, 18, 30, 0.28);
}

.pd-widget-monitor:not(.is-collapsed) .pd-summary-status {
    background: rgba(8, 24, 34, 0.72);
}

.pd-widget-body {
    display: block;
}

.pd-widget-panel.is-collapsed .pd-widget-body {
    display: none;
}

.pd-widget-monitor.is-collapsed .pd-widget-body {
    display: block;
}

.pd-message-screen {
    position: relative;
    display: block;
    width: 100%;
    height: 62px;
    padding: 8px 10px 10px;
    border: 0;
    background: rgba(255, 255, 255, 0.02);
    color: inherit;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
}

.pd-message-screen:hover,
.pd-message-screen:focus-visible {
    background: rgba(91, 219, 225, 0.07);
    outline: 1px solid rgba(91, 219, 225, 0.24);
}

.pd-message-line {
    display: block;
    color: rgba(226, 250, 252, 0.84);
    font-size: 12px;
    line-height: 1.45;
    transform: translateY(0);
    opacity: 1;
}

.pd-message-line.is-exiting {
    animation: pd-message-exit 0.28s ease forwards;
}

.pd-message-line.is-entering {
    animation: pd-message-enter 0.34s ease forwards;
}

.pd-message-line.is-scrolling {
    animation: pd-message-scroll var(--pd-message-scroll-duration, 8000ms) linear forwards;
}

.pd-monitor-grid {
    display: grid;
    gap: 6px;
    padding: 8px;
}

.pd-widget-monitor.is-collapsed .pd-monitor-grid {
    justify-items: center;
    gap: 6px;
    padding: 8px 0;
}

.pd-metric {
    display: grid;
    grid-template-columns: 56px 1fr 18px;
    gap: 7px;
    align-items: center;
    min-height: 36px;
    padding: 5px 6px;
    border: 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.035);
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.pd-widget-monitor.is-collapsed .pd-metric {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 100%;
    min-height: 42px;
    padding: 5px 0 6px;
    border-radius: 0;
    background: transparent;
}

.pd-widget-monitor.is-collapsed .pd-metric-name,
.pd-widget-monitor.is-collapsed .pd-mini-chart,
.pd-widget-monitor.is-collapsed .pd-text-readout {
    display: none;
}

.pd-metric-short {
    display: none;
    color: rgba(188, 239, 243, 0.82);
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.pd-widget-monitor.is-collapsed .pd-metric-short {
    display: block;
}

.pd-metric:hover,
.pd-metric:focus-visible {
    background: rgba(91, 219, 225, 0.09);
    outline: 1px solid rgba(91, 219, 225, 0.34);
}

.pd-metric.is-stale {
    background: rgba(241, 196, 15, 0.045);
}

.pd-metric-name {
    min-width: 0;
}

.pd-metric-label {
    display: block;
    color: rgba(237, 254, 255, 0.9);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pd-metric-unit {
    display: block;
    margin-top: 2px;
    color: rgba(181, 227, 231, 0.56);
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
}

.pd-mini-chart {
    width: 100%;
    height: 30px;
    display: block;
}

.pd-mini-zone,
.pd-full-zone {
    opacity: 0.2;
}

.pd-zone-safe {
    fill: #2fd277;
}

.pd-zone-watch {
    fill: #f1c40f;
}

.pd-zone-caution {
    fill: #e67e22;
}

.pd-zone-alert {
    fill: #ff3040;
}

.pd-mini-gridline {
    stroke: rgba(235, 255, 255, 0.12);
    stroke-width: 0.6;
}

.pd-chart-empty {
    fill: rgba(188, 239, 243, 0.58);
    font-size: 10px;
    font-family: "Consolas", "SFMono-Regular", monospace;
    letter-spacing: 0;
}

.pd-chart-empty-large {
    fill: rgba(226, 250, 252, 0.72);
    font-size: 16px;
}

.pd-mini-segment,
.pd-full-segment {
    fill: none;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.pd-mini-segment {
    stroke-width: 1.45;
    filter: drop-shadow(0 0 3px rgba(125, 249, 255, 0.35));
}

.pd-full-segment {
    stroke-width: 2.3;
    filter: drop-shadow(0 0 4px rgba(125, 249, 255, 0.22));
}

.pd-segment-safe {
    stroke: #2fd277;
}

.pd-segment-watch {
    stroke: #f1c40f;
}

.pd-segment-caution {
    stroke: #e67e22;
}

.pd-segment-alert {
    stroke: #ff3040;
}

.pd-text-readout {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
    font-family: "Consolas", "SFMono-Regular", monospace;
}

.pd-text-value {
    color: rgba(237, 254, 255, 0.95);
    font-size: 18px;
    line-height: 1;
}

.pd-text-unit {
    color: rgba(181, 227, 231, 0.56);
    font-size: 9px;
}

.pd-status-light {
    width: 10px;
    height: 10px;
    justify-self: center;
    border-radius: 50%;
    background: var(--pd-light, #2fd277);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08), 0 0 10px var(--pd-light, #2fd277);
}

.pd-status-safe {
    --pd-light: #2fd277;
}

.pd-status-watch {
    --pd-light: #f1c40f;
}

.pd-status-caution {
    --pd-light: #e67e22;
}

.pd-status-alert {
    --pd-light: #ff3040;
}

.pd-widget-modal {
    position: fixed;
    inset: 0;
    z-index: 12050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(2, 8, 15, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.pd-widget-modal.is-open {
    display: flex;
}

.pd-widget-dialog {
    width: min(760px, 96vw);
    max-height: min(86vh, 760px);
    border: 1px solid rgba(91, 219, 225, 0.28);
    border-radius: 8px;
    background: rgba(7, 15, 26, 0.94);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.46);
    color: rgba(236, 253, 255, 0.94);
    overflow: hidden;
}

.pd-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(91, 219, 225, 0.16);
}

.pd-dialog-title {
    margin: 0 0 6px;
    font-size: 18px;
    color: #f1feff;
}

.pd-dialog-value {
    color: rgba(155, 242, 247, 0.72);
    font-size: 12px;
    font-family: "Consolas", "SFMono-Regular", monospace;
}

.pd-dialog-close {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(236, 253, 255, 0.9);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.pd-dialog-body {
    max-height: calc(86vh - 92px);
    padding: 16px 18px 18px;
    overflow: auto;
}

.pd-full-chart {
    width: 100%;
    height: auto;
    display: block;
}

.pd-axis-text {
    fill: rgba(204, 236, 238, 0.68);
    font-size: 10px;
    font-family: "Consolas", "SFMono-Regular", monospace;
}

.pd-axis-line {
    stroke: rgba(204, 236, 238, 0.2);
    stroke-width: 1;
}

.pd-plot-border {
    fill: none;
    stroke: rgba(204, 236, 238, 0.3);
    stroke-width: 1;
}

.pd-now-line {
    stroke: rgba(236, 253, 255, 0.56);
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.pd-current-dot {
    stroke: #f8ffff;
    stroke-width: 1;
}

.pd-dot-safe {
    fill: #2fd277;
}

.pd-dot-watch {
    fill: #f1c40f;
}

.pd-dot-caution {
    fill: #e67e22;
}

.pd-dot-alert {
    fill: #ff3040;
}

.pd-zone-label {
    fill: rgba(236, 253, 255, 0.5);
    font-size: 10px;
    font-weight: 700;
}

.pd-message-full-content {
    color: rgba(226, 250, 252, 0.88);
    font-size: 14px;
    line-height: 1.75;
    white-space: pre-wrap;
}

.pd-message-list {
    max-height: min(56vh, 300px);
    overflow-y: auto;
    padding-right: 4px;
}

.pd-message-item {
    padding: 0 0 14px;
    margin: 0 0 14px;
    border-bottom: 1px solid rgba(91, 219, 225, 0.14);
}

.pd-message-item:last-child {
    border-bottom: 0;
    margin-bottom: 0;
}

.pd-message-time {
    display: block;
    color: rgba(144, 235, 241, 0.68);
    font-size: 12px;
    margin-bottom: 6px;
}

.pd-message-title {
    margin: 0 0 6px;
    color: rgba(236, 253, 255, 0.96);
    font-size: 15px;
    line-height: 1.35;
}

.pd-message-content {
    margin: 0;
    color: rgba(226, 250, 252, 0.84);
    font-size: 14px;
    line-height: 1.72;
    white-space: pre-wrap;
}

@keyframes pd-message-exit {
    to {
        transform: translateY(-110%);
        opacity: 0;
    }
}

@keyframes pd-message-enter {
    from {
        transform: translateY(110%);
        opacity: 0;
    }

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

@keyframes pd-message-scroll {
    0%,
    16% {
        transform: translateY(0);
    }

    86%,
    100% {
        transform: translateY(var(--pd-message-shift, -24px));
    }
}

@media (max-width: 640px) {
    .pd-widget-stack {
        right: 10px;
        bottom: 82px;
        bottom: calc(82px + env(safe-area-inset-bottom));
        width: min(270px, calc(90vw - 18px));
    }

    .pd-widget-panel.is-collapsed {
        width: 42px;
    }

    .pd-widget-panel {
        background:
            linear-gradient(180deg, rgba(8, 17, 28, 0.48), rgba(4, 9, 16, 0.4)),
            repeating-linear-gradient(90deg, rgba(91, 219, 225, 0.035) 0 1px, transparent 1px 34px);
    }

    .pd-toggle-title {
        font-size: 10px;
    }

    .pd-widget-code {
        display: none;
    }

    .pd-metric {
        grid-template-columns: 48px 1fr 16px;
        gap: 6px;
    }

    .pd-message-screen {
        height: 58px;
    }

    .pd-dialog-head {
        padding: 13px 14px 10px;
    }

    .pd-dialog-body {
        padding: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pd-message-line.is-exiting,
    .pd-message-line.is-entering,
    .pd-message-line.is-scrolling {
        animation: none !important;
    }
}
