/*
 * RJS BOOK theme layer
 * v6.51
 *
 * style.css  : layout / sizing / component structure
 * theme.css  : light/dark colors and state contrast
 *
 * This file is intentionally loaded AFTER style.css.
 */

/* =========================
   Shared theme tokens
   ========================= */
html.theme-light {
  color-scheme: light;

  --theme-page: #f6f3ee;
  --theme-surface: #fffdf9;
  --theme-surface-strong: #ffffff;
  --theme-surface-soft: #f8f4ed;
  --theme-text: #191816;
  --theme-muted: #77716a;
  --theme-line: #ddd7ce;
  --theme-line-soft: #ebe6df;
  --theme-hover: #f3eee7;

  --theme-primary-bg: #191816;
  --theme-primary-text: #ffffff;
  --theme-secondary-bg: #ffffff;
  --theme-secondary-text: #191816;

  --theme-overlay: rgba(20, 18, 16, .55);
  --theme-shadow: rgba(37, 33, 28, .08);
}

html.theme-dark {
  color-scheme: dark;

  --theme-page: #171614;
  --theme-surface: #211f1c;
  --theme-surface-strong: #2a2724;
  --theme-surface-soft: #27231f;
  --theme-text: #f2ede6;
  --theme-muted: #aaa39a;
  --theme-line: #4d4841;
  --theme-line-soft: #39352f;
  --theme-hover: #38342f;

  --theme-primary-bg: #eee8df;
  --theme-primary-text: #171614;
  --theme-secondary-bg: #2a2724;
  --theme-secondary-text: #f2ede6;

  --theme-overlay: rgba(4, 4, 4, .72);
  --theme-shadow: rgba(0, 0, 0, .28);
}

/* =========================
   Page / header / search
   ========================= */
html.theme-light body,
html.theme-dark body {
  color: var(--theme-text);
}

html.theme-light body {
  background:
    radial-gradient(circle at top right, rgba(255,255,255,.9), transparent 34%),
    var(--theme-page);
}

html.theme-dark body {
  background:
    radial-gradient(circle at top right, rgba(255,255,255,.025), transparent 34%),
    var(--theme-page);
}

html.theme-light .site-header.compact-mode::before,
html.theme-dark .site-header.compact-mode::before {
  border-bottom-color: var(--theme-line);
}

html.theme-light .site-header.compact-mode::before {
  background: rgba(246,243,238,.94);
}

html.theme-dark .site-header.compact-mode::before {
  background: rgba(23,22,20,.94);
}

html.theme-light .search-box,
html.theme-light .compact-header-search,
html.theme-dark .search-box,
html.theme-dark .compact-header-search {
  background: var(--theme-surface-strong);
  border-color: var(--theme-line);
  color: var(--theme-text);
}

html.theme-light input,
html.theme-light select,
html.theme-light textarea,
html.theme-dark input,
html.theme-dark select,
html.theme-dark textarea {
  background: var(--theme-surface-strong);
  color: var(--theme-text);
  border-color: var(--theme-line);
}

html.theme-light input::placeholder,
html.theme-light textarea::placeholder,
html.theme-dark input::placeholder,
html.theme-dark textarea::placeholder {
  color: var(--theme-muted);
}

/* =========================
   Filter / toolbar surfaces
   ========================= */
html.theme-light .control-card,
html.theme-dark .control-card {
  background: var(--theme-surface);
  border-color: var(--theme-line);
}

html.theme-light .filter-label,
html.theme-dark .filter-label,
html.theme-light .filter-summary,
html.theme-dark .filter-summary {
  color: var(--theme-muted);
}

html.theme-light .chip,
html.theme-light .view-switch,
html.theme-light .view-button,
html.theme-light .mobile-filter-toggle,
html.theme-light .quick-filter-button,
html.theme-light .resume-shortcut-button,
html.theme-dark .chip,
html.theme-dark .view-switch,
html.theme-dark .view-button,
html.theme-dark .mobile-filter-toggle,
html.theme-dark .quick-filter-button,
html.theme-dark .resume-shortcut-button {
  border-color: var(--theme-line);
  background: var(--theme-secondary-bg);
  color: var(--theme-secondary-text);
}

html.theme-light .chip:hover,
html.theme-light .view-button:hover,
html.theme-light .quick-filter-button:hover,
html.theme-light .resume-shortcut-button:hover,
html.theme-dark .chip:hover,
html.theme-dark .view-button:hover,
html.theme-dark .quick-filter-button:hover,
html.theme-dark .resume-shortcut-button:hover {
  background: var(--theme-hover);
  color: var(--theme-text);
}

