/*
    Warm paper, ink and a calm deep green: the design of docs/ARCHITECTURE.md → «Вёрстка». Sizes follow the design's scale:
    0.25rem steps, text from 0.75rem (xs) to 2.25rem (4xl), widths 640, 768 and 1024 px.
*/

:root {
    --radius: 0.5rem;
    --background: oklch(0.975 0.008 85);
    --foreground: oklch(0.22 0.015 60);
    --paper: oklch(0.995 0.003 85);
    --ink: oklch(0.2 0.012 60);
    --card: oklch(0.995 0.003 85);
    --primary: oklch(0.38 0.07 160);
    --primary-foreground: oklch(0.98 0.01 120);
    --secondary: oklch(0.94 0.012 85);
    --secondary-foreground: oklch(0.25 0.015 60);
    --muted: oklch(0.945 0.01 85);
    --muted-foreground: oklch(0.5 0.015 60);
    --accent: oklch(0.93 0.03 150);
    --accent-foreground: oklch(0.3 0.06 160);
    --destructive: oklch(0.55 0.19 28);
    --success: oklch(0.5 0.12 155);
    --success-soft: oklch(0.94 0.04 155);
    --warning: oklch(0.6 0.13 65);
    --warning-soft: oklch(0.95 0.045 80);
    --border: oklch(0.9 0.012 80);
    --input: oklch(0.88 0.014 80);
    --ring: oklch(0.38 0.07 160);
    --sidebar: oklch(0.955 0.01 85);
    --sidebar-accent: oklch(0.92 0.014 85);
    --shadow-paper: 0 1px 2px oklch(0.3 0.02 60 / 6%), 0 12px 32px -12px oklch(0.3 0.02 60 / 14%);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --font-sans: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
    --font-serif: "Newsreader", Georgia, serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

/* A clean start: every element is styled here, not by the browser. */

*,
::before,
::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0 solid var(--border);
}

html {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    font-size: inherit;
    font-weight: inherit;
}

ol,
ul {
    list-style: none;
}

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

b,
strong {
    font-weight: bolder;
}

img,
svg {
    display: block;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
    background: transparent;
    border-radius: 0;
}

button,
[role="button"],
label:has(> input[type="radio"]) {
    cursor: pointer;
}

textarea {
    resize: vertical;
}

::placeholder {
    color: var(--muted-foreground);
    opacity: 1;
}

[hidden]:where(:not([hidden="until-found"])) {
    display: none !important;
}

fieldset {
    min-width: 0;
}

