/* Readings, archives and account pages share the site's surfaces. The selectors
   start from template-owned wrappers so a post can keep its own artwork and controls. */
body.jelly-site {
  --content-surface: linear-gradient(157deg, var(--paper) 30%, color-mix(in srgb, var(--paper), var(--soft) 64%));
  --content-rim: color-mix(in srgb, var(--paper) 55%, white);
  --content-control: color-mix(in srgb, var(--paper) 83%, var(--soft));
  --content-control-edge: color-mix(in srgb, var(--line) 72%, var(--muted));
  --content-primary: linear-gradient(170deg, #8053be, #674199 55%, #523183);
  --content-primary-hover: linear-gradient(170deg, #7545b7, #5d368f 55%, #4d2b7b);
  --content-primary-edge: #57317f;
  --content-primary-ink: #fff9ff;
  --content-error-ink: #79283f;
  --content-error-bg: #ffedf2;
  --content-error-line: #bc6a82;
  --content-warning-ink: #724410;
  --content-warning-bg: #fff3d8;
  --content-warning-line: #c39351;
  --content-ok-ink: #245647;
  --content-ok-bg: #eafbf3;
  --content-ok-line: #6fa898;
}

html[data-theme="dark"] body.jelly-site {
  --content-rim: color-mix(in srgb, var(--paper) 84%, white);
  --content-control: color-mix(in srgb, var(--paper) 80%, black);
  --content-primary-edge: #a579d4;
  --content-error-ink: #ffc1d0;
  --content-error-bg: #482637;
  --content-error-line: #bd7191;
  --content-warning-ink: #ffdcad;
  --content-warning-bg: #442c25;
  --content-warning-line: #b28757;
  --content-ok-ink: #bcebd7;
  --content-ok-bg: #213c38;
  --content-ok-line: #669e92;
}

/* Existing reading defaults use --site-* and --reading-*. Bridge the variables
   locally so old post content, including the download section, follows day/night. */
body.jelly-site .reading-wrap {
  --site-text: var(--text);
  --site-muted: var(--muted);
  --site-line: var(--line);
  --site-panel: var(--paper);
  --site-paper: var(--page);
  --site-link: var(--accent);
}

html[data-theme="dark"] body.jelly-site .reading-wrap {
  --reading-raised: var(--soft);
  --reading-field: var(--content-control);
  --reading-rule: var(--content-control-edge);
  --reading-warm: var(--content-warning-ink);
  --reading-alert-bg: var(--content-error-bg);
  --reading-alert-ink: var(--content-error-ink);
}

body.jelly-site :is(.reading-wrap, .listing, .account-page) {
  color: var(--text);
}

body.jelly-site :is(.reading-wrap > .ink-entry, .reading-wrap > .ink-comments, .listing > .list-title, .account-page > .account-panel) {
  background: var(--content-surface);
  border: 1px solid var(--line);
  border-radius: clamp(19px, 2.5vw, 30px);
  box-shadow: var(--shell-shadow);
}

/* Reading paper stays quiet below the header, including long blocks of text. */
body.jelly-site .reading-wrap > .ink-entry {
  background: linear-gradient(var(--soft), var(--paper) 220px, var(--paper));
}

body.jelly-site :is(.listing > .list-title, .account-page > .account-panel) {
  padding: clamp(16px, 3.5vw, 30px);
}

body.jelly-site :is(.reading-wrap .entry-header h1, .listing .list-title h1, .account-page .account-panel h1) {
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: var(--heading-size);
  font-weight: 800;
  line-height: 1.26;
  letter-spacing: 0;
  text-wrap: pretty;
}

body.jelly-site :is(.reading-wrap, .listing) > .breadcrumbs {
  color: var(--muted);
}

body.jelly-site :is(.reading-wrap > .breadcrumbs, .listing > .breadcrumbs) a {
  color: var(--accent);
}

body.jelly-site .reading-wrap .entry-header {
  border-color: var(--line);
}

body.jelly-site .reading-wrap > .entry-preview {
  border-color: var(--content-warning-line);
  border-radius: 13px;
  background: var(--content-warning-bg);
  color: var(--content-warning-ink);
}

/* Apply pill styling to the template's navigation, outside the authored body. */
body.jelly-site :is(.reading-wrap .entry-header .term-links, .reading-wrap .entry-tags, .listing .term-links) a,
body.jelly-site :is(.reading-wrap > .entry-neighbours, .listing > .listing-pagination) a {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--content-surface);
  color: var(--accent);
  box-shadow: inset 0 1px var(--content-rim);
  text-decoration: none;
}

body.jelly-site :is(.reading-wrap .entry-header .term-links, .reading-wrap .entry-tags, .listing .term-links) a {
  min-height: 32px;
  align-items: center;
  padding-inline: 12px;
}

body.jelly-site .reading-wrap > .entry-neighbours a {
  border-radius: 15px;
}

body.jelly-site :is(.reading-wrap .entry-header .term-links, .reading-wrap .entry-tags, .listing .term-links,
  .reading-wrap > .entry-neighbours, .listing > .listing-pagination) a:hover {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--accent);
}

