:root {
    --bg: #0f0f0f;
    --panel: #111111;
    --border: #1f1f1f;
    --divider: #1b1b1b;
    --hover: #171717;
    --text: #f2f2f2;
    --muted: #8b8b8b;
    --dim: #6e6e6e;
    --accent: #f0a726;
    --zebra: #161616;
    --modal-bg: #161616;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

.page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 40px 24px 64px;
}

.page-logo {
    display: block;
    width: 100%;
    max-width: 420px;
    height: auto;
    margin: 0 auto;
}

/* --- toolbar --- */

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 24px 0 18px;
    flex-wrap: wrap;
}

.search {
    position: relative;
    flex: 1 1 auto;
    min-width: 200px;
}

.search svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--dim);
    pointer-events: none;
}

.search input {
    width: 100%;
    height: 38px;
    padding: 0 14px 0 38px;
    border: 1px solid #262626;
    border-radius: 999px;
    background: #141414;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.search input::placeholder {
    color: var(--dim);
}

.search input:focus {
    border-color: #3a3a3a;
    background: #181818;
}

.search input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid #262626;
    border-radius: 999px;
    background: #141414;
    color: #cfcfcf;
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.chip:hover {
    border-color: #3a3a3a;
    background: #191919;
}

/* --s normalises the differing padding baked into each icon file */
.chip img {
    width: calc(14px * var(--s, 1));
    height: calc(14px * var(--s, 1));
    flex-shrink: 0;
    object-fit: contain;
}

.chip .n {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--dim);
}

.editor-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 16px;
    border: 1.5px solid var(--accent);
    border-radius: 999px;
    background: rgba(240, 167, 38, 0.12);
    color: var(--accent);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

.editor-link-btn:hover {
    background: rgba(240, 167, 38, 0.22);
}

.editor-link-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* --- table --- */

.panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
    overflow: hidden;
}

.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 70px 170px 205px 84px;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
}

.thead {
    border-bottom: 1px solid var(--border);
    height: 40px;
}

.th {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #7d7d7d;
    cursor: pointer;
    transition: color 0.15s;
}

.th:hover {
    color: #b8b8b8;
}

.th.sorted {
    color: #cfcfcf;
}

.th svg {
    width: 12px;
    height: 12px;
    opacity: 0;
    transition: transform 0.15s, opacity 0.15s;
}

.th.sorted svg {
    opacity: 1;
}

.th.sorted.asc svg {
    transform: rotate(180deg);
}

/* aligns the Name header with the entry names rather than their icons */
.th:first-child {
    padding-left: 34px;
}

.th-date {
    justify-content: flex-end;
}

.entry {
    height: 38px;
    border-top: 1px solid var(--divider);
    cursor: pointer;
    transition: background 0.12s;
    text-align: left;
    width: 100%;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    background: none;
    font: inherit;
    color: inherit;
}

.entry:first-child {
    border-top: 0;
}

.entry:nth-child(even) {
    background: var(--zebra);
}

.entry:hover {
    background: var(--hover);
}

.entry:focus-visible {
    outline: 1px solid #3a3a3a;
    outline-offset: -1px;
}

.name {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 23px;
    height: 23px;
    border-radius: 7px;
    flex-shrink: 0;
}

.badge img {
    width: calc(15px * var(--s, 1));
    height: calc(15px * var(--s, 1));
    object-fit: contain;
}

.name-block {
    min-width: 0;
}

.name-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13.5px;
}

.meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--muted);
}

.date {
    text-align: right;
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.sub {
    display: none;
}

.empty {
    padding: 52px 20px;
    text-align: center;
    font-size: 13px;
    color: var(--dim);
}

/* --- detail modal --- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 100;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 100%;
    max-width: 420px;
    background: var(--modal-bg);
    border: 1px solid #262626;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.97) translateY(6px);
    transition: transform 0.15s;
}

.modal-backdrop.open .modal {
    transform: none;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 22px 20px 18px;
}

.modal-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    flex-shrink: 0;
}

.modal-badge img {
    width: calc(23px * var(--s, 1));
    height: calc(23px * var(--s, 1));
    object-fit: contain;
}

.modal-title-block {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.modal-title {
    margin: 0;
    font-size: 16.5px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-category {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--dim);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
    background: #232323;
    color: var(--text);
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-divider {
    height: 1px;
    background: var(--border);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

.modal-field {
    display: flex;
    align-items: baseline;
    gap: 16px;
}

.modal-label {
    width: 84px;
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #7d7d7d;
}

.modal-value {
    font-size: 13.5px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-value-link {
    white-space: normal;
    overflow: visible;
    word-break: break-all;
    font-size: 12.5px;
    color: var(--muted);
    user-select: all;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 18px 20px 20px;
}

.modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 42px;
    border-radius: 999px;
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s, opacity 0.15s, border-color 0.15s, color 0.15s;
}

.modal-btn svg {
    width: 15px;
    height: 15px;
}

.modal-open-btn {
    flex: 1.6;
    border: 1.5px solid;
    background: transparent;
}

.modal-open-btn:hover:not(:disabled) {
    filter: brightness(1.2);
}

.modal-open-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.modal-close-btn {
    flex: 1;
    border: 1.5px solid #333;
    background: transparent;
    color: #cfcfcf;
}

.modal-close-btn:hover {
    border-color: #4a4a4a;
    color: var(--text);
}

@media (max-width: 860px) {
    .page {
        padding: 28px 16px 48px;
    }

    h1 {
        font-size: 21px;
    }

    .row {
        grid-template-columns: minmax(0, 1fr) 72px;
        gap: 12px;
        padding: 0 14px;
    }

    .entry {
        height: 54px;
    }

    .meta {
        display: none;
    }

    .th:nth-child(2),
    .th:nth-child(3),
    .th:nth-child(4) {
        display: none;
    }

    .sub {
        display: block;
        margin-top: 3px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 11.5px;
        color: var(--dim);
    }

    .search {
        flex: 1 1 100%;
    }
}