html.theme-light .chip.active,
html.theme-light .view-button.active,
html.theme-light .quick-filter-button.active,
html.theme-dark .chip.active,
html.theme-dark .view-button.active,
html.theme-dark .quick-filter-button.active {
  background: var(--theme-primary-bg);
  border-color: var(--theme-primary-bg);
  color: var(--theme-primary-text);
}

/* =========================
   Content list / cards
   ========================= */
html.theme-light .content-card,
html.theme-light .content-list-wrap,
html.theme-dark .content-card,
html.theme-dark .content-list-wrap {
  background: var(--theme-surface);
  border-color: var(--theme-line-soft);
  color: var(--theme-text);
}

html.theme-light .content-card:hover,
html.theme-dark .content-card:hover,
html.theme-light .content-list tbody tr:hover,
html.theme-dark .content-list tbody tr:hover {
  background: var(--theme-hover);
}

html.theme-light .content-list th,
html.theme-dark .content-list th {
  background: var(--theme-surface-soft);
  color: var(--theme-muted);
  border-bottom-color: var(--theme-line-soft);
}

html.theme-light .content-list td,
html.theme-dark .content-list td {
  border-bottom-color: var(--theme-line-soft);
}

html.theme-light .list-title,
html.theme-dark .list-title {
  color: var(--theme-text);
}

/* =========================
   Reader
   ========================= */
html.theme-light .reader,
html.theme-light .reader-header,
html.theme-dark .reader,
html.theme-dark .reader-header {
  background: var(--theme-surface);
  color: var(--theme-text);
}

html.theme-light .reader-overlay,
html.theme-dark .reader-overlay {
  background: var(--theme-overlay);
}

html.theme-light .reader-body,
html.theme-dark .reader-body {
  color: var(--theme-text);
}

html.theme-light .reader-author,
html.theme-light .reader-filename,
html.theme-dark .reader-author,
html.theme-dark .reader-filename {
  color: var(--theme-muted);
}

html.theme-light .reader-loading-overlay {
  background:
    linear-gradient(
      to bottom,
      rgba(255,253,249,.985) 0%,
      rgba(255,253,249,.97) 74%,
      rgba(255,253,249,.84) 100%
    );
}

html.theme-dark .reader-loading-overlay {
  background:
    linear-gradient(
      to bottom,
      rgba(33,31,28,.985) 0%,
      rgba(33,31,28,.97) 74%,
      rgba(33,31,28,.86) 100%
    );
}

/* Resume box */
html.theme-light .reader-resume,
html.theme-dark .reader-resume {
  background: var(--theme-surface-soft);
  border-color: var(--theme-line);
  color: var(--theme-text);
  box-shadow: 0 8px 20px var(--theme-shadow);
}

html.theme-light .reader-resume strong,
html.theme-dark .reader-resume strong {
  color: var(--theme-text);
}

html.theme-light .reader-resume span,
html.theme-dark .reader-resume span {
  color: var(--theme-muted);
}

/* Secondary resume button */
html.theme-light .reader-resume-actions button,
html.theme-dark .reader-resume-actions button {
  background: var(--theme-secondary-bg);
  border-color: var(--theme-line);
  color: var(--theme-secondary-text);
}

/* Primary "이어보기" button — explicit per theme to prevent black-on-black */
html.theme-light .reader-resume-actions button:first-child,
html.theme-dark .reader-resume-actions button:first-child {
  background: var(--theme-primary-bg);
  border-color: var(--theme-primary-bg);
  color: var(--theme-primary-text);
}

html.theme-light .reader-resume-actions button:hover,
html.theme-dark .reader-resume-actions button:hover {
  filter: brightness(.97);
}

html.theme-light .reader-bookmark-button,
html.theme-light .reader-download-button,
html.theme-light .reader-close,
html.theme-dark .reader-bookmark-button,
html.theme-dark .reader-download-button,
html.theme-dark .reader-close {
  background: var(--theme-secondary-bg);
  color: var(--theme-secondary-text);
  border-color: var(--theme-line);
}

html.theme-light .reader-bookmark-button.active,
html.theme-dark .reader-bookmark-button.active {
  background: var(--theme-primary-bg);
  color: var(--theme-primary-text);
  border-color: var(--theme-primary-bg);
}

/* =========================
   Modal / account / library
   ========================= */
html.theme-light .simple-modal,
html.theme-dark .simple-modal {
  background: var(--theme-surface);
  color: var(--theme-text);
  border-color: var(--theme-line);
}