body.jelly-site :is(.listing-pagination, .listing .empty-note, .reading-wrap .empty-note,
  .entry-byline, .entry-neighbours small, .ink-comments .comment-count, .ink-comments time) {
  color: var(--muted);
}

/* List cards retain their cover ratio and responsive layout. The edge clips
   only the image/card contents so the outline can sit outside the link. */
body.jelly-site .listing > .article-grid > .article {
  overflow: hidden;
  border-color: var(--line);
  border-radius: 19px;
  background: var(--content-surface);
  color: var(--text);
  box-shadow: var(--shell-shadow);
}

body.jelly-site .listing > .article-grid > .article:hover {
  border-color: var(--accent);
  box-shadow: var(--shell-shadow);
}

body.jelly-site .listing .article-info h3 {
  font-family: inherit;
  overflow-wrap: anywhere;
}

body.jelly-site .listing .article-info p { color: var(--muted); }
body.jelly-site .listing .article-info :is(small, span) { color: var(--accent); }

body.jelly-site .listing .article-image-empty {
  background:
    radial-gradient(ellipse at 24% 18%, var(--content-rim), transparent 67%),
    linear-gradient(149deg, var(--soft), color-mix(in srgb, var(--soft) 80%, var(--accent)));
}

body.jelly-site :is(.listing, .reading-wrap) .empty-note {
  grid-column: 1 / -1;
  margin-block: 0;
  padding: 13px 15px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--paper);
  overflow-wrap: anywhere;
}

body.jelly-site .reading-wrap .ink-comments .section-title {
  border-color: var(--line);
}

body.jelly-site .reading-wrap .ink-comments .section-title h2 {
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  font-family: inherit;
  font-size: clamp(17px, 2vw, 21px);
  clip-path: none;
}

body.jelly-site .reading-wrap .ink-comments :is(.comment-item, .comment-replies) {
  border-color: var(--line);
}

body.jelly-site .reading-wrap .ink-comments .comment-controls {
  color: var(--accent);
}

/* Account and CMS form colors use the same material. Scope controls independently
   from the page form type so replies, report fields and native validation still work. */
body.jelly-site :is(.account-page .site-form, .listing .list-search, .reading-wrap .ink-comments .site-form)
  :is(input:not([type="hidden"], [type="checkbox"], [type="radio"]), select, textarea) {
  min-height: 44px;
  border-color: var(--content-control-edge);
  border-radius: 12px;
  background: var(--content-control);
  color: var(--text);
  box-shadow: inset 0 1px 3px color-mix(in srgb, var(--line) 45%, transparent);
}

body.jelly-site :is(.account-page .site-form, .listing .list-search, .reading-wrap .ink-comments .site-form)
  :is(input, textarea)::placeholder {
  color: var(--muted);
  opacity: 1;
}

body.jelly-site :is(.account-page, .reading-wrap .ink-comments) .site-form textarea { min-height: 85px; }

body.jelly-site :is(.account-page .site-form, .reading-wrap .ink-comments .site-form) [aria-invalid="true"] {
  border-color: var(--content-error-line);
}

body.jelly-site :is(.account-page .site-form, .reading-wrap .ink-comments .site-form) .errorlist {
  border-color: var(--content-error-line);
  border-radius: 9px;
  background: var(--content-error-bg);
  color: var(--content-error-ink);
}

body.jelly-site :is(.account-page, .listing, .reading-wrap) :is(.site-form .site-button, .entry-actions .site-button,
  .account-profile-actions .site-button, .account-panel > .form-actions .site-button) {
  min-height: 44px;
  border-color: var(--content-primary-edge);
  border-radius: 13px;
  background: var(--content-primary);
  color: var(--content-primary-ink);
  box-shadow: inset 0 1px #ffffff54, inset 0 -2px #3a1e6333;
  text-decoration: none;
  white-space: normal;
  text-align: center;
}

body.jelly-site :is(.account-page, .listing, .reading-wrap) :is(.site-form .site-button, .entry-actions .site-button,
  .account-profile-actions .site-button, .account-panel > .form-actions .site-button):hover {
  background: var(--content-primary-hover);
}

body.jelly-site :is(.account-page, .listing, .reading-wrap) :is(.site-form, .entry-actions, .account-profile-actions,
  .account-panel > .form-actions) .site-button-secondary {
  border-color: var(--line);
  background: var(--content-surface);
  color: var(--accent);
  box-shadow: inset 0 1px var(--content-rim);
}

