/* Shared extension palette, aligned with the Read Later landing page. */
:root {
    color-scheme: light dark;
    --accent: #c2410c;
    --accent-hover: #9a3412;
    --accent-soft: #fdf0e8;
    --accent-contrast: #ffffff;
    --background: #f6f7f9;
    --surface: #ffffff;
    --surface-subtle: #f1f3f5;
    --surface-raised: #ffffff;
    --selected: #eceef1;
    --border: #e3e6ea;
    --border-strong: #a3a9b1;
    --text: #1f2328;
    --muted: #5f6670;
    --success: #1a7f37;
    --warning: #9a6700;
    --error: #cf222e;
    --video: #0969da;
    --local: color-mix(in srgb, var(--accent) 40%, var(--muted));
    --icon-filter: opacity(0.65);
    --shadow: 0 4px 14px rgb(0 0 0 / 12%);
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7178' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --font-ui: system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
    accent-color: var(--accent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Text fields and selects show focus with their own border and glow. */
select,
textarea,
input:not([type="checkbox"], [type="radio"], [type="file"]) {
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

select:focus-visible,
textarea:focus-visible,
input:not([type="checkbox"], [type="radio"], [type="file"]):focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

select {
    height: 34px;
    padding: 0 30px 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface) var(--chevron) no-repeat right 11px center / 10px 6px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    appearance: none;
}

select:hover:not(:disabled) {
    border-color: var(--border-strong);
}

::selection {
    background: var(--accent-soft);
    color: var(--text);
}

@media (prefers-color-scheme: dark) {
    :root {
        --accent: #ff8c52;
        --accent-hover: #ffa778;
        --accent-soft: #3a2a21;
        --accent-contrast: #1f2023;
        --background: #1f2023;
        --surface: #28292c;
        --surface-subtle: #303134;
        --surface-raised: #4a4c50;
        --selected: #393b3f;
        --border: #3c4043;
        --border-strong: #70757c;
        --text: #e8eaed;
        --muted: #a8adb4;
        --success: #7ee2a8;
        --warning: #e3b341;
        --error: #ff7b72;
        --video: #79b8ff;
        --icon-filter: invert(88%);
        --shadow: 0 4px 14px rgb(0 0 0 / 45%);
        --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a8adb4' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    }
}
.tooltip-popup {
    position: fixed;
    z-index: 1000;
    box-sizing: border-box;
    max-width: min(320px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background-color: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    font: 400 11px/16px var(--font-ui);
    opacity: 0;
    overflow-wrap: anywhere;
    pointer-events: none;
    transform: translateY(3px);
    transition: opacity 120ms ease, transform 120ms ease;
    visibility: hidden;
    white-space: pre-wrap;
}

.tooltip-detail {
    display: block;
    margin-top: 2px;
    color: var(--muted);
}

.tooltip-popup.visible {
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.tooltip-popup[data-placement="bottom"] {
    transform: translateY(-3px);
}

.tooltip-popup.visible[data-placement="bottom"] {
    transform: translateY(0);
}

@media screen and (prefers-reduced-motion: reduce) {
    .tooltip-popup {
        transition: none;
    }
}
#reading-list {
    max-height: 492px;
    overflow-y: scroll;
    font-size: 14px;
    list-style: none;
    padding: 6px;
    /* Rows scrolled into the top or bottom padding stay hidden and unhoverable. */
    clip-path: inset(6px 0);
}

#reading-list li {
    display: flex;
    align-items: center;
    padding: 0 10px;
    line-height: 32px;
    border-radius: 5px;
    /* Keep the list padding visible when keyboard moves scroll an item in. */
    scroll-margin-block: 6px;
}

#reading-list li[hidden] {
    display: none;
}

#reading-list li.is-clipped {
    pointer-events: none;
}

#reading-list li.active {
    background: var(--selected);
}

#reading-list a {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-decoration: none;
    color: var(--text);
    cursor: default;
}

#reading-list a.scroll-title {
    text-overflow: clip;
}

#reading-list .title-track {
    display: inline-flex;
    gap: 32px;
    min-width: max-content;
}

#reading-list .title-primary {
    display: inline-block;
}

#reading-list .title-repeat {
    display: none;
}

#reading-list a.scroll-title.is-overflowing .title-repeat {
    display: inline-block;
}

#reading-list a.scroll-title.is-overflowing:hover .title-track {
    animation: scroll-item-title var(--title-scroll-duration) linear infinite;
}

@keyframes scroll-item-title {
    to {
        transform: translateX(var(--title-scroll-offset));
    }
}

#reading-list a.url-only {
    color: var(--muted);
}

#reading-list li.local-overflow a {
    color: var(--local);
}

#reading-list img {
    margin-right: 8px;
    padding: 1px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    box-sizing: content-box;
}

/* Theme the delete icon like the status-bar icons. */
#reading-list img[data-delete-action] {
    filter: var(--icon-filter);
    opacity: 0.8;
}

#reading-list img[data-delete-action]:hover {
    opacity: 1;
}

#reading-list .percent {
    font-size: 12px;
    font-weight: 500;
    padding-left: 5px;
    cursor: default;
    font-variant-numeric: tabular-nums;
}

#reading-list .scroll {
    color: var(--accent);
}

#reading-list li.active .scroll {
    color: var(--accent-hover);
}

#reading-list .video {
    color: var(--video);
}

@media screen and (prefers-reduced-motion: reduce) {
    #reading-list a.scroll-title.is-overflowing:hover .title-track {
        animation: none;
    }
}

.empty-state {
    display: none;
    padding: 28px 24px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.empty-state strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text);
    font-weight: 600;
}

.empty-state em {
    font-style: normal;
    color: var(--text);
}

/* Shown once the list has loaded and every row is gone or hidden after
   deletion, so it doesn't flash while saved pages are still being read. */
main:not([aria-busy="true"]):not(:has(#reading-list li:not([hidden]))) .empty-state {
    display: block;
}

main:not([aria-busy="true"]):not(:has(#reading-list li:not([hidden]))) #reading-list {
    padding: 0;
}
#status-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    box-sizing: border-box;
    list-style-type: none;
    /* Overlap the list's clipped bottom padding so the icons sit 8px from
       the last row and 8px from the popup edge. */
    position: relative;
    margin-top: -4px;
    padding: 0 10px 2px 16px;
    height: 30px;
    background: var(--surface);
    width: 100%;
}

#status-bar li {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0;
    color: var(--muted);
    font-size: 12px;
}

#status-bar a {
    color: inherit;
    font-size: inherit;
    cursor: pointer;
    text-decoration: none;
}

#status-bar li a:hover {
    color: var(--accent);
}

#status-bar #count {
    color: var(--muted);
    cursor: default;
    margin-right: auto; /* Push other items to the end. */
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

#status-bar .count-separator {
    white-space: pre;
    opacity: 0.6;
}

/* Same color as local-only items in the list; the tooltip has the breakdown. */
#status-bar #count.has-local #total {
    color: var(--local);
}

#status-bar #count[data-format="total"] :is(#row, .count-separator) {
    display: none;
}

#status-bar img {
    display: block;
    cursor: pointer;
    width: 16px;
    height: 16px;
    filter: var(--icon-filter);
}

#status-bar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

#status-bar button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    background: var(--selected);
}

#status-bar button:hover {
    background: var(--selected);
}

#status-bar #question {
    margin-right: 0;
}

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

body {
    width: 400px;
    background: var(--surface);
    color: var(--text);
    font: 14px/1.5 var(--font-ui);
}

::-webkit-scrollbar {
    display: none;
}

html {
    background: var(--surface);
}
