:root {
    --bg: #1f1f1f;
    --bg-elevated: #242424;
    --bg-panel: #1b1b1b;
    --bg-hover: #2b2b2b;
    --bg-active: #333333;
    --bg-selected: #353535;
    --bg-press: #414141;
    --border: #343434;
    --border-color: #343434;
    --border-strong: #444444;
    --text-primary: #f2f2f2;
    --text-secondary: #b4b4b4;
    --text-muted: #8a8a8a;
    --accent: #efefef;
    --accent-text: #111111;
    --danger: #d16f6f;
    --danger-bg: #2a2121;
    --success: #c9c9c9;
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --font-family: "Inter", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

.app-shell {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    width: 100%;
    height: 100vh;
}

.app-sidebar {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: #1d1d1d;
    border-right: 1px solid var(--border);
    padding: 18px 14px 16px;
    overflow: hidden;
}

.sidebar-brand {
    padding: 4px 8px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sidebar-brand p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-label,
.utility-label {
    margin: 0;
    padding: 0 8px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.filter-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-button,
.filter-button {
    width: 100%;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

.sidebar-button:hover,
.filter-button:hover {
    background: var(--bg-hover);
}

.sidebar-button:active,
.filter-button:active {
    background: var(--bg-press);
}

.sidebar-button.is-active,
.filter-button.is-active {
    background: var(--bg-selected);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.sidebar-button.danger {
    color: var(--danger);
}

.sidebar-button.danger:hover,
button.secondary.danger:hover {
    background: #312626;
}

.workspace {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: var(--bg-panel);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    min-height: 56px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
}

.topbar-copy h2 {
    margin: 0;
    font-size: 1.06rem;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.registry-panel {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    margin: 0;
    font-size: 0.95rem;
}

.panel-header p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.registry-body {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr);
}

.vault-list {
    min-height: 0;
    overflow: auto;
    list-style: none;
    margin: 0;
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vault-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px 16px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
}

.item-info {
    min-width: 0;
}

.item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.item-title {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #202020;
    color: var(--text-secondary);
    font-size: 0.76rem;
    white-space: nowrap;
}

.item-status {
    justify-self: end;
}

.item-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
}

.item-actions button {
    flex: 1;
    min-width: 0;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 108px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.status-verified {
    background: #272727;
    color: #ececec;
}

.status-pending {
    background: #2a2222;
    color: #efb6b6;
    border-color: #4b3434;
}

.empty-state {
    margin: 14px 16px 16px;
    padding: 16px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.docs-drawer,
.side-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(460px, 100vw);
    transform: translateX(100%);
    transition: transform 0.2s ease;
    z-index: 1250;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 18px;
    background: #202020;
    border-left: 1px solid var(--border);
    overflow-y: auto;
}

.docs-drawer.active,
.side-drawer.active {
    transform: translateX(0);
    pointer-events: auto;
}

.docs-drawer h3 {
    margin: 0;
    font-size: 0.98rem;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.drawer-header h3 {
    margin: 0;
    font-size: 0.98rem;
}

.docs-drawer p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.drawer-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
    padding-top: 12px;
    overflow-y: auto;
}

.doc-row {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.doc-row:last-child {
    border-bottom: none;
}

.doc-row h4 {
    margin: 0 0 8px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.doc-row p {
    margin: 0;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    width: min(440px, calc(100vw - 24px));
    max-height: min(82vh, 700px);
    overflow-y: auto;
    background: #202020;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow);
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 0.98rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #181818;
    color: var(--text-primary);
    font-family: "IBM Plex Mono", "Consolas", monospace;
    font-size: 0.92rem;
}

input:focus,
select:focus {
    outline: none;
    border-color: #575757;
    background: #1c1c1c;
}

button {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

button:hover {
    background: var(--bg-hover);
}

button:active {
    background: var(--bg-press);
}

button.secondary {
    background: #252525;
    border-color: var(--border);
    color: var(--text-primary);
}

button.danger {
    background: var(--danger-bg);
    border-color: #4b3434;
    color: #efb6b6;
}

.nav-button {
    height: 38px;
}

.nav-info {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.nav-info:hover {
    background: #262626;
    color: var(--text-primary);
}

.nav-info:active {
    background: #373737;
}

.nav-data {
    background: #242424;
    border-color: var(--border);
    color: var(--text-primary);
}

.nav-data:hover {
    background: #2d2d2d;
    border-color: #464646;
}

.nav-data:active {
    background: #3b3b3b;
    border-color: #5a5a5a;
}

.nav-danger {
    background: #2a2121;
    border-color: #4b3434;
    color: #efb6b6;
}

.nav-danger:hover {
    background: #352727;
    border-color: #614141;
}

.nav-danger:active {
    background: #452f2f;
    border-color: #7a5050;
}

.nav-primary {
    background: #efefef;
    border-color: #efefef;
    color: #111111;
}

.nav-primary:hover {
    background: #d8d8d8;
    border-color: #d8d8d8;
    color: #111111;
}

.nav-primary:active {
    background: #bcbcbc;
    border-color: #bcbcbc;
    color: #111111;
}

.close-button {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
    padding: 6px 0;
}

.close-button:hover {
    background: transparent;
    border-color: transparent;
    color: var(--text-primary);
}

.close-button:active {
    background: transparent;
    border-color: transparent;
    color: #ffffff;
}

button svg {
    display: block;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.feedback-msg {
    margin-top: 10px;
    font-size: 0.88rem;
    font-weight: 600;
}

.feedback-success {
    color: var(--success);
}

.feedback-error {
    color: #efb6b6;
}

.tag-badge {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex: none;
}

.matte-blue,
.matte-green,
.matte-red,
.matte-yellow,
.matte-purple,
.matte-grey {
    background: #8f8f8f;
    border: 1px solid #727272;
}

.color-selector {
    display: flex;
    gap: 10px;
}

.color-option {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    cursor: pointer;
    position: relative;
}

.color-option.selected::after {
    content: "";
    position: absolute;
    inset: -4px;
    border: 1px solid #cfcfcf;
    border-radius: 999px;
}

.tag-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.tag-item-row:last-child {
    border-bottom: none;
}

.tag-list {
    max-height: 220px;
    overflow-y: auto;
}

@media (max-width: 960px) {
    body {
        overflow: auto;
    }

    .app-shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }

    .app-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .topbar {
        padding: 12px 14px;
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions {
        flex-wrap: wrap;
    }

    .topbar-actions button {
        flex: 1 1 160px;
    }
}

@media (max-width: 768px) {
    .vault-list {
        padding: 10px 12px 12px;
    }

    .vault-item {
        grid-template-columns: 1fr;
    }

    .item-status {
        justify-self: start;
    }

    .item-actions {
        flex-wrap: wrap;
    }

    .item-actions button {
        flex: 1 1 120px;
    }

    .docs-drawer,
    .side-drawer {
        width: 100vw;
    }

    .docs-drawer,
    .side-drawer {
        padding: 16px;
    }
}
