/* Web Serial 串口调试工具样式 */

/* 本地字体（思源宋体 SC） */
@font-face {
    font-family: 'SourceHanSerifSC';
    src: url('/fonts/SourceHanSerifSC-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SourceHanSerifSC';
    src: url('/fonts/SourceHanSerifSC-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SourceHanSerifSC';
    src: url('/fonts/SourceHanSerifSC-SemiBold.otf') format('opentype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SourceHanSerifSC';
    src: url('/fonts/SourceHanSerifSC-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'SourceHanSerifSC', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 16px;
    background-color: #0b0f149d;
    min-width: 1600px;

}

/* 统一控件尺寸（输入框/选择框） */
:root {
    --control-height: 34px;
    --control-padding-y: 6px;
    --control-padding-x: 10px;
}

/* Diegetic Interface 主题（沉浸式设备风格） */
.diegetic {
    --bg: #0c0f14;
    --panel: #102c5083;
    --panel-2: #0d131a87;
    --accent: #3df5ff;
    --accent-2: #79ffa6;
    --danger: #ff5577;
    --ok: #7fffb0;
    --text: #ffffff;
    --muted: #6f8296;
    --grid: rgba(61, 245, 255, 0.1);
    --glow: 0 0 12px rgba(61, 245, 255, 0.45), 0 0 24px rgba(61, 245, 255, 0.15);
    /* radii disabled for sharp corners */
    --radius-lg: 0px;
    --radius-md: 0px;
    --radius-sm: 0px;
}

.diegetic body,
body.diegetic {
    background-color: var(--bg);
    background-image:
        radial-gradient(1200px 600px at 20% -20%, rgba(61, 245, 255, 0.06), transparent 60%),
        linear-gradient(rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.25)),
        url('/img/129563571_p0_master1200.jpg');
    background-size: auto, auto, cover;
    background-position: center, center, center;
    background-attachment: fixed, fixed, fixed;
    color: var(--text);
    font-family: 'SourceHanSerifSC', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* 增强可读性：为主要文本与控件提供黑色阴影 */
.diegetic input,
.diegetic select,
.diegetic textarea,
.diegetic button,
.diegetic label,
.diegetic .data-text,
.diegetic .timestamp,
.diegetic .quick-send-note,
.diegetic .quick-send-hex {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.diegetic .container {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03)), var(--panel);
    border: 1px solid rgba(61, 245, 255, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 8px 40px rgba(0, 0, 0, 0.45);
    backdrop-filter: saturate(102%) blur(4px);
    -webkit-backdrop-filter: saturate(110%) blur(8px);
    position: relative;
}

.diegetic h1,
.diegetic h3 {
    margin-top: 0;
    letter-spacing: 0.06em;
}

.icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    margin-right: 6px;
}

.diegetic .status.connected {
    background: rgba(127, 255, 176, 0.12);
    color: var(--ok);
    border-color: rgba(127, 255, 176, 0.25);
}

.diegetic .status.disconnected {
    background: rgba(255, 85, 119, 0.08);
    color: var(--danger);
    border-color: rgba(255, 85, 119, 0.25);
}

.diegetic .sidebar,
.diegetic .left-tools,
.diegetic .send-area,
.diegetic .data-section {
    background: var(--panel-2);
    border-color: rgba(61, 245, 255, 0.12);
}

.diegetic .data-section h3 {
    background: rgba(61, 245, 255, 0.05);
    border-bottom-color: rgba(61, 245, 255, 0.15);
}

.diegetic .data-content {
    background: linear-gradient(90deg, var(--grid) 1px, transparent 1px) repeat-x, linear-gradient(var(--grid) 1px, transparent 1px) repeat-y;
    background-size: 24px 24px;
}

.diegetic select,
.diegetic input[type="text"],
.diegetic input[type="number"],
.diegetic textarea {
    background: #0a0f14;
    color: var(--text);
    border: 1px solid rgba(61, 245, 255, 0.25);
}

.diegetic .btn-send {
    background: var(--accent);
    color: #001014;
    box-shadow: var(--glow);
}

.diegetic .btn-send:hover {
    background: #2fdbe6;
}

.diegetic .btn-clear {
    background: #2a3342;
    color: var(--text);
}

.diegetic .btn-connect {
    background: var(--ok);
    color: #001014;
}

.diegetic .btn-disconnect {
    background: var(--danger);
}

.diegetic .quick-send-delete {
    background: var(--danger);
}

.diegetic .tool-toggle {
    background: #2a3342;
}

.diegetic .tool-header {
    background: rgba(61, 245, 255, 0.08);
    border-bottom-color: rgba(61, 245, 255, 0.2);
}

.diegetic .quick-send-data-input,
.diegetic .quick-send-note {
    background: #0a0f14;
    border-color: rgba(61, 245, 255, 0.25);
    color: var(--text);
}

.diegetic .data-item.sent {
    background-color: rgba(61, 245, 255, 0.08);
    border-left-color: var(--accent);
}

.diegetic .data-item.received {
    background-color: rgba(121, 255, 166, 0.08);
    border-left-color: var(--accent-2);
}

.diegetic .timestamp {
    color: var(--muted);
}

.diegetic .display-mode label,
.diegetic label {
    color: var(--text);
}

.container {
    height: 92vh;
    margin: 0 auto;
    background: white;
    border-radius: 0px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 16px 16px 20px 16px;
}

h1 {
    color: var(--accent);
    margin: 6px 0 18px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.35));
}

h1::after {
    content: "";
    display: block;
    height: 1px;
    width: min(720px, 60%);
    margin: 6px auto 0 auto;
    background: linear-gradient(90deg, rgba(61, 245, 255, 0), rgba(61, 245, 255, 0.45), rgba(61, 245, 255, 0));
    flex-basis: 100%;
    order: 2;
}

.logo {
    width: 42px;
    height: 42px;
    vertical-align: middle;
}

.brand-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    vertical-align: middle;
}

