@font-face {
    font-family: 'BoxDrawing';
    src: url('box-drawing.be16be8d.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: #008080;
    font-family: "MS Sans Serif", Tahoma, Geneva, sans-serif;
    font-size: 11px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 16px 0;
    min-height: 100vh;
}

.window {
    background: #c0c0c0;
    border-top: 3px solid #fff;
    border-left: 3px solid #fff;
    border-right: 3px solid #000;
    border-bottom: 3px solid #000;
}

.title-bar {
    background: linear-gradient(90deg, #000080, #1084d0);
    color: #fff;
    font-weight: bold;
    padding: 2px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 18px;
    user-select: none;
    font-size: 11px;
}

.window-body {
    margin: 4px;
    background: #c0c0c0;
}

/* ── Tab Control ── */
.tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: -3px;
    position: relative;
    z-index: 1;
}

.tab-btn {
    background: #c0c0c0;
    border-top: 3px solid #fff;
    border-left: 3px solid #fff;
    border-right: 3px solid #404040;
    border-bottom: 3px solid #404040;
    padding: 3px 12px;
    font-family: "MS Sans Serif", Tahoma, Geneva, sans-serif;
    font-size: 11px;
    cursor: pointer;
    user-select: none;
    height: 22px;
    line-height: 1;
}

.tab-btn:hover {
    background: #d0d0d0;
}

.tab-btn:active,
.tab-btn.active {
    border-top: 3px solid #808080;
    border-left: 3px solid #808080;
    border-right: 3px solid #fff;
    border-bottom: none;
    background: #c0c0c0;
    padding-bottom: 6px;
    height: 25px;
}

.tab-panel {
    display: none;
    border-top: 3px solid #808080;
    border-left: 3px solid #808080;
    border-right: 3px solid #fff;
    border-bottom: 3px solid #fff;
    padding: 8px;
    background: #c0c0c0;
}

.tab-panel.active {
    display: block;
}

.grid {
    display: inline-grid;
    border-top: 3px solid #808080;
    border-left: 3px solid #808080;
    border-right: 3px solid #fff;
    border-bottom: 3px solid #fff;
    background: #fff;
}

.cell {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-family: "BoxDrawing", "Courier New", "Lucida Sans Unicode", monospace;
    cursor: pointer;
    user-select: none;
    background: #c0c0c0;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-right: 2px solid #404040;
    border-bottom: 2px solid #404040;
}

.cell:hover {
    border-top: 2px solid #404040;
    border-left: 2px solid #404040;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    background: #c0c0c0;
    color: #000;
}

.cell.empty {
    color: transparent;
    cursor: default;
    border: 1px solid #808080 !important;
}
.cell.copied {
    background: #a0a0a0 !important;
    border-top: 2px solid #404040 !important;
    border-left: 2px solid #404040 !important;
    border-right: 2px solid #fff !important;
    border-bottom: 2px solid #fff !important;
}

.status-bar {
    margin: 4px;
    padding: 2px 4px;
    border-top: 3px solid #808080;
    border-left: 3px solid #808080;
    border-right: 3px solid #fff;
    border-bottom: 3px solid #fff;
    font-size: 11px;
}

/* ── Body layout: log + main area ── */
.body-layout {
    display: flex;
    gap: 4px;
    align-items: stretch;
}

.log-panel {
    position: relative;
    border-top: 3px solid #808080;
    border-left: 3px solid #808080;
    border-right: 3px solid #fff;
    border-bottom: 3px solid #fff;
    background: #fff;
    overflow: hidden;
}

.log-entries {
    position: absolute;
    top: 3px; left: 3px; right: 3px; bottom: 3px;
    padding: 6px;
    font-family: "BoxDrawing", "Courier New", monospace;
    font-size: 11px;
    line-height: 1.5;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
}

.log-spacer {
    flex: 1 0 auto;
    min-height: 0;
}

.log-entry {
    padding: 1px 0;
    line-height: 1.4;
}

.main-area {
    flex: 1 1 0;
    min-width: 0;
}

.tooltip {
    display: none;
    position: fixed;
    background: #ffffcc;
    border: 1px solid #000;
    padding: 6px 10px;
    font-size: 12px;
    font-family: "BoxDrawing", "Courier New", monospace;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 2px 2px 0 #808080;
    white-space: nowrap;
}

.tooltip .char-preview {
    font-size: 28px;
    margin-right: 8px;
    vertical-align: middle;
    font-family: "BoxDrawing", "Courier New", "Lucida Sans Unicode", monospace;
}

.tooltip .detail {
    display: inline-block;
    vertical-align: middle;
    line-height: 1.4;
}

.tooltip .cp { font-weight: bold; }
.tooltip .bin { color: #555; }
.tooltip .name { color: #333; font-size: 11px; }

/* ── Mobile responsive (≤ 500px) ── */
@media (max-width: 500px) {
    body {
        padding: 8px 4px 0;
    }

    .window {
        max-width: calc(100vw - 8px);
        width: fit-content;
    }

    .body-layout {
        flex-direction: column;
    }

    .log-panel {
        width: 100% !important;
        max-height: 100px;
        order: 1;
    }

    .main-area {
        order: 0;
    }

    .cell {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .grid {
        grid-template-columns: repeat(9, 28px) !important;
        grid-template-rows: repeat(9, 28px) !important;
    }

    .tab-panel {
        padding: 4px;
    }

    .tab-btn {
        padding: 3px 8px;
        font-size: 10px;
    }
}