/* Standard Works. Colours follow the visitor's system setting unless they picked a theme with the
   switcher (data-theme="light" or "dark" on <html>); dark values are defined once for each case. */
:root {
    color-scheme: light dark;
    --bg: #fff;
    --text: #222;
    --muted: #666;
    --link: #06c;
    --rule: #ddd;
    --panel: #f3f4f6;
    --panel-border: #d5d8dc;
    --chip: #fff;
    --chip-border: #b8bdc4;
    --chip-on: #e3eefb;
    --chip-on-border: #06c;
    --field-bg: #fff;
    --field-border: #999;
    --bad: #c00;
    --accent: #e8770e;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #16181b;
        --text: #e3e5e8;
        --muted: #a9aeb5;
        --link: #7db8ff;
        --rule: #33383e;
        --panel: #1f2226;
        --panel-border: #3d4249;
        --chip: #1f2226;
        --chip-border: #4a5058;
        --chip-on: #1d3144;
        --chip-on-border: #7db8ff;
        --field-bg: #1f2226;
        --field-border: #5a6068;
        --bad: #ff7b72;
        --accent: #f59a42;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #16181b;
    --text: #e3e5e8;
    --muted: #a9aeb5;
    --link: #7db8ff;
    --rule: #33383e;
    --panel: #1f2226;
    --panel-border: #3d4249;
    --chip: #1f2226;
    --chip-border: #4a5058;
    --chip-on: #1d3144;
    --chip-on-border: #7db8ff;
    --field-bg: #1f2226;
    --field-border: #5a6068;
    --bad: #ff7b72;
    --accent: #f59a42;
}

:root[data-theme="light"] {
    color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
    margin: 0 auto;
    max-width: 950px;
    padding: 0 16px;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
}

a { color: var(--link); }

h1, h2, h3 { margin: 0; font-weight: normal; }
h2 { font-size: 26px; line-height: 1.2; }
h3 { font-size: 19px; }

button, input { font: inherit; color: inherit; }

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

.notice {
    padding: 10px 14px;
    border: 1px solid var(--panel-border);
    background: var(--panel);
}

/* Header: logo centred, theme switcher at the right */
.site-header {
    position: relative;
    padding: 24px 52px 18px;
    border-bottom: 1px solid var(--rule);
    text-align: center;
}
.site-header img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

/* The logo is black on white: in dark mode, light lettering on the page colour */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .site-header img { filter: invert(1); mix-blend-mode: screen; }
}
:root[data-theme="dark"] .site-header img { filter: invert(1); mix-blend-mode: screen; }

#theme-toggle {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    padding: 7px;
    border: 1px solid var(--field-border);
    border-radius: 50%;
    background: var(--bg);
    color: var(--text);
    line-height: 0;
    cursor: pointer;
}
#theme-toggle:hover, #theme-toggle:focus-visible { color: var(--link); border-color: var(--link); }
#theme-toggle[hidden] { display: none; }
#theme-toggle svg { width: 20px; height: 20px; }
#theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) #theme-toggle .icon-sun { display: inline; }
    :root:not([data-theme="light"]) #theme-toggle .icon-moon { display: none; }
}
:root[data-theme="dark"] #theme-toggle .icon-sun { display: inline; }
:root[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

.intro {
    margin: 0;
    padding: 18px 0;
    border-bottom: 1px solid var(--rule);
    font-size: 16px;
}

/* Steps: label on the left, controls on the right */
.step {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 24px;
    padding: 24px 0;
    border-bottom: 1px solid var(--rule);
}
.step-label p { margin: 6px 0 0; color: var(--muted); }

/* Step 1: volume buttons and the reading list */
.step-body:first-child { min-width: 0; }
.volumes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.volume {
    min-height: 52px;
    padding: 8px 10px;
    border: 1px solid var(--chip-border);
    border-radius: 6px;
    background: var(--chip);
    font-size: 16px;
    text-align: left;
    cursor: pointer;
}
.volume:hover { border-color: var(--chip-on-border); }
.volume[aria-pressed="true"] {
    border-color: var(--chip-on-border);
    background: var(--chip-on);
}
.volume .plus {
    display: inline-block;
    width: 1.2em;
    color: var(--link);
    font-weight: bold;
}

.reading-list {
    padding: 12px 14px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: var(--panel);
}
.reading-list h3 { font-size: 15px; font-weight: bold; }
.reading-list ol { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: item; }
.reading-list ol:empty { display: none; }
/* Name (numbered) then the move and remove buttons, on one line */
.reading-list li { display: flex; align-items: center; gap: 4px; max-width: 360px; padding: 3px 0; counter-increment: item; }
.reading-list li::before { content: counter(item) "."; min-width: 1.6em; }
.reading-list li span { flex: 1; min-width: 0; }
.reading-list p { margin: 6px 0 0; }
.reading-list p[hidden] { display: none; }
.icon {
    width: 32px;
    height: 32px;
    flex: none;
    border: 1px solid var(--chip-border);
    border-radius: 4px;
    background: var(--chip);
    line-height: 1;
    cursor: pointer;
}
.icon:disabled { opacity: .35; cursor: default; }
.icon:not(:disabled):hover { border-color: var(--chip-on-border); }

/* Step 2: dates and totals */
.dates {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px 24px;
}
.dates label { display: flex; flex-direction: column; gap: 4px; font-weight: bold; }
input[type="date"], input[type="text"] {
    padding: 7px 8px;
    border: 1px solid var(--field-border);
    border-radius: 4px;
    background: var(--field-bg);
    font-weight: normal;
}
.info {
    display: grid;
    grid-template-columns: auto auto;
    gap: 2px 14px;
    margin: 0;
    padding: 10px 14px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: var(--panel);
}
.info dt { font-weight: bold; }
.info dd { margin: 0; }
.bad { color: var(--bad); }

/* Step 3: the feed */
.feed { display: flex; align-items: center; gap: 16px; }
.feed-icon { flex: none; line-height: 0; }
.feed-text { flex: 1; min-width: 0; }
.feed-message { margin: 0; font-size: 24px; font-weight: bold; }
.feed-actions { display: flex; gap: 8px; margin: 0; }
.feed-actions[hidden], .feed-message[hidden] { display: none; }
#feed-url { flex: 1; min-width: 0; }
#copy {
    padding: 7px 16px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: var(--accent);
    color: #1b1b1b;
    font-weight: bold;
    cursor: pointer;
}
.help { margin: 12px 0 0; color: var(--muted); }

/* Advanced options */
.options { display: flex; flex-wrap: wrap; gap: 16px 48px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { padding: 0; font-weight: bold; }
fieldset label { display: block; padding: 3px 0; cursor: pointer; }

footer {
    padding: 20px 0 28px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

/* Phones: steps stack, reading list rows wrap */
@media (max-width: 640px) {
    .site-header { padding: 18px 44px 14px; }
    .step { grid-template-columns: 1fr; gap: 12px; padding: 18px 0; }
    h2 { font-size: 22px; }
    .volumes { grid-template-columns: 1fr 1fr; }
    .volume { font-size: 15px; }
    .icon { width: 38px; height: 36px; }
    .feed { align-items: flex-start; }
    .feed-icon img { width: 48px; height: 48px; }
    .feed-message { font-size: 19px; }
    .feed-actions { flex-wrap: wrap; }
    #feed-url { flex-basis: 100%; }
}