.title-text {
    font-size: 24px;
    color: #ffffff;
}

.title-text {
    display: inline-block;
}

.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    /* 允许换行避免溢出 */
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.lang-group {
    margin-left: auto;
    /* 推到最右 */
}

.lang-group select {
    min-width: 100px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 0px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn-connect {
    background-color: #28a745;
    color: white;
}

.btn-connect:hover {
    background-color: #218838;
}

.btn-disconnect {
    background-color: #dc3545;
    color: white;
}

.btn-disconnect:hover {
    background-color: #c82333;
}

.btn-send {
    background-color: #007bff;
    color: white;
    justify-self: end;
    /* 在网格内靠右 */
}

.btn-send:hover {
    background-color: #0056b3;
}

.btn-clear {
    background-color: #6c757d;
    color: white;
}

.btn-clear:hover {
    background-color: #545b62;
}

select,
input[type="text"],
input[type="number"] {
    height: var(--control-height);
    padding: var(--control-padding-y) var(--control-padding-x);
    border: 1px solid #ddd;
    border-radius: 0px;
    font-size: 14px;
}

/* 行高仅对文本/数字输入应用，避免影响原生 select 渲染 */
input[type="text"],
input[type="number"] {
    line-height: calc(var(--control-height) - 2px);
}

.status {
    padding: 3px;
    border-radius: 0px;
    margin-bottom: 6px;
    font-weight: bold;
}

.status.disconnected {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status.connected {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.main-content {
    height: 70vh;
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    /* 左工具栏 / 主区 / 右侧栏 */
    gap: 6px;
    margin-top: 6px;
}

.left-tools {
    background: rgba(10, 16, 22, 0.40);
    border: 1px solid rgba(61, 245, 255, 0.12);
    border-radius: 0px;
    padding: 12px;
    backdrop-filter: blur(6px) saturate(110%);
    -webkit-backdrop-filter: blur(6px) saturate(110%);
    overflow: hidden;
}

.tool-section {
    border: 1px solid rgba(61, 245, 255, 0.15);
    border-radius: 0px;
    margin-bottom: 12px;
    overflow: hidden;
    background: rgba(17, 23, 31, 0.45);
    backdrop-filter: blur(5px);
}

.tool-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(61, 245, 255, 0.08);
    border-bottom: 1px solid rgba(61, 245, 255, 0.18);
}

.tool-toggle {
    background: #6c757d;
    color: #fff;
    border: none;
    padding: 4px 8px;
    border-radius: 0px;
    font-size: 12px;
    cursor: pointer;
}

.tool-content {
    padding: 10px;
    max-width: 100%;
    overflow-x: hidden;
}

.tool-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: nowrap;
}

.tool-row label {
    width: 56px;
    color: #ffffff;
    font-size: 12px;
}

.tool-row input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    /* 防止溢出 */
}

