:root {
    --font-sans: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

    --color-bg: #14181c;
    --color-bg-elevated: #1c2228;
    --color-text: #d8dee3;
    --color-text-muted: #7f8c9a;
    --color-border: #2a3138;
    --color-accent: #00e054;
    --color-danger: #e0564a;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
}

body {
    display: flex;
    min-height: 100vh;
}

h1,
h2,
h3 {
    font-weight: 700;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    color: var(--color-accent);
}

button {
    font: inherit;
    cursor: pointer;
}

input,
select {
    font: inherit;
    background: var(--color-bg-elevated);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 7px 10px;
}

input:focus,
select:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

/* Buttons, ported loosely from the dioxus button/badge component kit */

button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
    color: var(--color-text);
    font-size: 0.9em;
    line-height: 1.2;
}

button:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

button[data-active="true"],
button.is-active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

button.ghost {
    background: transparent;
    border-color: transparent;
}

button.primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

button.destructive {
    background: transparent;
    border-color: var(--color-danger);
    color: var(--color-danger);
}

button.destructive:hover {
    background: var(--color-danger);
    color: #fff;
}

button:disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

/* Badges */

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 0.78em;
    line-height: 1.6;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    white-space: nowrap;
}

.badge-accent {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}


.app-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
}

header {
    flex: 0 0 auto;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
}

.app-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 16px;
}

.header-logout {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

@media (max-width: 480px) {
    .header-logout {
        padding: 6px 10px;
        font-size: 0.85em;
    }
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.logo {
    font-size: 1.15em;
    font-weight: 700;
}

.app-header img {
    width: 2.5rem;
    margin-right: 0.5rem;
}

.app-content {
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.app-content-inner {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 36px 24px;
}

footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
}

.footer-menu {
    list-style: none;
    margin: 0;
    padding: 6px 16px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 8px;
}

.footer-menu-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 64px;
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--color-text);
    text-align: center;
    font-size: 0.75em;
}

.footer-menu-button:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.footer-menu-button[data-active="true"] {
    background: var(--color-accent);
    color: #fff;
}

.footer-menu-button .icon {
    font-size: 1.3em;
    line-height: 1;
}

@media (max-width: 480px) {
    .footer-menu {
        justify-content: space-around;
        padding: 6px 4px;
    }

    .footer-menu-button {
        min-width: 0;
        flex: 1;
        padding: 6px 4px;
    }
}

/* Page content */

.filters,
.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 24px;
}

.filters label,
.inline-form label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9em;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 20px 0;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.9em;
}

.auth-form button {
    margin-top: 6px;
}

.password-field {
    position: relative;
    display: flex;
}

.password-field input {
    flex: 1;
    padding-right: 34px;
}

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    border: none;
    background: transparent;
}

.password-toggle:hover img {
    opacity: 0.8;
}

.auth-error {
    margin: 20px 0 0;
    padding: 10px 14px;
    border: 1px solid var(--color-danger);
    border-radius: 6px;
    color: var(--color-danger);
    font-size: 0.9em;
}

.scp-type-picker-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.scp-type-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.scp-hidden-toggle-row {
    margin-bottom: 12px;
    font-size: 0.9em;
}

.goi-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.goi-formats {
    display: flex;
    flex-direction: column;
    flex: 0 0 220px;
    gap: 8px;
    position: sticky;
    top: 36px;
    max-height: calc(100vh - 72px);
    overflow-y: auto;
    padding-right: 8px;
}

.goi-formats button {
    text-align: left;
}

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

.error {
    color: var(--color-danger);
}

.item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.item-tag-heading {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.item-metadata {
    margin-top: 4px;
    color: var(--color-text-muted);
    font-size: 0.85em;
}

.item-metadata p {
    margin: 2px 0;
}

/* Card */

.card {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-elevated);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

.card-header h3 {
    margin: 0;
}

.card-header p {
    margin: 4px 0 0;
    color: var(--color-text-muted);
    font-size: 0.9em;
}

.card-content {
    padding: 8px 16px;
}

/* Item group / item rows, ported from the dioxus item primitives */

.item-group {
    list-style: none;
    margin: 0;
    padding: 0;
}

.item-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--color-border);
}

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

.item-row.is-muted {
    opacity: 0.5;
}

.item-row-main,
.item-row-view {
    flex: 1;
    min-width: 0;
}

.item-row-main a:hover .item-title,
.item-row-view a:hover .item-title {
    color: var(--color-accent);
}

.item-title {
    font-weight: 600;
}

.item-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
}

/* Inline list-rename rows (Home page): each .item-row renders both a view
   block and an edit block; Edit/Cancel just toggle the "editing" class
   client-side (no server round-trip), only Save hits the API. */
.item-row-edit {
    display: none;
    flex: 1;
    flex-direction: column;
    gap: 6px;
}

.item-row.editing .item-row-view {
    display: none;
}

.item-row.editing .item-row-edit {
    display: flex;
}

.item-separator {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 0;
}

/* Pagination */

.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    font-size: 0.9em;
}

.pagination a[aria-current="page"] {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.pagination .ellipsis {
    border: none;
    color: var(--color-text-muted);
}

/* Misc helpers */

.muted {
    color: var(--color-text-muted);
}

.stub-note {
    color: var(--color-text-muted);
    font-size: 0.85em;
    border: 1px dashed var(--color-border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 12px;
}

.loading {
    color: var(--color-text-muted);
    padding: 20px 0;
}

/* Rating component */
.rating {
    display: flex;
}

.rating input {
    position: absolute;
    left: -100vw;
}

.rating label,
.rating span {
    width: 1em;
    height: 2em;
    overflow: hidden;
    box-sizing: border-box;
    background-repeat: no-repeat, no-repeat;

    /* Coloured sprite position, then static grey position */
    background-position: 0 0, 0 0;
}

.rating-odd {
    background-image:
        url('../icon/left-star.svg'),
        url('../icon/left-grey-star.svg');
}

.rating-even {
    background-image:
        url('../icon/right-star.svg'),
        url('../icon/right-grey-star.svg');
}

#rating-none {
    background-image: url('../icon/x.svg');
    width: 2em;
    height: 2em;
}

/* Unselected states */
.rating:not(:hover) input:checked~input+label,
.rating input:hover~input+label {
    background-position: -48px 0, 0 0;
}

/* Hide the "none" label by default */
#rating-none {
    display: none;
}

/* Show it when any other rating is checked */
.rating:has(input:not(#ratingNone):checked) #rating-none {
    display: inline-block;
}

/* Static (non-interactive) rating display, e.g. for a logged read's rating */
.rating-readonly {
    cursor: default;
}

.rating-readonly .rating-off {
    background-position: -48px 0, 0 0;
}

/* ITEM PAGE */
#item-page {
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
    gap: 32px;
    align-items: flex-start;
}

#item-detail,
#item-user {
    flex: 1;
    min-width: 0;
}

#item-user {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.base-lists {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

details {
    cursor: pointer;
    font-weight: 600;

    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 10px 12px;
}

.list-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}

.logs-list {
    list-style: none;
    margin: 8px 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.logs-list li {
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.9em;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.logs-list li p {
    width: 100%;
    margin: 2px 0 0;
    color: var(--color-text-muted);
}

@media (max-width: 720px) {
    #item-page {
        flex-direction: column;
    }
}