/* Lore — page-specific layouts. */

/* ---- Hero (logged-out front page) ---- */
.lore-hero {
	background: linear-gradient(160deg, var(--ember) 0%, #c8461f 60%, #a83a1a 100%);
	color: #fff; padding: var(--space-12) var(--space-4) var(--space-10);
	text-align: center; position: relative; overflow: hidden;
}
.lore-hero::after {
	content: ''; position: absolute; inset: 0; opacity: .12; pointer-events: none;
	background-image: radial-gradient(circle at 20% 20%, #fff 0, transparent 40%), radial-gradient(circle at 80% 70%, #fff 0, transparent 35%);
}
.lore-hero__inner { position: relative; max-width: 620px; margin: 0 auto; }
.lore-hero h1 { font-family: var(--lore-font-serif); font-size: clamp(1.9rem, 6vw, 3rem); margin-bottom: var(--space-3); }
.lore-hero p { font-size: 1.05rem; opacity: .92; margin-bottom: var(--space-6); }
.lore-hero__actions { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; }
.lore-hero .lore-btn--primary { background: #fff; color: var(--ember-dark); }
.lore-hero .lore-btn--ghost { border-color: rgba(255,255,255,.6); color: #fff; }
.lore-hero__stats { display: flex; gap: var(--space-6); justify-content: center; margin-top: var(--space-8); flex-wrap: wrap; }
.lore-hero__stats div { text-align: center; }
.lore-hero__stats strong { display: block; font-size: 1.4rem; }
.lore-hero__stats span { font-size: .75rem; opacity: .85; }

.lore-continue-strip { padding: var(--space-4); max-width: var(--max-w); margin: var(--space-4) auto 0; }
.lore-continue-card { display: flex; gap: var(--space-3); align-items: center; background: var(--paper-alt); border-radius: var(--radius-lg); padding: var(--space-3); }
.lore-continue-card img { width: 56px; height: 84px; object-fit: cover; border-radius: var(--radius-sm); flex: none; }
.lore-continue-card__body { flex: 1; min-width: 0; }
.lore-continue-card__title { font-weight: 700; font-size: .95rem; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Story detail (single-lore_story) ---- */
.lore-story-head { padding: var(--space-6) var(--space-4); max-width: var(--max-w); margin: 0 auto; }
@media (min-width: 760px) { .lore-story-head { display: grid; grid-template-columns: 260px 1fr; gap: var(--space-8); } }
.lore-story-head__cover { width: 200px; max-width: 60vw; margin: 0 auto var(--space-4); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-md); aspect-ratio: 2/3; }
@media (min-width: 760px) { .lore-story-head__cover { width: 100%; max-width: none; margin-bottom: 0; } }
.lore-story-head__cover img { width: 100%; height: 100%; object-fit: cover; }
.lore-story-head__title { font-family: var(--lore-font-serif); font-size: clamp(1.5rem, 4vw, 2.1rem); margin-bottom: var(--space-2); }
.lore-story-head__byline { font-size: .95rem; margin-bottom: var(--space-3); }
.lore-story-head__byline a { color: var(--ember); font-weight: 600; }
.lore-story-head__badges { display: flex; gap: var(--space-2); margin-bottom: var(--space-3); flex-wrap: wrap; }
.lore-story-head__stats { display: flex; gap: var(--space-5); margin-bottom: var(--space-4); color: var(--ink-soft); font-size: .875rem; }
.lore-story-head__stats span { display: inline-flex; align-items: center; gap: 5px; }
.lore-story-head__desc { max-width: 640px; margin-bottom: var(--space-4); color: var(--ink-soft); line-height: 1.6; }
.lore-story-head__desc.is-clamped { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.lore-story-head__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-5); }
.lore-story-head__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2); }

.lore-toc { max-width: var(--max-w); margin: var(--space-4) auto; padding: 0 var(--space-4); }
.lore-toc__list { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.lore-toc__row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border-bottom: 1px solid var(--line); }
.lore-toc__row:last-child { border-bottom: 0; }
.lore-toc__row:hover { background: var(--paper-alt); }
.lore-toc__num { width: 28px; height: 28px; border-radius: 50%; background: var(--paper-alt); display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; color: var(--ink-faint); flex: none; }
.lore-toc__title { flex: 1; font-weight: 600; }
.lore-toc__meta { font-size: .75rem; color: var(--ink-faint); }

/* ---- Reader header (part) partially shared with pages.css for TOC dropdown etc. handled in reader.css ---- */

/* ---- Taxonomy / browse / search ---- */
.lore-page-head { padding: var(--space-6) var(--space-4) var(--space-2); max-width: var(--max-w); margin: 0 auto; }
.lore-page-head h1 { font-family: var(--lore-font-serif); }
.lore-genre-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); max-width: var(--max-w); margin: 0 auto; padding: var(--space-4); }
@media (min-width: 600px) { .lore-genre-tiles { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .lore-genre-tiles { grid-template-columns: repeat(4, 1fr); } }
.lore-genre-tile {
	border-radius: var(--radius-lg); padding: var(--space-5) var(--space-4); color: #fff; font-weight: 700;
	min-height: 90px; display: flex; align-items: flex-end; background: var(--ink-soft);
}

/* ---- Profile ---- */
.lore-profile-head { text-align: center; padding: var(--space-6) var(--space-4); background: var(--paper-alt); }
.lore-profile-head__banner { height: 140px; background: linear-gradient(135deg, var(--ember), var(--teal)); border-radius: var(--radius-lg); margin-bottom: -56px; }
.lore-profile-head__name { font-weight: 800; font-size: 1.3rem; margin-top: var(--space-3); }
.lore-profile-head__username { color: var(--ink-faint); margin-bottom: var(--space-3); }
.lore-profile-head__bio { max-width: 480px; margin: 0 auto var(--space-4); color: var(--ink-soft); font-size: .9rem; }
.lore-profile-head__stats { display: flex; gap: var(--space-6); justify-content: center; margin-bottom: var(--space-4); }
.lore-profile-head__stats strong { display: block; }
.lore-profile-head__stats span { font-size: .75rem; color: var(--ink-faint); }
.lore-profile-head__actions { display: flex; gap: var(--space-3); justify-content: center; }

/* ---- Library ---- */
.lore-library-item { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); align-items: center; }
.lore-library-item img { width: 52px; height: 78px; object-fit: cover; border-radius: var(--radius-sm); flex: none; }
.lore-library-item__body { flex: 1; min-width: 0; }
.lore-library-item__title { font-weight: 700; font-size: .9rem; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lore-library-item__pct { font-size: .72rem; color: var(--ink-faint); margin-top: 4px; }

/* ---- Notifications ---- */
.lore-notif-list { max-width: 640px; margin: 0 auto; }
.lore-notif { display: flex; gap: var(--space-3); padding: var(--space-4); border-bottom: 1px solid var(--line); align-items: flex-start; }
.lore-notif.is-unread { background: var(--ember-light); }
.lore-notif__icon { width: 36px; height: 36px; border-radius: 50%; background: var(--paper-alt); display: flex; align-items: center; justify-content: center; flex: none; color: var(--ember); }
.lore-notif__body { flex: 1; font-size: .875rem; }
.lore-notif__time { font-size: .75rem; color: var(--ink-faint); }

/* ---- Inbox ---- */
.lore-inbox { display: block; max-width: var(--max-w); margin: 0 auto; }
@media (min-width: 820px) { .lore-inbox { display: grid; grid-template-columns: 320px 1fr; min-height: 70vh; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; margin: var(--space-4) auto; } }
.lore-inbox__threads { border-right: 1px solid var(--line); overflow-y: auto; }
.lore-thread-row { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); cursor: pointer; }
.lore-thread-row:hover, .lore-thread-row.is-active { background: var(--paper-alt); }
.lore-thread-row img { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.lore-thread-row__body { flex: 1; min-width: 0; }
.lore-thread-row__name { font-weight: 700; font-size: .875rem; }
.lore-thread-row__preview { font-size: .8rem; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lore-conversation { display: flex; flex-direction: column; height: 100%; min-height: 60vh; }
.lore-conversation__messages { flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.lore-bubble { max-width: 75%; padding: 10px 14px; border-radius: 16px; font-size: .875rem; background: var(--paper-alt); }
.lore-bubble.is-mine { align-self: flex-end; background: var(--ember); color: #fff; }
.lore-conversation__composer { display: flex; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--line); }
.lore-conversation__composer textarea { flex: 1; min-height: 44px; max-height: 120px; }

/* ---- Settings ---- */
.lore-settings { max-width: 620px; margin: 0 auto; padding: var(--space-4); }
.lore-settings__section { padding: var(--space-5) 0; border-bottom: 1px solid var(--line); }
.lore-settings__section h2 { font-size: 1.05rem; }
.lore-avatar-upload { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-4); }

/* ---- Write dashboard ---- */
.lore-write-head { display: flex; justify-content: space-between; align-items: center; padding: var(--space-6) var(--space-4) var(--space-4); max-width: var(--max-w); margin: 0 auto; flex-wrap: wrap; gap: var(--space-3); }
.lore-story-manage-list { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.lore-story-manage-card { display: flex; gap: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-3); }
.lore-story-manage-card img { width: 64px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); flex: none; }
.lore-story-manage-card__body { flex: 1; min-width: 0; }
.lore-story-manage-card__title { font-weight: 700; margin-bottom: 4px; }
.lore-story-manage-card__meta { font-size: .75rem; color: var(--ink-faint); display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: 6px; }
.lore-status-pill { font-size: .65rem; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--paper-alt); }
.lore-status-pill--published { background: rgba(27,153,139,.14); color: var(--teal-dark); }
.lore-status-pill--draft { background: var(--ember-light); color: var(--ember-dark); }