.data-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.sidebar {
    background: rgba(10, 16, 22, 0.40);
    border: 1px solid rgba(61, 245, 255, 0.12);
    border-radius: 0px;
    padding: 12px;
    overflow-x: hidden;
    /* 防止横向溢出 */
    backdrop-filter: blur(6px) saturate(110%);
    -webkit-backdrop-filter: blur(6px) saturate(110%);
}

.sidebar h3 {
    margin-top: 0;
    margin-bottom: 15px;

}

.data-section {
    border: 1px solid rgba(61, 245, 255, 0.15);
    border-radius: 0px;
    overflow: hidden;
    background: rgba(17, 23, 31, 0.45);
    backdrop-filter: blur(5px);
}

.data-section h3 {
    background-color: rgba(61, 245, 255, 0.06);
    margin: 0;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(61, 245, 255, 0.15);
    color: #9fd7ff;
}

.data-content {
    height: calc(60vh - 130px);
    /* 动态高度，减去标题和边距 */
    overflow-y: auto;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    background: linear-gradient(90deg, rgba(61, 245, 255, 0.08) 1px, transparent 1px) repeat-x,
        linear-gradient(rgba(61, 245, 255, 0.08) 1px, transparent 1px) repeat-y;
    background-size: 24px 24px;
    position: relative;
    /* Firefox scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(61, 245, 255, 0.55) rgba(0, 0, 0, 0.22);
}

/* WebKit-based browsers (Chrome/Edge/Safari) scrollbar styling for data panes */
.data-content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.data-content::-webkit-scrollbar-track {
    background: linear-gradient(90deg, rgba(61, 245, 255, 0.06), rgba(61, 245, 255, 0.02));
    border-left: 1px solid rgba(61, 245, 255, 0.15);
}

.data-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(61, 245, 255, 0.55), rgba(121, 255, 166, 0.55));
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0;
    /* keep hard corners per design */
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.data-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(61, 245, 255, 0.75), rgba(121, 255, 166, 0.75));
}

.data-content::-webkit-scrollbar-thumb:active {
    background: linear-gradient(180deg, rgba(61, 245, 255, 0.95), rgba(121, 255, 166, 0.95));
}

.data-content::-webkit-scrollbar-corner {
    background: transparent;
}

.send-area {
    grid-column: 1 / -1;
    padding: 15px;
    background: rgba(17, 23, 31, 0.45);
    border-radius: 0px;
    border: 1px solid rgba(61, 245, 255, 0.15);
    backdrop-filter: blur(5px);
}

.send-controls {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    /* 设置在下排：HEX、换行、校验组(自适应)、发送按钮(右侧) */
    gap: 10px;
    align-items: center;
}

.send-input {
    flex: 1;
    min-width: 200px;
    min-width: 0;
    /* grid 内防止溢出 */
    grid-column: 1 / -1;
    /* 顶部独占一行 */
}

.checksum-group {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 6px;
    align-items: center;
    white-space: nowrap;
    justify-self: start;
    /* 占据左侧 */
}

.data-item {
    margin-bottom: 8px;
    padding: 6px 8px;
    border-radius: 0px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
}

.data-item.sent {
    background-color: rgba(61, 245, 255, 0.08);
    border-left: 3px solid #3df5ff;
}

.data-item.received {
    background-color: rgba(121, 255, 166, 0.08);
    border-left: 3px solid #79ffa6;
}

.timestamp {
    color: #666;
    font-size: 11px;
}

.data-text {
    margin-top: 2px;
}

.warning {
    background-color: rgba(255, 243, 205, 0.15);
    border: 1px solid rgba(255, 234, 167, 0.35);
    color: #ffe28a;
    padding: 12px;
    border-radius: var(--radius-lg, 8px);
    margin-bottom: 16px;
    backdrop-filter: blur(4px);
}

.display-mode {
    margin-left: 15px;
}

/* 快捷发送相关样式 */
.quick-send-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(61, 245, 255, 0.15);
    border-radius: 0px;
    backdrop-filter: blur(4px);
}