/* Text */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.small {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.hint {
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

.faint {
    opacity: 0.7;
}

.strong {
    font-weight: 500;
}

.plain {
    color: var(--foreground);
}

.serif {
    font-family: var(--font-serif);
}

.mono {
    font-family: var(--font-mono);
}

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

.centered {
    text-align: center;
}

.error {
    color: var(--destructive);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.error:empty {
    display: none;
}

.below {
    margin-top: 0.5rem;
}

.below-lg {
    margin-top: 1.5rem;
}

.title {
    font-family: var(--font-serif);
    font-size: 2.25rem;
    line-height: 2.5rem;
}

.title.medium {
    font-size: 1.875rem;
    line-height: 2.25rem;
}

.title.tight {
    line-height: 1.25;
}

.lead {
    margin-top: 0.5rem;
    color: var(--muted-foreground);
}

.eyebrow {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.label {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
}

.label.with-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field-label {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.note {
    margin-top: 1.5rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.alert {
    padding: 0.75rem;
    border: 1px solid color-mix(in oklab, var(--destructive) 30%, transparent);
    border-radius: 0.5rem;
    background: color-mix(in oklab, var(--destructive) 6%, var(--card));
    color: var(--destructive);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.success-line {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.5rem;
    color: var(--success);
    font-size: 0.75rem;
    line-height: 1rem;
}

.text-link {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.text-link:hover {
    color: var(--foreground);
}

.text-link.primary {
    color: var(--primary);
    font-weight: 500;
    text-underline-offset: 2px;
}

.text-link.centered {
    width: 100%;
    font-size: 0.75rem;
    line-height: 1rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 1.5rem;
    color: var(--primary);
    font-size: 0.875rem;
    text-decoration: underline;
    text-underline-offset: 4px;
}

code,
kbd {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1rem;
}

kbd {
    margin: 0 0.125rem;
    padding: 0.125rem 0.375rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

.code-chip {
    padding: 0 0.25rem;
    border-radius: 0.25rem;
    background: var(--muted);
}

/* Icons: wwwroot/img/icons.svg through the icon tag helper. */

.icon {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon.xs {
    width: 0.75rem;
    height: 0.75rem;
}

.icon.sm {
    width: 0.875rem;
    height: 0.875rem;
}

.icon.lg {
    width: 1.25rem;
    height: 1.25rem;
}

.icon.xl {
    width: 2.5rem;
    height: 2.5rem;
}

.icon.primary {
    color: var(--primary);
}

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

.icon.destructive {
    color: var(--destructive);
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Buttons */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.25rem;
    padding: 0.5rem 1rem;
    border-radius: calc(var(--radius) - 2px);
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.15s, color 0.15s;
}

.button:hover {
    background: color-mix(in oklab, var(--primary) 90%, transparent);
}

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

.button.outline {
    border: 1px solid var(--input);
    background: var(--background);
    color: var(--foreground);
}

.button.outline.on-card {
    background: var(--card);
}

.button.outline:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

.button.secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
}

.button.secondary:hover {
    background: color-mix(in oklab, var(--secondary) 80%, transparent);
}

.button.ghost {
    background: none;
    color: var(--foreground);
    box-shadow: none;
}

.button.ghost:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

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

/* A done state, not a control: a span that looks like the button it replaced. */
.button.messaged {
    border: 1px solid color-mix(in oklab, var(--success) 25%, transparent);
    background: var(--success-soft);
    color: var(--success);
    box-shadow: none;
}

.button.sm {
    height: 2rem;
    padding: 0 0.75rem;
    font-size: 0.75rem;
    line-height: 1rem;
}

.button.sm.tall-sm {
    height: 2.25rem;
}

.button.lg {
    height: 2.5rem;
    padding: 0 2rem;
}

.button.icon-only {
    width: 2.25rem;
    padding: 0;
}

.button.wide {
    width: 100%;
}

.button.start {
    justify-content: flex-start;
}

.button.raised {
    box-shadow: var(--shadow-paper);
}

.icon-button {
    display: grid;
    place-items: center;
}

:is(.button, .icon-button, .tool, .chip, .title-option, button):focus-visible,
:is(a):focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

/* Fields */

input:not([type="radio"], [type="checkbox"], [type="hidden"]),
select,
textarea {
    display: block;
    width: 100%;
    min-width: 0;
    height: 2.25rem;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--input);
    border-radius: calc(var(--radius) - 2px);
    background: var(--card);
    font-size: 1rem;
    line-height: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s;
}

textarea {
    height: auto;
    min-height: 60px;
    padding: 0.5rem 0.75rem;
}

textarea.tall {
    min-height: 9rem;
}

select {
    appearance: none;
    padding-right: 2rem;
    background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23746f68' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.625rem center / 1rem;
}

@media (min-width: 768px) {
    input:not([type="radio"], [type="checkbox"], [type="hidden"]),
    select,
    textarea {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: 0 0 0 1px var(--ring), var(--shadow-sm);
}

input.large {
    height: 2.75rem;
}

input.compact {
    font-size: 0.75rem;
    line-height: 1rem;
}

.code-input {
    font-family: var(--font-mono);
    letter-spacing: 0.4em;
}

[aria-invalid="true"] {
    border-color: var(--destructive) !important;
}

.inline-field {
    display: flex;
    gap: 0.5rem;
}

.inline-field > input {
    flex: 1;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.field > span:first-child {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* Cards and badges */

.card {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--card);
}

.card.raised {
    box-shadow: var(--shadow-paper);
}

.avatar {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    border-radius: calc(var(--radius) - 2px);
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font-serif);
    font-size: 0.875rem;
    line-height: 1.25rem;
    object-fit: cover;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1rem;
    white-space: nowrap;
}

.badge-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 9999px;
    background: currentColor;
}

.badge.draft {
    background: var(--muted);
    color: var(--muted-foreground);
}

.badge.in-substack {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge.scheduled {
    background: color-mix(in oklab, var(--primary) 12%, transparent);
    color: var(--primary);
}

.badge.published {
    background: var(--success-soft);
    color: var(--success);
}

.dot {
    flex-shrink: 0;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 9999px;
    background: color-mix(in oklab, var(--muted-foreground) 40%, transparent);
}

.dot.on {
    background: var(--success);
}

/* Segmented choice: tabs and the issue's length, as radio buttons. */

.segmented {
    display: inline-flex;
    align-self: flex-start;
    padding: 0.25rem;
    border-radius: 0.5rem;
    background: var(--muted);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.segmented label {
    padding: 0.375rem 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    color: var(--muted-foreground);
}

.segmented label:has(:checked) {
    background: var(--card);
    color: var(--foreground);
    box-shadow: var(--shadow-sm);
}

.segmented label:has(:focus-visible) {
    outline: 2px solid var(--ring);
}

.segmented input,
.browsers input,
.choice input,
.preset input,
.format input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* The app: a sidebar and the page. */

.shell {
    min-height: 100vh;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--foreground);
    font-family: var(--font-serif);
    font-size: 1.25rem;
    line-height: 1.75rem;
    letter-spacing: -0.025em;
}

.logo-mark {
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: calc(var(--radius) - 2px);
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 1rem;
    font-style: italic;
    line-height: 1.5rem;
}

/* A drawer while open on a phone (popover), a column from 768 px. */
.sidebar:popover-open {
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 85%;
    max-width: 20rem;
    height: 100%;
    margin: 0;
    padding: 1.25rem;
    border: 0;
    background: var(--sidebar);
    color: var(--foreground);
    overflow-y: auto;
}

.sidebar::backdrop {
    background: color-mix(in oklab, var(--ink) 30%, transparent);
}

.drawer-close {
    position: absolute;
    top: 1.25rem;
    right: 1rem;
}

.pub {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem;
}

.pub-text {
    min-width: 0;
}

.pub-name,
.pub-host {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pub-name {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
}

.pub-host {
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

/* The publication opens the switch to the author's other ones. */

.pub-switch summary {
    border-radius: calc(var(--radius) - 2px);
    list-style: none;
    cursor: pointer;
    transition: background-color 0.15s;
}

.pub-switch summary::-webkit-details-marker {
    display: none;
}

.pub-switch summary:hover {
    background: color-mix(in oklab, var(--sidebar-accent) 60%, transparent);
}

.pub-chevron {
    margin-left: auto;
    color: var(--muted-foreground);
    transition: transform 0.15s;
}

.pub-switch[open] .pub-chevron {
    transform: rotate(180deg);
}

.pub-menu {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    margin-top: 0.375rem;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--card);
}

.pub-option {
    width: 100%;
    border-radius: calc(var(--radius) - 2px);
    text-align: left;
}

.pub-option:hover,
.pub-add:hover {
    background: var(--muted);
}

.pub-add {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: calc(var(--radius) - 2px);
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
}

.pub-note {
    padding: 0.375rem 0.5rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
    transition: background-color 0.15s, color 0.15s;
}

.nav a:hover {
    background: color-mix(in oklab, var(--sidebar-accent) 60%, transparent);
    color: var(--foreground);
}

.nav a.active {
    background: var(--sidebar-accent);
    color: var(--foreground);
    font-weight: 500;
}

.sidebar-foot {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: auto;
    font-size: 0.75rem;
    line-height: 1rem;
}

.plan,
.substack-status {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--card);
}

.plan-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.plan-row .strong,
.substack-status b {
    font-weight: 500;
}

.plan-bar {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.plan-bar span {
    flex: 1;
    height: 0.375rem;
    border-radius: 9999px;
    background: var(--muted);
}

.plan-bar span.used {
    background: var(--primary);
}

.plan p {
    margin-top: 0.5rem;
}

.substack-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.substack-status .grow {
    flex: 1;
    min-width: 0;
}

.substack-status .text-link {
    font-size: 0.75rem;
    line-height: 1rem;
    text-underline-offset: 2px;
}

.account {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 0.25rem;
    color: var(--muted-foreground);
}

.signout {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.signout:hover {
    color: var(--foreground);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: color-mix(in oklab, var(--background) 90%, transparent);
    backdrop-filter: blur(8px);
}

.topbar .logo {
    font-size: 1.125rem;
}

.topbar-end {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-substack {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

.main {
    min-width: 0;
}

@media (min-width: 768px) {
    .shell {
        display: grid;
        grid-template-columns: 260px 1fr;
    }

    .sidebar,
    .sidebar:popover-open {
        position: sticky;
        inset: auto;
        top: 0;
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        width: auto;
        max-width: none;
        height: 100vh;
        margin: 0;
        padding: 1.25rem;
        border: 0;
        border-right: 1px solid var(--border);
        background: var(--sidebar);
        color: var(--foreground);
        overflow-y: auto;
    }

    .drawer-close,
    .topbar {
        display: none;
    }
}

/* Pages */

.page {
    margin: 0 auto;
    padding: 2rem 1rem;
}

.page-wide {
    max-width: 56rem;
}

.page-settings {
    max-width: 48rem;
}

.page-form {
    max-width: 42rem;
}

.page-narrow {
    max-width: 36rem;
}

@media (min-width: 640px) {
    .page {
        padding: 3rem 2rem;
    }
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}

.page-head-end {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Toasts */

.toasts {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(356px, calc(100% - 2rem));
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--background);
    color: var(--foreground);
    font-size: 0.8125rem;
    line-height: 1.5;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-in 0.3s ease-out;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.leaving {
    opacity: 0;
    transform: translateY(0.5rem);
}

.toast-icon {
    margin-top: 0.125rem;
    color: var(--success);
}

.toast.failed .toast-icon {
    color: var(--destructive);
}

.toast-title {
    font-weight: 500;
}

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

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }
}

/* Dialogs */

.dialog {
    width: 100%;
    max-width: 32rem;
    max-height: 100%;
    margin: auto;
    padding: 1.5rem;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--foreground);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
}

.dialog[open] {
    display: grid;
    gap: 1rem;
}

.dialog.scrolls {
    max-height: 90vh;
}

/* site.js gives the focus to the dialog itself when it opens. */
.dialog:focus-visible {
    outline: none;
}

.dialog::backdrop {
    background: rgb(0 0 0 / 0.8);
}

@media (min-width: 640px) {
    .dialog {
        border-radius: 0.5rem;
    }
}

.dialog-x {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.dialog-x button {
    display: grid;
    border-radius: 0.125rem;
    opacity: 0.7;
}

.dialog-x button:hover {
    opacity: 1;
}

.dialog-head {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    text-align: center;
}

.dialog-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.025em;
}

.dialog-text {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.dialog-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.dialog-buttons {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
}

.dialog-buttons .button {
    width: 100%;
}

@media (min-width: 640px) {
    .dialog-head {
        text-align: left;
    }

    .dialog-buttons {
        flex-direction: row;
        justify-content: flex-end;
    }

    .dialog-buttons .button {
        width: auto;
    }
}

.publication-box,
.test-box,
.schedule-box {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.publication-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.send-title {
    font-family: var(--font-serif);
    font-size: 1.125rem;
    line-height: 1.375;
}

.test-box .inline-field,
.schedule-box .inline-field {
    margin-top: 0.5rem;
}

.schedule-box > .hint:last-child {
    margin-top: 0.5rem;
}

.intent {
    padding: 0.75rem;
    border: 1px solid color-mix(in oklab, var(--primary) 30%, transparent);
    border-radius: 0.5rem;
    background: var(--accent);
    color: var(--accent-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* The progress of a long action, in place of the page (site.js). */

.working > :not(.progress) {
    display: none !important;
}

.progress {
    padding: 4rem 1rem;
}

.onboarding .progress {
    padding: 0;
}

.progress-card {
    max-width: 32rem;
    margin: 0 auto;
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--card);
    box-shadow: var(--shadow-paper);
}

.progress-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    line-height: 2rem;
}

.progress-hint {
    margin-top: 0.25rem;
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.progress-stages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
    counter-reset: stage;
}

.progress-stages li {
    display: flex;
    gap: 0.75rem;
    counter-increment: stage;
}

.stage-mark {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    margin-top: 0.125rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

.stage-number::before {
    content: counter(stage);
}

.stage-running,
.stage-done,
.stage-failed,
.active .stage-number,
.done .stage-number,
.failed .stage-number {
    display: none;
}

.active .stage-mark {
    border-color: var(--primary);
    color: var(--primary);
}

.active .stage-running,
.done .stage-done,
.failed .stage-failed {
    display: block;
}

.done .stage-mark {
    border-color: var(--success);
    background: var(--success);
    color: var(--primary-foreground);
}

.failed .stage-mark {
    border-color: var(--destructive);
    background: var(--destructive);
    color: var(--primary-foreground);
}

.stage-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.stage-title {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
}

:is(.active, .done, .failed) .stage-title {
    color: var(--foreground);
}

.stage-detail {
    overflow: hidden;
    color: var(--muted-foreground);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stage-detail:empty {
    display: none;
}

.progress .error {
    margin-top: 1.5rem;
}

.progress-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 2rem;
}

@media (prefers-reduced-motion: reduce) {
    .spin {
        animation-duration: 3s;
    }
}

/* Sign-in */

.login {
    display: grid;
    min-height: 100vh;
}

.login-main {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.login-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 24rem;
    margin: 0 auto;
    padding: 3rem 0;
}

.login-body .lead {
    margin-top: 0.75rem;
}

.login-body .title.medium.below {
    margin-top: 1rem;
}

.google {
    margin-top: 2rem;
}

.or {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

.or span {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.link-form {
    display: flex;
    flex-direction: column;
}

.link-form.alone {
    margin-top: 2rem;
}

.link-form input {
    margin-top: 0.375rem;
}

.link-form .error {
    margin-top: 0.375rem;
}

.link-form .button {
    margin-top: 0.75rem;
}

.login-aside {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: var(--ink);
    color: var(--paper);
}

.login-aside figure {
    max-width: 28rem;
}

.login-aside blockquote {
    font-family: var(--font-serif);
    font-size: 1.875rem;
    font-style: italic;
    line-height: 1.375;
}

.login-aside figcaption {
    margin-top: 1.5rem;
    color: color-mix(in oklab, var(--paper) 60%, transparent);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.login-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid color-mix(in oklab, var(--paper) 15%, transparent);
}

.login-steps dt {
    font-family: var(--font-serif);
    font-size: 1.125rem;
    line-height: 1.75rem;
}

.login-steps dd {
    color: color-mix(in oklab, var(--paper) 60%, transparent);
    font-size: 0.75rem;
    line-height: 1rem;
}

@media (min-width: 640px) {
    .login-main {
        padding: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .login {
        grid-template-columns: 1fr 1fr;
    }

    .login-aside {
        display: flex;
    }
}

/* Setting up: the publication, then the style. */

.onboarding-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
}

.stepper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

.stepper li {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.stepper li.done,
.stepper li.current {
    color: var(--foreground);
}

.step-number {
    display: grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-family: var(--font-mono);
}

.current .step-number {
    border-color: var(--foreground);
}

.done .step-number {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--primary-foreground);
}

.step-line {
    width: 1.5rem;
    height: 1px;
    margin: 0 0.25rem;
    background: var(--border);
}

.onboarding {
    display: block;
    max-width: 36rem;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

@media (min-width: 640px) {
    .onboarding-head {
        padding: 1.25rem 2.5rem;
    }
}

.find {
    display: flex;
    gap: 0.5rem;
    margin-top: 2rem;
}

.find .button {
    flex-shrink: 0;
}

.found {
    margin-top: 1.5rem;
    padding: 1.25rem;
}

.found-publication {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.found-name {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    line-height: 1.75rem;
}

.found-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.style-form {
    display: flex;
    flex-direction: column;
}

.choices {
    display: grid;
    gap: 0.75rem;
    margin-top: 2rem;
}

.choice {
    position: relative;
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--card);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.choice > .icon {
    margin-top: 0.125rem;
}

.choice:hover {
    border-color: color-mix(in oklab, var(--foreground) 30%, transparent);
}

.choice:has(:checked) {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary) 20%, transparent);
}

.choice:has(:focus-visible),
.preset:has(:focus-visible),
.format:has(:focus-visible),
.browsers label:has(:focus-visible) {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

.choice-title,
.preset-name,
.format-name {
    display: block;
    font-weight: 500;
}

.choice-text {
    display: block;
    margin-top: 0.125rem;
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.when-text,
.when-preset,
.when-posts,
.when-copy {
    display: none;
}

.style-form:has([name="Source"][value="posts"]:checked) .when-posts,
.style-form:has([name="Source"][value="text"]:checked) .when-text,
.style-form:has([name="Source"][value="preset"]:checked) .when-preset,
.style-form:has([name="Source"][value="copy"]:checked) .when-copy {
    display: flex;
}

.style-form:has([name="Source"][value="preset"]:checked) .presets.when-preset,
.style-form:has([name="Source"][value="copy"]:checked) .presets.when-copy {
    display: grid;
}

/* A browser that cannot pick the shown parts by the radio buttons shows them all. */
@supports not selector(:has(*)) {
    .when-text,
    .when-preset,
    .when-posts,
    .when-copy {
        display: block;
    }
}

.style-form .when-text textarea {
    margin-top: 1rem;
}

.style-form .error {
    margin-top: 1rem;
}

.style-form > .button {
    margin-top: 1.5rem;
}

.presets {
    gap: 0.5rem;
    margin-top: 1rem;
}

.preset {
    position: relative;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--card);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.preset:has(:checked) {
    border-color: var(--primary);
    background: var(--accent);
}

.preset-text {
    display: block;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

@media (min-width: 640px) {
    .presets {
        grid-template-columns: 1fr 1fr;
    }
}

/* Issues */

.checked {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

.checked.failed {
    color: var(--warning);
}

.checked + .checked {
    margin-top: 0.25rem;
}

.issues {
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--card);
    box-shadow: var(--shadow-paper);
}

.issue-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
}

.issue-row + .issue-row {
    border-top: 1px solid var(--border);
}

.issue-link {
    flex: 1;
    min-width: 0;
}

.issue-title {
    display: block;
    font-family: var(--font-serif);
    font-size: 1.25rem;
    line-height: 1.375;
    overflow-wrap: anywhere;
    transition: color 0.15s;
}

.issue-row:hover .issue-title {
    color: var(--primary);
}

.meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    margin-top: 0.375rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

.issue-actions {
    display: flex;
    gap: 0.25rem;
}

@media (min-width: 640px) {
    .issue-row {
        flex-direction: row;
        align-items: center;
    }

    .copy-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .from-label,
    .mark-label {
        display: none;
    }
}

@media (min-width: 1024px) {
    .from-label,
    .mark-label {
        display: inline;
    }
}

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 36rem;
    min-height: 80vh;
    margin: 0 auto;
    padding: 0 1.5rem;
    text-align: center;
}

.empty .lead {
    margin-top: 0.75rem;
}

.empty .button {
    margin-top: 2rem;
}

.empty-paper {
    width: 7rem;
    height: 9rem;
    margin-bottom: 2rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    background: var(--paper);
    box-shadow: var(--shadow-paper);
    transform: rotate(-4deg);
}

.empty-heading {
    display: block;
    width: 75%;
    height: 0.5rem;
    border-radius: 0.25rem;
    background: color-mix(in oklab, var(--ink) 80%, transparent);
}

.empty-lines {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 0.75rem;
}

.empty-lines span {
    height: 0.25rem;
    border-radius: 0.25rem;
    background: color-mix(in oklab, var(--muted-foreground) 25%, transparent);
}

.empty-lines span:nth-child(2) { width: 90%; }
.empty-lines span:nth-child(3) { width: 95%; }
.empty-lines span:nth-child(4) { width: 70%; }
.empty-lines span:nth-child(5) { width: 85%; }
.empty-lines span:nth-child(6) { width: 60%; }

/* A new issue */

.prefilled {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    background: var(--accent);
    color: var(--accent-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.prefilled-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 1rem;
}

.prefilled .text-link {
    color: inherit;
}

.blank-issue {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
    margin-top: 0.5rem;
}

.templates {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem 0.5rem;
    margin-top: 0.5rem;
}

.templates .chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.templates .chip:hover {
    border-color: color-mix(in oklab, var(--foreground) 30%, transparent);
}

.templates .chip[aria-current="true"] {
    border-color: var(--primary);
    background: var(--accent);
}

.new-issue {
    display: flex;
    flex-direction: column;
}

.topic {
    position: relative;
    margin-top: 1.5rem;
}

.topic textarea {
    min-height: 7rem;
    padding: 1rem;
    font-family: var(--font-serif);
    font-size: 1.25rem;
    line-height: 1.375;
    resize: none;
    box-shadow: var(--shadow-paper);
}

.topic-count {
    position: absolute;
    right: 0.75rem;
    bottom: 0.5rem;
    color: var(--muted-foreground);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1rem;
}

.new-issue > .error {
    margin-top: 0.5rem;
}

.formats {
    display: grid;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.format {
    position: relative;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--card);
    transition: border-color 0.15s;
}

.format:hover {
    border-color: color-mix(in oklab, var(--foreground) 30%, transparent);
}

.format:has(:checked) {
    border-color: var(--primary);
    background: var(--accent);
}

.format-name {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.format-text {
    display: block;
    margin-top: 0.125rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1.375;
}

@media (min-width: 640px) {
    .formats {
        grid-template-columns: repeat(4, 1fr);
    }
}

.new-issue .segmented {
    margin-top: 0.75rem;
}

.more {
    margin-top: 1.5rem;
}

.more summary {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    width: fit-content;
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
    list-style: none;
    cursor: pointer;
}

.more summary::-webkit-details-marker {
    display: none;
}

.more summary:hover {
    color: var(--foreground);
}

.more summary .icon {
    transition: transform 0.15s;
}

.more[open] summary .icon {
    transform: rotate(180deg);
}

.more-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1rem;
}

.more-body textarea {
    min-height: 8rem;
    margin-top: 0.5rem;
}

.source-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.source-list:empty {
    display: none;
}

.source {
    display: flex;
    gap: 0.5rem;
}

.source-field {
    position: relative;
    flex: 1;
}

.source-field .icon {
    position: absolute;
    top: 50%;
    left: 0.75rem;
    color: var(--muted-foreground);
    transform: translateY(-50%);
}

.source-field input {
    padding-left: 2.25rem;
}

.sources .error,
.sources > .button {
    margin-top: 0.5rem;
}

.small-error {
    font-size: 0.75rem;
    line-height: 1rem;
}

.submit-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

@media (min-width: 640px) {
    .submit-bar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* Write the issue is the form's first button, and the last one seen. */
.submit-buttons {
    display: flex;
    flex-direction: row-reverse;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.template-list {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--card);
}

.template-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.25rem 0.25rem 0.25rem 1rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.template-list li + li {
    border-top: 1px solid var(--border);
}

/* Publication & style */

.welcome {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border-radius: 0.75rem;
    background: var(--ink);
    color: var(--paper);
}

.welcome-eyebrow {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: color-mix(in oklab, var(--paper) 70%, transparent);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.welcome-quote {
    margin-top: 0.5rem;
    font-family: var(--font-serif);
    font-size: 1.5rem;
    line-height: 1.375;
}

.welcome-note {
    margin-top: 0.75rem;
    color: color-mix(in oklab, var(--paper) 70%, transparent);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.section {
    display: grid;
    gap: 1rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border);
}

.section-head h2 {
    font-weight: 500;
}

.section-head .hint {
    margin-top: 0.25rem;
}

.section-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

@media (min-width: 768px) {
    .section {
        grid-template-columns: 200px 1fr;
    }
}

.pub-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pub-row-name {
    font-family: var(--font-serif);
    font-size: 1.125rem;
    line-height: 1.75rem;
}

.two-columns {
    display: grid;
    gap: 1rem;
}

@media (min-width: 640px) {
    .two-columns {
        grid-template-columns: 1fr 1fr;
    }
}

.excerpts {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.excerpt-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.excerpt-list:empty {
    display: none;
}

.excerpt {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--paper);
}

.excerpt textarea {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font-family: var(--font-serif);
    box-shadow: none;
    resize: none;
}

.excerpt textarea:focus-visible {
    box-shadow: none;
}

/* One line tall like an input until the text needs more (site.js). */
textarea[data-grow] {
    min-height: 2.25rem;
    padding-top: 0.4375rem;
    padding-bottom: 0.4375rem;
    overflow: hidden;
    resize: none;
}

.section-body > .button {
    align-self: flex-start;
}

.sticky-save {
    position: sticky;
    bottom: 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Where an imported post came from, on its row in Posts. */
.feed-mark {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* A parameter of an API feed (Feeds/Edit): name, value and the remove button on one line. */
.feed-param {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
}

/* Substack connection */

.connect-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
}

.connect-card,
.connected {
    padding: 1.5rem;
}

.connected {
    margin-top: 2rem;
}

.connected-as {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.connected .muted {
    margin-top: 0.5rem;
}

.connected .button {
    margin-top: 1.25rem;
}

.disclosure {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: color-mix(in oklab, var(--muted) 50%, transparent);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.disclosure-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.disclosure ul {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 0.5rem;
    color: var(--muted-foreground);
}

.disclosure li::before {
    content: "• ";
}

.connect-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.connect-way {
    display: none;
    flex-direction: column;
}

.connect-way[data-way="code"] {
    gap: 0.75rem;
}

.connect-way[data-way="key"] {
    gap: 1.25rem;
}

.connect-form:has([name="connect-way"][value="code"]:checked) [data-way="code"],
.connect-form:has([name="connect-way"][value="key"]:checked) [data-way="key"] {
    display: flex;
}

.phone-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 0.75rem;
    line-height: 1rem;
}

@media (min-width: 768px) {
    .phone-note {
        display: none;
    }
}

.browsers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.browsers label {
    position: relative;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 0.75rem;
    line-height: 1rem;
}

.browsers label:hover {
    background: var(--muted);
}

.browsers label:has(:checked) {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--primary-foreground);
}

[data-browser] {
    display: none;
}

.connect-form:has([value="chrome"]:checked) [data-browser~="chrome"],
.connect-form:has([value="edge"]:checked) [data-browser~="edge"],
.connect-form:has([value="firefox"]:checked) [data-browser~="firefox"],
.connect-form:has([value="safari"]:checked) [data-browser~="safari"] {
    display: inline;
}

@supports not selector(:has(*)) {
    .connect-way {
        display: flex;
    }

    [data-browser] {
        display: inline;
    }
}

.key-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    counter-reset: key-step;
}

.key-steps li {
    position: relative;
    padding: 0.125rem 0 0 2.25rem;
    counter-increment: key-step;
}

.key-steps li::before {
    content: counter(key-step);
    position: absolute;
    top: 0;
    left: 0;
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background: var(--secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.key-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.key-form .button {
    margin-top: 0.75rem;
}

.warn-line {
    display: flex;
    align-items: flex-start;
    gap: 0.375rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

.warn-line .icon {
    margin-top: 0.125rem;
    color: var(--warning);
}

/* An issue: the editor and the panel. */

.editor-main {
    min-width: 0;
}

.toolbar {
    position: sticky;
    top: 53px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: color-mix(in oklab, var(--background) 95%, transparent);
    backdrop-filter: blur(8px);
    overflow-x: auto;
}

.toolbar-line {
    flex-shrink: 0;
    width: 1px;
    height: 1.25rem;
    margin: 0 0.25rem;
    background: var(--border);
}

.tool {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.25rem;
}

.tool:hover,
.tool[aria-pressed="true"] {
    background: var(--muted);
}

.toolbar-end {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding-left: 0.5rem;
}

/* On a phone the formatting buttons scroll under Save and Substack, which stay in reach. */
@media (max-width: 639.98px) {
    .toolbar-end {
        position: sticky;
        right: 0;
        background: var(--background);
        /* Covers the toolbar's right padding too, where the buttons scrolled under would show. */
        box-shadow: 0.75rem 0 0 var(--background), -8px 0 8px -4px var(--background);
    }
}

.save-state {
    display: none;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

@media (min-width: 640px) {
    .save-state {
        display: inline;
    }
}

@media (min-width: 768px) {
    .toolbar {
        top: 0;
    }
}

.article {
    max-width: 680px;
    margin: 0 auto;
    padding: 2.5rem 1.25rem;
}

@media (min-width: 640px) {
    .article {
        padding: 3.5rem 1.25rem;
    }
}

/* Over the general field rules: the title and subtitle look like a post's, and grow with their text (editor.js). */
.article .post-title,
.article .post-subtitle {
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    resize: none;
    overflow: hidden;
    field-sizing: content;
}

.article .post-title:focus-visible,
.article .post-subtitle:focus-visible {
    box-shadow: none;
}

.article .post-title {
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 2.4rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.025em;
}

.article .post-subtitle {
    color: var(--muted-foreground);
    font-family: var(--font-serif);
    font-size: 1.25rem;
    line-height: 1.375;
}

.title-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin: 0.25rem 0 1rem;
}

.title-options-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

.title-option {
    padding: 0.125rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: var(--card);
    font-size: 0.75rem;
    line-height: 1rem;
    text-align: left;
}

.title-option:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.byline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.byline-name {
    font-weight: 500;
}

.byline-publication {
    color: var(--muted-foreground);
    font-size: 0.75rem;
    line-height: 1rem;
}

/* The issue's body as Substack shows a post. */
.prose {
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.1875rem;
    line-height: 1.65;
    overflow-wrap: break-word;
}

.prose .ProseMirror {
    min-height: 240px;
    outline: none;
}

/* An empty editor, as a blank issue opens, says what goes there. Outside the editable element, so the cursor ignores it. */
.prose[data-placeholder] {
    position: relative;
}

.prose[data-placeholder]:has(> .ProseMirror > p:only-child > br.ProseMirror-trailingBreak:only-child)::before {
    position: absolute;
    top: 0;
    left: 0;
    color: var(--muted-foreground);
    content: attr(data-placeholder);
    pointer-events: none;
}

.prose h2 {
    margin: 2rem 0 0.75rem;
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.25;
}

.prose h3 {
    margin: 1.5rem 0 0.5rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.prose p {
    margin: 0 0 1.1rem;
}

.prose strong {
    font-weight: 600;
}

.prose a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.prose ul {
    margin-bottom: 1.1rem;
    padding-left: 1.4rem;
    list-style: disc;
}

.prose ol {
    margin-bottom: 1.1rem;
    padding-left: 1.4rem;
    list-style: decimal;
}

.prose li p {
    margin-bottom: 0.4rem;
}

.prose blockquote {
    margin: 1.4rem 0;
    padding-left: 1.1rem;
    border-left: 3px solid var(--ink);
    font-style: italic;
}

.prose hr {
    width: 40%;
    margin: 2rem auto;
    border-top: 1px solid var(--border);
}

.prose img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.75rem auto;
    border-radius: 0.25rem;
}

/* The editor marks the picture the cursor is on. */
.prose img.ProseMirror-selectednode {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* A sheet from the bottom while open on a narrow screen (popover), a column from 1024 px. */
.panel:popover-open {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 85vh;
    margin: 0;
    padding: 1.5rem;
    border: 0;
    border-top: 1px solid var(--border);
    background: var(--background);
    color: var(--foreground);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
}

.panel::backdrop {
    background: rgb(0 0 0 / 0.8);
}

.sheet-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    border-radius: 0.125rem;
    opacity: 0.7;
}

.sheet-close:hover {
    opacity: 1;
}

.panel-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.25rem;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.panel-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--card);
}

.panel-card.tight {
    gap: 0.5rem;
}

.panel-card-title {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
}

.stale {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 0.75rem;
    line-height: 1rem;
}

.stale-title {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-weight: 500;
}

.stale p + p {
    margin-top: 0.25rem;
}

.stale .button {
    margin-top: 0.5rem;
}

.dialog-body .stale {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.dialog-body .stale-title {
    gap: 0.5rem;
}

.copy-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.copy-fields {
    display: flex;
    gap: 0.5rem;
}

.copy-fields .button {
    flex: 1;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.chip {
    padding: 0.125rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 0.75rem;
    line-height: 1rem;
}

.chip[aria-pressed="true"] {
    border-color: var(--primary);
    background: var(--accent);
}

.activity-title {
    margin-bottom: 0.5rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.activity ol {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border);
}

.activity li {
    position: relative;
    font-size: 0.75rem;
    line-height: 1rem;
}

.activity li > .icon {
    position: absolute;
    top: 0.125rem;
    left: -21px;
    background: var(--sidebar);
}

.activity-action {
    font-weight: 500;
}

.activity .hint {
    overflow-wrap: anywhere;
}

.panel-button {
    flex-shrink: 0;
}

@media (min-width: 1024px) {
    .editor-page {
        display: grid;
        grid-template-columns: 1fr 340px;
    }

    .panel,
    .panel:popover-open {
        position: static;
        display: block;
        width: auto;
        height: auto;
        max-height: none;
        margin: 0;
        padding: 0;
        border: 0;
        border-left: 1px solid var(--border);
        background: color-mix(in oklab, var(--sidebar) 60%, transparent);
        color: var(--foreground);
        box-shadow: none;
        overflow: visible;
    }

    .panel-body {
        position: sticky;
        top: 0;
        max-height: 100vh;
        overflow-y: auto;
    }

    .sheet-close,
    .panel-button {
        display: none;
    }
}

/* Rewrite the selection: over the selected text (editor.js). */
.fragment {
    position: fixed;
    z-index: 50;
    display: flex;
    align-items: center;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--card);
    box-shadow: var(--shadow-paper);
    transform: translate(-50%, -100%);
}

.fragment-options {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.fragment-options > .icon {
    margin-left: 0.5rem;
}

.fragment-options button {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    line-height: 1rem;
    white-space: nowrap;
}

.fragment-options button:hover {
    background: var(--muted);
}

.fragment .fragment-options input {
    width: 7rem;
    height: auto;
    padding: 0.25rem 0.5rem;
    border: 0;
    border-radius: 0.25rem;
    background: var(--muted);
    font-size: 0.75rem;
    line-height: 1rem;
    box-shadow: none;
}

.fragment-busy {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    line-height: 1rem;
}

/* Errors */

.center-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 0 1rem;
}

.center-box {
    max-width: 28rem;
    text-align: center;
}

.center-box .muted {
    margin-top: 0.5rem;
}

.not-found {
    font-family: var(--font-serif);
    font-size: 4.5rem;
    font-style: italic;
    line-height: 1;
}

.center-title {
    margin-top: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.75rem;
}

.center-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* Substack growth (Pages/Growth): the tabs, the keywords and the publications with their people. */

.tabs {
    display: inline-flex;
    padding: 0.25rem;
    border-radius: 0.5rem;
    background: var(--muted);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.tabs a {
    padding: 0.375rem 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    color: var(--muted-foreground);
}

.tabs a[aria-current="page"] {
    background: var(--card);
    color: var(--foreground);
    box-shadow: var(--shadow-sm);
}

.keywords {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--card);
}

/* A worker on Growth/Workers, after the dot that says whether it runs. */
.worker-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.keyword-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.75rem 1rem;
}

.keyword-row + .keyword-row {
    border-top: 1px solid var(--border);
}

.keyword-text {
    flex: 1;
    min-width: 12rem;
}

.keyword-text .meta {
    margin-top: 0.125rem;
}

.keyword-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.growth-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.check-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    cursor: pointer;
}

.check-chip:has(:checked) {
    border-color: var(--primary);
    background: var(--accent);
}

.check-line {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    cursor: pointer;
}

.growth-results {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.growth-results-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.growth-results-head h2 {
    font-weight: 500;
}

.growth-results-head .hint {
    margin-left: 0.5rem;
}

.growth-list {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--card);
    box-shadow: var(--shadow-paper);
}

.growth-row {
    padding: 1.25rem;
    scroll-margin-top: 1rem;
}

.growth-row + .growth-row {
    border-top: 1px solid var(--border);
}

/* The end of a list that comes a page at a time: it loads the next rows when it scrolls into view. */
.growth-more {
    display: flex;
    justify-content: center;
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.growth-pub {
    display: flex;
    gap: 0.875rem;
}

.growth-pub-text {
    flex: 1;
    min-width: 0;
}

.growth-pub-name {
    font-family: var(--font-serif);
    font-size: 1.125rem;
    line-height: 1.5rem;
    overflow-wrap: anywhere;
    transition: color 0.15s;
}

.growth-pub-name:hover {
    color: var(--primary);
}

.growth-pub-description,
.person-bio {
    display: -webkit-box;
    margin-top: 0.25rem;
    overflow: hidden;
    color: var(--muted-foreground);
    font-size: 0.875rem;
    line-height: 1.25rem;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.growth-pub-keywords {
    margin-top: 0.5rem;
}

/* Under the publication's name, past its 40px logo. */
.growth-people-line,
.people {
    margin: 0.75rem 0 0 calc(40px + 0.875rem);
}

.growth-people-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* An icon before its text on the same line: icons are blocks. */
.growth-pub .meta > span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.people {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.person {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem 0.75rem;
}

.person .avatar {
    border-radius: 9999px;
}

.person-text {
    flex: 1;
    min-width: 12rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.person-text > p:first-child {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
}

.person-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.person-mark {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Zero width and as wide as the button: the line hangs under it, runs out to the left and does not widen the row. */
.person-mark-note {
    display: flex;
    justify-content: flex-end;
    width: 0;
    min-width: 100%;
    color: var(--muted-foreground);
    font-size: 0.6875rem;
    line-height: 1rem;
    white-space: nowrap;
}

@media (max-width: 639.98px) {
    .growth-people-line,
    .people {
        margin-left: 0;
    }

    /* The actions wrap under the text here, so the note starts at the button's left edge and wraps. */
    .person-mark-note {
        justify-content: flex-start;
        width: auto;
        min-width: 0;
        white-space: normal;
    }
}

/* The form on Growth/Likes: a row per post, then the period for all of them. */
.like-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.like-rows {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.like-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.75rem;
}

.like-url {
    flex: 1;
    min-width: 14rem;
}

.like-count {
    width: 5rem;
}

.like-period {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.75rem;
}

.like-period input[type="number"] {
    width: 6rem;
}