/* Story edit / part list */
.lore-cover-upload { width: 160px; aspect-ratio: 2/3; border-radius: var(--radius-lg); border: 2px dashed var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--ink-faint); cursor: pointer; overflow: hidden; position: relative; background: var(--paper-alt); }
.lore-cover-upload img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lore-tags-input { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 8px; }
.lore-tags-input input { border: 0; flex: 1; min-width: 120px; padding: 6px; font-size: .9rem; }
.lore-parts-list { display: flex; flex-direction: column; gap: 8px; margin-top: var(--space-3); }
.lore-part-row { display: flex; align-items: center; gap: var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); background: var(--white); }
.lore-part-row__title { flex: 1; font-weight: 600; font-size: .9rem; }
.lore-part-row__meta { font-size: .72rem; color: var(--ink-faint); }

/* Part editor */
.lore-editor-wrap { max-width: 760px; margin: 0 auto; padding: var(--space-4); }
.lore-editor-toolbar { display: flex; flex-wrap: wrap; gap: 2px; position: sticky; top: calc(var(--header-h) + 8px); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 4px; z-index: 5; margin-bottom: var(--space-3); }
.lore-editor-toolbar button { width: 36px; height: 36px; border-radius: var(--radius-sm); background: none; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lore-editor-toolbar button:hover { background: var(--paper-alt); }
.lore-editor-toolbar button.is-active { background: var(--ember-light); color: var(--ember-dark); }
.lore-editor-toolbar .lore-icon { width: 18px; height: 18px; }
.lore-editor-title { width: 100%; border: 0; font-size: 1.4rem; font-weight: 700; font-family: var(--lore-font-serif); padding: var(--space-2) 0; margin-bottom: var(--space-2); background: transparent; }
.lore-editor-title:focus { outline: none; }
.lore-editor-content {
	min-height: 320px; font-family: var(--lore-font-serif); font-size: 1.1rem; line-height: 1.7;
	border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4);
}
.lore-editor-content:focus { outline: none; border-color: var(--teal); }
.lore-editor-content p { margin: 0 0 1em; }
.lore-editor-footer { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-4); flex-wrap: wrap; gap: var(--space-3); }
.lore-editor-footer__status { font-size: .8rem; color: var(--ink-faint); }
.lore-editor-actions { display: flex; gap: var(--space-2); }