html.theme-light .simple-modal-close,
html.theme-dark .simple-modal-close,
html.theme-light .library-entry,
html.theme-dark .library-entry,
html.theme-light .library-search,
html.theme-dark .library-search,
html.theme-light .account-preference-row,
html.theme-dark .account-preference-row,
html.theme-light .preference-segmented,
html.theme-dark .preference-segmented {
  background: var(--theme-surface-strong);
  color: var(--theme-text);
  border-color: var(--theme-line);
}

html.theme-light .modal-primary-button,
html.theme-dark .modal-primary-button,
html.theme-light .preference-toggle.active,
html.theme-dark .preference-toggle.active,
html.theme-light .preference-segmented button.active,
html.theme-dark .preference-segmented button.active {
  background: var(--theme-primary-bg);
  color: var(--theme-primary-text);
  border-color: var(--theme-primary-bg);
}

html.theme-light .modal-secondary-button,
html.theme-dark .modal-secondary-button,
html.theme-light .preference-segmented button,
html.theme-dark .preference-segmented button {
  background: var(--theme-secondary-bg);
  color: var(--theme-secondary-text);
  border-color: var(--theme-line);
}

/* =========================
   Scroll / utility buttons
   ========================= */
html.theme-light .page-scroll-top,
html.theme-light .reader-scroll-top,
html.theme-dark .page-scroll-top,
html.theme-dark .reader-scroll-top {
  background: var(--theme-surface-strong);
  color: var(--theme-text);
  border-color: var(--theme-line);
}

/* Do not override intentional semantic badges:
   - card CP pink badge
   - TXT / POSTYPE source badges
   - warning / edited status badges
*/


/* =========================
   v6.52 filter consistency
   ========================= */

/* CP filter uses exactly the same visual system as other filter chips. */
html.theme-light #combinationFilters .chip,
html.theme-dark #combinationFilters .chip {
  background: var(--theme-secondary-bg);
  border-color: var(--theme-line);
  color: var(--theme-secondary-text);
}

html.theme-light #combinationFilters .chip:hover,
html.theme-dark #combinationFilters .chip:hover {
  background: var(--theme-hover);
  border-color: var(--theme-line);
  color: var(--theme-text);
}

html.theme-light #combinationFilters .chip.active,
html.theme-dark #combinationFilters .chip.active {
  background: var(--theme-primary-bg);
  border-color: var(--theme-primary-bg);
  color: var(--theme-primary-text);
}

/* Mobile filter chevron: consistent SVG shape instead of a font glyph. */
.filter-chevron {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  line-height: 1;
  transition: transform .16s ease;
}

.filter-chevron svg {
  display: block;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-filter-toggle[aria-expanded="true"] .filter-chevron {
  transform: rotate(180deg);
}

/* POSTYPE bookmark button */
.postype-bookmark-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  flex: 0 0 auto;
  border: 1px solid var(--theme-line);
  border-radius: 50%;
  background: var(--theme-secondary-bg);
  color: var(--theme-muted);
  cursor: pointer;
}

.postype-bookmark-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.postype-bookmark-button:hover {
  background: var(--theme-hover);
  color: var(--theme-text);
}

.postype-bookmark-button.active {
  background: var(--theme-primary-bg);
  border-color: var(--theme-primary-bg);
  color: var(--theme-primary-text);
}

.postype-bookmark-button.active svg {
  fill: currentColor;
}

.card-postype-bookmark {
  position: absolute;
  right: 44px;
  bottom: 15px;
}

.list-postype-bookmark {
  width: 22px;
  height: 22px;
}

.list-postype-bookmark svg {
  width: 12px;
  height: 12px;
}

@media (max-width: 640px) {
  .filter-chevron {
    width: 16px;
    height: 16px;
  }

  .filter-chevron svg {
    width: 12px;
    height: 12px;
  }

  .card-postype-bookmark {
    right: 42px;
    bottom: 14px;
    width: 24px;
    height: 24px;
  }

  .card-postype-bookmark svg {
    width: 12px;
    height: 12px;
  }

  .list-postype-bookmark {
    width: 18px;
    height: 18px;
  }

  .list-postype-bookmark svg {
    width: 10px;
    height: 10px;
  }
}


/* =========================
   v6.53 mobile top compact
   ========================= */
