* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, sans-serif;
    color: #222;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    margin: 0.75rem;
    background: #dbeeff;
    color: #1f2933;
    border: 1px solid #a9d2f5;
    border-radius: 12px;
}

header h1 {
    margin: 0;
    font-size: 1.25rem;
    color: #1f2933;
}

#post-url {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1f2933;
}

#post-url code {
    background: rgba(31, 41, 51, 0.08);
    color: #1f2933;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

#header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

#channel-info {
    position: relative;
}

#channel-info summary {
    cursor: pointer;
    list-style: none;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1f2933;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: rgba(31, 41, 51, 0.08);
    transition: background-color 0.15s ease;
}

#channel-info summary::-webkit-details-marker {
    display: none;
}

#channel-info summary:hover {
    background: rgba(31, 41, 51, 0.16);
}

#channel-info[open] summary {
    background: rgba(31, 41, 51, 0.16);
}

.channel-popover {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    width: 340px;
    background: #fff;
    color: #222;
    border: 1px solid #a9d2f5;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    font-size: 0.85rem;
    line-height: 1.5;
    text-align: left;
    z-index: 10;
}

.channel-popover p {
    margin: 0 0 0.6rem;
}

.channel-popover p:last-child {
    margin-bottom: 0;
}

.channel-popover strong {
    color: #1f5fbf;
}

.channel-popover code {
    background: #f1f5f9;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    word-break: break-all;
}

#header-actions {
    display: flex;
    gap: 0.5rem;
}

header button {
    padding: 0.5rem 1.1rem;
    cursor: pointer;
    border: none;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: #3b82f6;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

header button:hover {
    background: #2f6fd9;
    transform: translateY(-1px);
}

header button:active {
    transform: translateY(0);
}

#clear-btn {
    background: #e5533d;
}

#clear-btn:hover {
    background: #cc4530;
}

main {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

#list-pane {
    width: 380px;
    overflow-y: auto;
    border-right: 1px solid #ddd;
}

#message-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.message-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.message-item:hover {
    background: #f5f5f5;
}

.message-item.selected {
    background: #e3f0ff;
}

.message-item .time {
    font-size: 0.8rem;
    font-weight: 700;
    color: #666;
    letter-spacing: 0.03em;
}

.message-item .time .date-part {
    margin-right: 0.6em;
}

.message-item .format-badge {
    display: inline-block;
    align-self: flex-start;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: #e3f0ff;
    color: #1f5fbf;
}

.message-item .remote-ip {
    font-size: 0.85rem;
    color: #444;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

#detail-pane {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border: none;
    border-radius: 999px;
    background: #3b82f6;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.icon-btn:hover {
    background: #2f6fd9;
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(0);
}

.icon-btn svg {
    flex-shrink: 0;
}

.outline-box {
    margin: 0 0 1.5rem;
    padding: 1rem;
    background: #fff;
    outline: 2px solid #4a90d9;
    outline-offset: 3px;
    border-radius: 6px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

.headers-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1rem;
    row-gap: 0.35rem;
    align-items: start;
}

.header-name {
    font-weight: 700;
    color: #0000ff;
    white-space: nowrap;
}

.header-value {
    word-break: break-all;
}

.tok-tag { color: #0000ff; }
.tok-attr-name { color: #ff0000; }
.tok-attr-value { color: #008000; }
.tok-comment { color: #008000; font-style: italic; }
.tok-punctuation { color: #222; }
.tok-key { color: #0000ff; }
.tok-string { color: #008000; }
.tok-number { color: #ff8000; }
.tok-boolean,
.tok-null { color: #0000ff; font-weight: 600; }
