:root {
  --navy: #13264A;
  --navy-2: #1d3461;
  --accent: #C7452B;
  --ink: #16202e;
  --muted: #5b6470;
  --line: #dfe3e8;
  --bg: #f6f7f9;
  --card: #ffffff;
  --radius: 10px;
  --wrap: 920px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); color: var(--ink);
  background: var(--bg); line-height: 1.5;
}
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); }

/* Masthead */
.masthead { background: var(--navy); color: #fff; }
.masthead .wrap {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; padding-top: 22px; padding-bottom: 18px; flex-wrap: wrap;
}
.masthead h1 { margin: 0; font-size: 30px; letter-spacing: -0.5px; }
.tagline { margin: 2px 0 0; color: #aebbd2; font-size: 13px; }
.issue-meta { text-align: right; color: #cdd6e6; font-size: 13px; }
.issue-meta strong { color: #fff; }

/* Toolbar */
.toolbar { background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; }
.toolbar-inner {
  display: flex; align-items: center; gap: 10px; padding-top: 12px;
  padding-bottom: 12px; flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); }
.field span { margin-bottom: 2px; text-transform: uppercase; letter-spacing: .04em; }
select, input[type="search"], input[type="text"] {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}
#search { flex: 1 1 220px; min-width: 160px; }
.btn {
  font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.btn:hover { border-color: var(--navy-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #ad3a23; border-color: #ad3a23; }
.link { background: none; border: none; color: var(--accent); cursor: pointer;
  font: inherit; padding: 0; }

/* Journals panel */
.journals-panel { padding: 14px 20px 18px; border-top: 1px solid var(--line);
  background: #fbfcfd; }
.muted { color: var(--muted); font-weight: 400; }
.journals-add { margin-bottom: 16px; }
.journals-add > label { font-size: 13px; display: block; margin-bottom: 6px; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; }
.journal-results { margin-top: 10px; display: grid; gap: 6px; }
.jresult { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.jresult button { flex: 0 0 auto; padding: 5px 12px; font-size: 13px; }

.journals-head { display: flex; justify-content: space-between; margin-bottom: 10px;
  font-size: 13px; color: var(--muted); }
.journals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 4px 16px; }
.journal-row { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer;
  padding: 3px 0; }
.journal-row .jrow-name { flex: 1; }
.journal-row input:disabled { opacity: .5; }
.pending-tag { color: var(--accent); font-size: 11px; font-weight: 600;
  background: #fbe7e2; border-radius: 4px; padding: 1px 6px; }
.jrow-remove { background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 4px; opacity: .55; }
.jrow-remove:hover { color: var(--accent); opacity: 1; }

.subs-sync { margin-top: 16px; background: #fff; border: 1px solid var(--accent);
  border-left-width: 3px; border-radius: 8px; padding: 12px 14px; font-size: 13px; }
.subs-sync p { margin: 0 0 10px; }
.subs-sync pre { margin: 12px 0 0; background: #0f1b33; color: #e8edf6; padding: 12px;
  border-radius: 8px; font-size: 12px; line-height: 1.45; overflow-x: auto;
  white-space: pre-wrap; word-break: break-word; max-height: 320px; }

/* Content */
main { padding: 22px 20px 40px; }
.status { color: var(--muted); padding: 30px 0; text-align: center; }
.summary-line { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

.journal-section { margin-bottom: 26px; }
.journal-title {
  font-size: 16px; color: var(--navy); margin: 0 0 10px;
  padding-bottom: 6px; border-bottom: 2px solid var(--navy);
  display: flex; align-items: baseline; gap: 8px;
}
.journal-title .count { color: var(--muted); font-size: 13px; font-weight: 400; }

.article { background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.article h3 { margin: 0; font-size: 15px; line-height: 1.35; }
.article h3 button {
  text-align: left; background: none; border: none; cursor: pointer; padding: 0;
  font: inherit; color: var(--ink); width: 100%;
}
.article h3 button:hover { color: var(--accent); }
.authors { color: var(--muted); font-size: 13px; font-style: italic; margin: 5px 0 0; }
.abstract { margin: 10px 0 0; font-size: 14px; color: #2a323d; white-space: pre-wrap; }
.abstract[hidden] { display: none; }
.article-links { margin-top: 10px; display: flex; gap: 14px; font-size: 13px; }
.article-links a { text-decoration: none; font-weight: 600; }
.toggle-hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }

.empty { background: #fff; border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 28px; text-align: center; color: var(--muted); }

.site-footer { color: var(--muted); font-size: 12px; padding: 22px 20px 40px;
  border-top: 1px solid var(--line); margin-top: 20px; }

/* Newsstand (home) */
.newsstand { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px; margin-bottom: 6px; }
.newsstand.dim { opacity: .65; }
.nostand-sep { margin: 20px 0 8px; font-size: 13px; }
.jcard { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  cursor: pointer; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 14px; font: inherit; color: inherit;
  transition: border-color .15s, transform .05s; }
.jcard:hover:not(:disabled) { border-color: var(--navy-2); }
.jcard:active:not(:disabled) { transform: translateY(1px); }
.jcard.is-empty { cursor: default; }
.jcard-badge { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px; color: #fff;
  font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center;
  letter-spacing: .3px; position: relative; overflow: hidden; }
/* When journal-icons/<key>.png exists it overlays the monogram tile (white bg for logos). */
.jcard-badge.has-img { background: #fff !important; border: 1px solid var(--line); }
.jbadge-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  padding: 4px; background: #fff; display: none; }
.jcard-badge.has-img .jbadge-img { display: block; }
.jcard-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.jcard-name { font-weight: 600; color: var(--navy); line-height: 1.25; }
.jcard-edition { font-size: 12.5px; color: var(--muted); }
.jcard-count { flex: 0 0 auto; min-width: 28px; text-align: center; font-weight: 700;
  color: var(--a, var(--navy)); font-size: 18px; }
.jcard.is-empty .jcard-count { color: var(--muted); font-weight: 400; }

/* Journal contents (table of contents) */
.toc-head { margin-bottom: 10px; }
.back { background: none; border: none; color: var(--accent); font: inherit; font-weight: 600;
  cursor: pointer; padding: 4px 0; }
.toc-title { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.toc-journal { display: block; font-size: 19px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.toc-edition { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; }
.toc-section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 20px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.article h4 { margin: 0; font-size: 15px; line-height: 1.35; }
.article h4 button { text-align: left; background: none; border: none; cursor: pointer; padding: 0;
  font: inherit; color: var(--ink); width: 100%; font-weight: 600; }
.article h4 button:hover { color: var(--accent); }
.meta-line { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.meta-line a { color: var(--accent); font-weight: 600; text-decoration: none; }
.meta-line a:hover { text-decoration: underline; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(19,38,74,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 14px; max-width: 480px; width: 100%;
  padding: 24px; position: relative; }
.modal-card h2 { margin: 0 0 8px; color: var(--navy); }
.modal-card ol { padding-left: 18px; font-size: 14px; color: #2a323d; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none;
  font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.copy-row input { flex: 1; }
.digest-h { margin: 14px 0 2px; font-size: 14px; color: var(--navy); }
.digest-p { margin: 0; font-size: 13px; color: var(--muted); }
.digest-hint { margin: 7px 0 0; font-size: 11.5px; color: var(--muted); }
.digest-sep { border: none; border-top: 1px solid var(--line); margin: 18px 0 0; }
.digest-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.digest-actions .btn { text-decoration: none; }

@media (max-width: 560px) {
  .masthead h1 { font-size: 24px; }
  .issue-meta { text-align: left; }
}