@media (max-width: 640px) {
  .site-header {
    height: 54px;
  }

  .brand {
    gap: 7px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 9px;
  }

  .cat-mark svg {
    width: 18px;
    height: 18px;
  }

  .brand-text {
    font-size: 14px;
  }

  .hero {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .hero h1,
  .hero-copy,
  .hero .eyebrow {
    display: none;
  }

  .search-box {
    margin-top: 0;
    min-height: 46px;
    padding: 0 12px;
    border-radius: 14px;
  }

  .search-box input {
    padding: 11px 0;
    font-size: 13px;
  }

  .search-icon {
    font-size: 18px;
  }

  .controls {
    padding-top: 0;
    padding-bottom: 20px;
  }

  .controls-toolbar {
    gap: 7px;
    margin-bottom: 7px;
  }

  .mobile-filter-toggle,
  .sort-control select {
    min-height: 40px;
    border-radius: 13px;
  }

  .mobile-filter-toggle {
    padding: 7px 10px;
  }

  .sort-control select {
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .library-quick-actions {
    gap: 6px;
  }

  .resume-shortcut-button {
    min-height: 38px;
    padding: 7px 10px;
    border-radius: 13px;
    font-size: 10px;
  }

  .resume-shortcut-icon {
    width: 18px;
    height: 18px;
    font-size: 7px;
  }

  .quick-filter-button {
    min-height: 38px;
    padding: 7px 9px;
    border-radius: 13px;
    font-size: 10px;
  }

  .quick-filter-button svg {
    width: 14px;
    height: 14px;
  }

  .content-section {
    padding-top: 24px;
  }

  .section-head {
    margin-bottom: 16px;
  }
}

/* Give resume a little more hierarchy than the secondary filters. */
html.theme-light .resume-shortcut-button {
  background: #f3eee7;
  border-color: #ddd2c3;
  color: #2a2724;
}

html.theme-light .resume-shortcut-button:hover {
  background: #ebe4da;
}

html.theme-dark .resume-shortcut-button {
  background: #2f2a25;
  border-color: #51483f;
  color: #f4eee6;
}

html.theme-dark .resume-shortcut-button:hover {
  background: #39332d;
}


/* =========================
   v6.54 action icon size unify
   ========================= */

/* List view: TXT download / POSTYPE bookmark use the same visual box. */
.list-download-button.item-download-button,
.list-postype-bookmark.postype-bookmark-button {
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  border-radius: 50%;
}

.list-download-button.item-download-button svg,
.list-postype-bookmark.postype-bookmark-button svg {
  width: 12px;
  height: 12px;
}

/* Card view: TXT download / POSTYPE bookmark use the same visual box. */
.card-download-button.item-download-button,
.card-postype-bookmark.postype-bookmark-button {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: 50%;
}

.card-download-button.item-download-button svg,
.card-postype-bookmark.postype-bookmark-button svg {
  width: 14px;
  height: 14px;
}

/* Keep icon stroke weight visually consistent. */
.list-download-button.item-download-button svg,
.card-download-button.item-download-button svg,
.list-postype-bookmark.postype-bookmark-button svg,
.card-postype-bookmark.postype-bookmark-button svg {
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Mobile: preserve the same relative size between source actions. */
@media (max-width: 640px) {
  .list-download-button.item-download-button,
  .list-postype-bookmark.postype-bookmark-button {
    width: 20px;
    height: 20px;
    min-width: 20px;
  }

  .list-download-button.item-download-button svg,
  .list-postype-bookmark.postype-bookmark-button svg {
    width: 11px;
    height: 11px;
  }

  .card-download-button.item-download-button,
  .card-postype-bookmark.postype-bookmark-button {
    width: 26px;
    height: 26px;
    min-width: 26px;
  }

  .card-download-button.item-download-button svg,
  .card-postype-bookmark.postype-bookmark-button svg {
    width: 13px;
    height: 13px;
  }
}


/* =========================
   v6.55 downloaded TXT state
   ========================= */
.item-download-button {
  position: relative;
}

.item-download-button.downloaded {
  border-color: var(--theme-primary-bg);
  color: var(--theme-primary-bg);
}

.item-download-button.downloaded .downloaded-check {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 13px;
  height: 13px;
  border: 2px solid var(--theme-surface);
  border-radius: 50%;
  background: var(--theme-primary-bg);
  color: var(--theme-primary-text);
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .item-download-button.downloaded .downloaded-check {
    right: -3px;
    bottom: -3px;
    width: 12px;
    height: 12px;
    font-size: 7px;
  }
}


/* =========================
   v6.56 TXT / POSTYPE action icon final alignment
   ========================= */

/* Card action container owns the position.
   Child buttons must never position themselves independently. */
.content-card .card-actions {
  right: 16px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.content-card .card-actions > .card-download-button.item-download-button,
.content-card .card-actions > .card-postype-bookmark.postype-bookmark-button {
  position: relative !important;
  right: auto !important;
  bottom: auto !important;
  inset: auto !important;

  display: inline-grid !important;
  place-items: center;
  flex: 0 0 28px;

  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  padding: 0 !important;
  margin: 0 !important;

  box-sizing: border-box;
  border: 1px solid var(--theme-line) !important;
  border-radius: 50% !important;
  background: var(--theme-secondary-bg) !important;
  color: var(--theme-secondary-text) !important;
  box-shadow: none !important;
  transform: none !important;
  line-height: 1;
}

.content-card .card-actions > .card-download-button.item-download-button svg,
.content-card .card-actions > .card-postype-bookmark.postype-bookmark-button svg {
  display: block;
  width: 14px !important;
  height: 14px !important;
  margin: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8 !important;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.content-card .card-actions > .card-postype-bookmark.postype-bookmark-button.active {
  background: var(--theme-primary-bg) !important;
  border-color: var(--theme-primary-bg) !important;
  color: var(--theme-primary-text) !important;
}

.content-card .card-actions > .card-postype-bookmark.postype-bookmark-button.active svg {
  fill: currentColor;
}

/* List action buttons share exactly the same box model. */
.content-list .list-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.content-list .list-title-actions > .list-download-button.item-download-button,
.content-list .list-title-actions > .list-postype-bookmark.postype-bookmark-button {
  position: relative !important;
  right: auto !important;
  bottom: auto !important;
  inset: auto !important;

  display: inline-grid !important;
  place-items: center;
  flex: 0 0 22px;

  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
  padding: 0 !important;
  margin: 0 !important;

  box-sizing: border-box;
  border: 1px solid var(--theme-line) !important;
  border-radius: 50% !important;
  background: var(--theme-secondary-bg) !important;
  color: var(--theme-secondary-text) !important;
  box-shadow: none !important;
  transform: none !important;
  line-height: 1;
}

.content-list .list-title-actions > .list-download-button.item-download-button svg,
.content-list .list-title-actions > .list-postype-bookmark.postype-bookmark-button svg {
  display: block;
  width: 12px !important;
  height: 12px !important;
  margin: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8 !important;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.content-list .list-title-actions > .list-postype-bookmark.postype-bookmark-button.active {
  background: var(--theme-primary-bg) !important;
  border-color: var(--theme-primary-bg) !important;
  color: var(--theme-primary-text) !important;
}

.content-list .list-title-actions > .list-postype-bookmark.postype-bookmark-button.active svg {
  fill: currentColor;
}

/* Downloaded TXT keeps the check mark, but the parent circle remains
   exactly the same size and position as the POSTYPE bookmark circle. */
.item-download-button.downloaded {
  border-color: var(--theme-primary-bg) !important;
  color: var(--theme-primary-bg) !important;
}

@media (max-width: 640px) {
  .content-card .card-actions {
    right: 14px;
    bottom: 13px;
    gap: 6px;
  }

  .content-card .card-actions > .card-download-button.item-download-button,
  .content-card .card-actions > .card-postype-bookmark.postype-bookmark-button {
    flex-basis: 26px;
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    min-height: 26px !important;
  }

  .content-card .card-actions > .card-download-button.item-download-button svg,
  .content-card .card-actions > .card-postype-bookmark.postype-bookmark-button svg {
    width: 13px !important;
    height: 13px !important;
  }

  .content-list .list-title-actions > .list-download-button.item-download-button,
  .content-list .list-title-actions > .list-postype-bookmark.postype-bookmark-button {
    flex-basis: 20px;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
  }

  .content-list .list-title-actions > .list-download-button.item-download-button svg,
  .content-list .list-title-actions > .list-postype-bookmark.postype-bookmark-button svg {
    width: 11px !important;
    height: 11px !important;
  }
}


/* =========================
   v6.57 list action vertical centering
   ========================= */

/*
 * POSTYPE rows can have a second metadata line under the title.
 * Previously the action icons were centered only against the first title row,
 * so they looked visually too high. Center them against the entire title cell.
 */
.content-list td.list-title {
  position: relative;
  padding-right: 42px;
}

.content-list .list-title-row {
  display: block;
  width: 100%;
  min-width: 0;
}

.content-list .list-title-main {
  width: 100%;
  min-width: 0;
}

.content-list .list-title-actions {
  position: absolute;
  top: 50%;
  right: 7px;
  margin: 0;
  transform: translateY(-50%);
  z-index: 1;
}

.content-list .list-source-meta {
  padding-right: 0;
}

@media (max-width: 640px) {
  .content-list td.list-title {
    padding-right: 32px !important;
  }

  .content-list .list-title-actions {
    right: 5px;
  }
}