body.jelly-site :is(.account-page, .listing, .reading-wrap) :is(.site-form, .entry-actions, .account-profile-actions,
  .account-panel > .form-actions) .site-button-secondary:hover {
  border-color: var(--accent);
  background: var(--soft);
}

body.jelly-site :is(.account-page, .listing, .reading-wrap .ink-comments, .reading-wrap .entry-actions) :focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

body.jelly-site .listing .list-search .site-button { flex: none; }

body.jelly-site .account-panel :is(.account-description, .helptext, dt, .account-steps, .account-membership-status) {
  color: var(--muted);
}

body.jelly-site .account-panel :is(dd, .account-profile-section) { color: var(--text); }
body.jelly-site .account-panel a:not(.site-button) { color: var(--accent); }

body.jelly-site .account-panel .account-profile-summary {
  border-color: var(--line);
  border-radius: 15px;
  background: var(--soft);
}

body.jelly-site .account-panel :is(.account-profile-details > div, .account-steps li) { border-color: var(--line); }
body.jelly-site .account-panel .account-steps [aria-current="step"] { border-color: var(--accent); color: var(--accent); }
body.jelly-site .account-panel .account-membership-status.is-current { color: var(--content-ok-ink); }
body.jelly-site .account-panel .account-membership-status.is-expired { color: var(--content-error-ink); }

/* Keep feedback timing and dialog geometry in their owning components. These
   rules style the visible surfaces without adding alternate alerts or controls. */
body.jelly-site .site-messages li {
  border-color: var(--line);
  border-radius: 13px;
  background: var(--content-surface);
  color: var(--text);
}

body.jelly-site .site-messages .success {
  border-color: var(--content-ok-line);
  background: var(--content-ok-bg);
  color: var(--content-ok-ink);
}

body.jelly-site .site-messages .warning {
  border-color: var(--content-warning-line);
  background: var(--content-warning-bg);
  color: var(--content-warning-ink);
}

body.jelly-site .site-messages .error {
  border-color: var(--content-error-line);
  background: var(--content-error-bg);
  color: var(--content-error-ink);
}

body.jelly-site .account-toast {
  border-color: var(--line);
  border-radius: 16px;
  background: var(--content-surface);
  box-shadow: var(--shell-shadow);
}

body.jelly-site .account-toast-check {
  border-color: var(--content-primary-edge);
  background: var(--content-primary);
}

body.jelly-site .account-toast-text { color: var(--text); }
body.jelly-site .account-toast-track { background: var(--line); }
body.jelly-site .account-toast-track::before { background: var(--accent); }

body.jelly-site #wang-update-notice {
  border-color: var(--line);
  border-radius: clamp(19px, 2.5vw, 26px);
  background: var(--paper);
  color: var(--text);
  box-shadow: var(--shell-shadow);
}

body.jelly-site #wang-update-notice::backdrop,
body.jelly-site .wn-shade { background: #211233a8; }

body.jelly-site #wang-update-notice :is(.wn-header, .wn-footer) { background: var(--content-surface); }
body.jelly-site #wang-update-notice :is(.wn-brand, .wn-hint, .wn-body > p:first-child) { color: var(--muted); }
body.jelly-site #wang-update-notice :is(#wn-title, .wn-body h2, .wn-body h3, .wn-body h4) { color: var(--text); }
body.jelly-site #wang-update-notice .wn-body li::marker,
body.jelly-site #wang-update-notice .wn-body a { color: var(--accent); }

body.jelly-site #wang-update-notice :is(.wn-tag, .wn-close, .wn-body blockquote, .wn-actions button, .wn-actions a) {
  border-color: var(--line);
  border-radius: 12px;
  background: var(--soft);
  color: var(--accent);
}

body.jelly-site #wang-update-notice .wn-close { border-radius: 50%; }
body.jelly-site #wang-update-notice :is(.wn-close, .wn-actions button, .wn-actions a):hover { background: var(--line); }

body.jelly-site #wang-update-notice .wn-actions .wn-primary {
  border-color: var(--content-primary-edge);
  background: var(--content-primary);
  color: var(--content-primary-ink);
}

body.jelly-site #wang-update-notice .wn-actions .wn-primary:hover { background: var(--content-primary-hover); }
body.jelly-site #wang-update-notice :is(button, a):focus-visible { outline-color: var(--focus); }

@media (max-width: 480px) {
  body.jelly-site .account-panel .account-profile-details { grid-template-columns: minmax(0, 1fr); }
  body.jelly-site #wang-update-notice .wn-actions { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}