.quick-send-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.quick-send-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    /* 窄宽时换行，避免溢出 */
}

.quick-send-hex {
    font-size: 12px;
    color: #555;
    flex: 1 1 auto;
    /* 优先占据剩余空间 */
    min-width: 80px;
}

.quick-send-data-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(61, 245, 255, 0.18);
    color: #cfe8ff;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 4px;
    resize: vertical;
    max-width: 100%;
}

.quick-send-data-input::placeholder {
    color: #aaa;
}

.quick-send-name {
    flex: 1;
    background: none;
    border: none;
    font-size: 13px;
    padding: 4px;
    border-radius: 0px;
    cursor: text;
}

.quick-send-name:hover {
    background: rgba(255, 255, 255, 0.06);
}

.quick-send-data {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #a9bfd3;
    background: rgba(0, 0, 0, 0.18);
    padding: 4px;
    border-radius: 0px;
    word-break: break-all;
    cursor: pointer;
    border: 1px solid rgba(61, 245, 255, 0.12);
}

.quick-send-data:hover {
    border-color: rgba(61, 245, 255, 0.35);
}

.quick-send-data-edit {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid #3df5ff;
    outline: none;
}

.quick-send-note {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(61, 245, 255, 0.15);
    padding: 4px 6px;
    font-size: 12px;
    color: #9fb4c7;
    border-radius: 0px;
    max-width: 100%;
}

.quick-send-btn {
    background: #00e5ff;
    color: #001014;
    border: none;
    padding: 4px 8px;
    border-radius: 0px;
    cursor: pointer;
    font-size: 12px;
    box-shadow: 0 0 12px rgba(61, 245, 255, 0.35);
}

.quick-send-btn:hover {
    background: #2fdbe6;
}

.quick-send-delete {
    background: #ff5577;
    color: white;
    border: none;
    padding: 2px 6px;
    border-radius: 0px;
    cursor: pointer;
    font-size: 11px;
}

.quick-send-delete:hover {
    background: #ff6f8d;
}

.quick-send-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    /* 顶部添加/导出/导入按钮在窄宽时换行 */
}

.quick-send-controls button {
    padding: 6px 12px;
    font-size: 12px;
}

/* footer credit merged into site-info */

/* 站点信息栏 */
.site-info {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    font-size: 12px;
    color: #cfe8ff;
    z-index: 999;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(61, 245, 255, 0.25);
    border-radius: 0px;
    padding: 6px 10px;
}

.site-info a {
    color: #7ff7ff;
    text-decoration: none;
}

.site-info a:hover {
    color: #cfffff;
}

/* 响应式设计 */
@media (max-width: 768px) {
    h1 {
        gap: 8px;
    }

    .brand-logo {
        width: 32px;
        height: 32px;
    }

    .main-content {
        grid-template-columns: 1fr;
        /* 小屏堆叠 */
    }

    .data-area {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
    }

    .control-group {
        flex-wrap: wrap;
    }
}

/* 细微噪点叠加（通用，可覆写） */
.noise-overlay::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: var(--noise-height, 180px);
    /* 限制容器顶部噪点高度 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
    pointer-events: none;
    mix-blend-mode: overlay;
    border-radius: inherit;
}

@media (max-width: 768px) {
    .noise-overlay::before {
        height: var(--noise-height-mobile, 140px);
    }
}

/* 右侧快捷发送：可滚动列表 */
#quickSendList {
    max-height: 58vh;
    /* 限制最大高度，防止过高 */
    overflow-y: auto;
}

/* Firefox */
#quickSendList {
    scrollbar-width: thin;
    scrollbar-color: rgba(61, 245, 255, 0.55) rgba(0, 0, 0, 0.22);
}

/* WebKit */
#quickSendList::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

#quickSendList::-webkit-scrollbar-track {
    background: linear-gradient(90deg, rgba(61, 245, 255, 0.06), rgba(61, 245, 255, 0.02));
    border-left: 1px solid rgba(61, 245, 255, 0.15);
}

#quickSendList::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(61, 245, 255, 0.55), rgba(121, 255, 166, 0.55));
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

#quickSendList::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(61, 245, 255, 0.75), rgba(121, 255, 166, 0.75));
}