/* ---- Auth pages ---- */
.lore-auth-wrap { min-height: calc(100vh - var(--header-h)); display: flex; align-items: center; justify-content: center; padding: var(--space-6) var(--space-4); }
.lore-auth-card { width: 100%; max-width: 400px; }
.lore-auth-card__logo { text-align: center; color: var(--ember); margin-bottom: var(--space-4); }
.lore-auth-card__logo .lore-logo { height: 34px; margin: 0 auto; }
.lore-auth-card h1 { text-align: center; font-size: 1.3rem; margin-bottom: var(--space-2); }
.lore-auth-card__sub { text-align: center; color: var(--ink-faint); font-size: .875rem; margin-bottom: var(--space-6); }
.lore-auth-steps { display: flex; gap: 6px; justify-content: center; margin-bottom: var(--space-5); }
.lore-auth-steps span { width: 28px; height: 4px; border-radius: 2px; background: var(--line); }
.lore-auth-steps span.is-active, .lore-auth-steps span.is-done { background: var(--ember); }
.lore-auth-card__footer { text-align: center; font-size: .875rem; margin-top: var(--space-5); color: var(--ink-faint); }

/* ---- 404 / offline ---- */
.lore-status-page { min-height: 60vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: var(--space-6) var(--space-4); }
.lore-status-page__glyph { color: var(--ember); margin-bottom: var(--space-4); }
.lore-status-page__glyph .lore-logo { height: 40px; margin: 0 auto; }
.lore-status-page h1 { font-family: var(--lore-font-serif); }

/* ---- Static content page (about/terms/privacy/guidelines) ---- */
.lore-content-page { max-width: 720px; margin: 0 auto; padding: var(--space-8) var(--space-4); line-height: 1.7; }
.lore-content-page h1 { font-family: var(--lore-font-serif); margin-bottom: var(--space-4); }
.lore-content-page h2 { margin-top: var(--space-6); }

/* ---- Reader settings popover (structure only, theme colours in reader.css) ---- */
.lore-popover {
	position: absolute; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg);
	box-shadow: var(--shadow-lg); padding: var(--space-4); z-index: 60; width: 280px;
}
.lore-popover[hidden] { display: none; }
.lore-popover__row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.lore-popover__label { font-size: .8rem; font-weight: 600; color: var(--ink-faint); }
.lore-seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius-pill); overflow: hidden; }
.lore-seg button { flex: 1; background: none; border: 0; padding: 6px 10px; font-size: .8rem; cursor: pointer; }
.lore-seg button.is-active { background: var(--ember); color: #fff; }

/* iOS add-to-home hint banner */
.lore-ios-hint { position: fixed; left: var(--space-4); right: var(--space-4); bottom: calc(var(--tabbar-h) + 10px); background: var(--ink); color: #fff; border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); font-size: .82rem; display: flex; align-items: center; gap: var(--space-3); z-index: 150; }
.lore-ios-hint button { margin-left: auto; background: none; border: 0; color: #fff; cursor: pointer; }
