:root {
  --profile-ink: #1e1a16;
  --profile-muted: #746c63;
  --profile-line: #e6ded2;
  --profile-line-strong: #d7cbbb;
  --profile-paper: #faf6ef;
  --profile-page: #fffdf9;
  --profile-shelf: #f2ece3;
  --profile-accent: #8c2f39;
  --profile-accent-dark: #6e222b;
  --profile-good: #3c6e47;
  --profile-blue: #304f63;
  --profile-shadow: 0 18px 42px rgba(30, 26, 22, 0.08);
}

body:has(.profile-shell) {
  background:
    linear-gradient(180deg, rgba(250, 246, 239, 0.95), rgba(242, 236, 227, 0.95)),
    var(--profile-paper);
  color: var(--profile-ink);
}

body:has(.profile-shell) .public-shell {
  width: min(100%, 1240px);
}

.profile-shell {
  display: grid;
  grid-template-columns: minmax(190px, 0.28fr) minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100dvh - var(--public-header-height) - 52px);
  color: var(--profile-ink);
}

.profile-messages {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.profile-message {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--profile-line-strong);
  border-radius: 8px;
  background: var(--profile-page);
  color: var(--profile-muted);
  font-size: 0.92rem;
}

.profile-message--success {
  border-color: rgba(60, 110, 71, 0.32);
  background: rgba(60, 110, 71, 0.08);
  color: var(--profile-good);
}

.profile-message--error {
  border-color: rgba(140, 47, 57, 0.34);
  background: rgba(140, 47, 57, 0.08);
  color: var(--profile-accent-dark);
}

:where(.profile-shell a) {
  color: inherit;
}

.profile-shell a.profile-action,
.profile-shell a.profile-action--secondary,
.profile-shell a.profile-action--danger {
  color: #fff;
}

.profile-shell a.profile-action--quiet {
  color: var(--profile-ink);
}

.profile-shell--auth {
  max-width: 780px;
  margin: 0 auto;
}

.profile-shell--auth .profile-nav__button {
  display: block;
  text-decoration: none;
}

.profile-panel {
  border: 1px solid var(--profile-line);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: var(--profile-shadow);
}

.profile-sections {
  position: sticky;
  top: calc(var(--public-header-height) + 18px);
  align-self: start;
}

.profile-sections__inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  padding: 18px;
  border: 1px solid var(--profile-line);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.88);
}

.profile-panel__eyebrow,
.profile-card__eyebrow,
.profile-book__collection {
  margin: 0;
  color: var(--profile-accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.profile-sections__title,
.profile-section__header h2,
.profile-detail-section h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.05;
}

.profile-sections__title {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 1.12rem;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-sections__title span {
  color: var(--profile-muted);
}

.profile-sections__intro,
.profile-section__lede,
.profile-section__hint,
.profile-card__text,
.profile-empty,
.profile-tip p,
.profile-note__meta,
.profile-book__summary,
.profile-book__author,
.profile-form__help {
  margin: 0;
  color: var(--profile-muted);
}

.profile-sections__intro,
.profile-section__lede,
.profile-card__text,
.profile-empty,
.profile-book__summary,
.profile-book__author,
.profile-form__help {
  line-height: 1.45;
}

.profile-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-nav__button {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--profile-muted);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.profile-nav__button:hover,
.profile-nav__button:focus-visible,
.profile-nav__button.is-active {
  border-color: var(--profile-line-strong);
  background: var(--profile-shelf);
  color: var(--profile-ink);
  outline: none;
}

.profile-nav__label,
.profile-nav__meta {
  display: block;
}

.profile-nav__label {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: lowercase;
}

.profile-nav__meta {
  margin-top: 0.25rem;
  font-size: 0.8rem;
}

.profile-main,
.profile-panel--main {
  min-width: 0;
}

.profile-panel--main {
  min-height: 100%;
  padding: clamp(18px, 3vw, 30px);
}

.profile-section,
.profile-detail-section {
  display: none;
}

.profile-section.is-active,
.profile-detail-section.is-active {
  display: block;
}

.profile-section__header {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--profile-line);
}

.profile-section__header h2,
.profile-detail-section h2 {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.profile-section__lede {
  max-width: 58rem;
  font-size: 1rem;
}

.profile-section__hint {
  margin-top: 5px;
  max-width: 48rem;
  font-size: 0.9rem;
}

.profile-help-inline {
  display: block;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--profile-line);
  border-radius: 8px;
  background: var(--profile-shelf);
}

.profile-help-inline h3,
.profile-card h3,
.profile-tip h3,
.profile-book h4 {
  margin: 0;
  line-height: 1.16;
}

.profile-help-inline p {
  margin: 6px 0 0;
  color: var(--profile-muted);
}

.profile-stack,
.profile-tip-list,
.profile-book-list,
.profile-note-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-card,
.profile-tip,
.profile-book,
.profile-note {
  border: 1px solid var(--profile-line);
  border-radius: 8px;
  background: var(--profile-page);
}

.profile-card,
.profile-tip {
  padding: 16px;
}

.profile-card--library {
  padding: 0;
  overflow: hidden;
}

.profile-card--library > .profile-card__header {
  margin: 0;
  padding: 16px 18px;
  border-bottom: 1px solid var(--profile-line);
  background: rgba(242, 236, 227, 0.58);
}

.profile-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.profile-story {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-story h3 {
  margin-bottom: 0;
}

.profile-story h3 a {
  text-decoration: none;
}

.profile-story h3 a:hover,
.profile-story h3 a:focus-visible {
  color: var(--profile-accent-dark);
  text-decoration: underline;
}

.profile-story__unlike {
  min-width: 42px;
  min-height: 42px;
  border: 1px solid var(--profile-line-strong);
  border-radius: 8px;
  background: #fff8df;
  color: var(--profile-accent);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.profile-story__unlike:hover,
.profile-story__unlike:focus-visible {
  border-color: var(--profile-accent);
  outline: 2px solid var(--profile-accent);
  outline-offset: 2px;
}

.profile-card h3,
.profile-tip h3 {
  margin-top: 2px;
  font-size: 1.08rem;
}

.profile-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.profile-link-row--text {
  gap: 14px;
}

.profile-text-link {
  color: var(--profile-accent-dark);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.profile-text-link:hover,
.profile-text-link:focus-visible {
  color: var(--profile-accent);
}

.profile-book-list {
  gap: 0;
}

.profile-book-list .profile-book + .profile-book {
  border-top: 1px solid var(--profile-line);
}

.profile-book {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(128px, auto);
  align-items: start;
  gap: 14px;
  padding: 14px 18px;
  border-width: 0;
  border-radius: 0;
  background: var(--profile-page);
}

.profile-book--everybook {
  background:
    linear-gradient(90deg, rgba(140, 47, 57, 0.07), transparent 44%),
    var(--profile-page);
}

.profile-book--read {
  background: rgba(255, 253, 249, 0.72);
}

.profile-book__cover {
  display: grid;
  place-items: center;
  width: 44px;
  height: 64px;
  overflow: hidden;
  border: 1px solid var(--profile-line-strong);
  border-radius: 4px;
  background:
    linear-gradient(145deg, #304f63, #8c2f39);
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.profile-book__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-book__placeholder-mark {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.profile-book__meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.profile-book__title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-book h4 {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 1.13rem;
}

.profile-book h4 a,
.profile-card h3 a,
.profile-book__version a {
  color: inherit;
  text-decoration: none;
}

.profile-book h4 a:hover,
.profile-card h3 a:hover,
.profile-book__version a:hover {
  text-decoration: underline;
}

.profile-book__author,
.profile-book__summary {
  font-size: 0.92rem;
}

.profile-book__versions {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(230, 222, 210, 0.78);
}

.profile-book__version {
  display: grid;
  grid-template-columns: minmax(78px, 0.28fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--profile-muted);
  font-size: 0.88rem;
}

.profile-book__version--source {
  color: var(--profile-ink);
}

.profile-book__version--pending {
  color: var(--profile-blue);
}

.profile-book__version-label {
  color: var(--profile-accent);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.profile-status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid rgba(140, 47, 57, 0.22);
  border-radius: 999px;
  background: rgba(140, 47, 57, 0.08);
  color: var(--profile-accent-dark);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.profile-book__actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: stretch;
  min-width: 128px;
}

.profile-inline-form {
  display: contents;
}

.profile-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 5px 9px;
  border: 1px solid var(--profile-line-strong);
  border-radius: 999px;
  background: var(--profile-page);
  color: var(--profile-ink);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
}

.profile-badge--pending {
  min-width: 8rem;
  white-space: nowrap;
}

.profile-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--profile-accent);
  border-radius: 8px;
  background: var(--profile-accent);
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.profile-action:hover,
.profile-action:focus-visible {
  background: var(--profile-accent-dark);
  outline: none;
}

.profile-action--secondary {
  border-color: var(--profile-line-strong);
  background: var(--profile-ink);
  color: #fff;
}

.profile-action--secondary:hover,
.profile-action--secondary:focus-visible {
  background: var(--profile-accent);
}

.profile-action--quiet {
  border-color: var(--profile-line-strong);
  background: var(--profile-page);
  color: var(--profile-ink);
}

.profile-action--quiet:hover,
.profile-action--quiet:focus-visible {
  background: var(--profile-shelf);
}

.profile-action--audio {
  border-color: var(--profile-blue);
  background: var(--profile-blue);
  color: #fff;
}

.profile-action--audio:hover,
.profile-action--audio:focus-visible {
  background: #243f51;
}

.profile-action--disabled,
.profile-action:disabled {
  border-color: var(--profile-line);
  background: var(--profile-shelf);
  color: var(--profile-muted);
  cursor: not-allowed;
  opacity: 0.64;
}

.profile-action--disabled:hover,
.profile-action--disabled:focus-visible,
.profile-action:disabled:hover,
.profile-action:disabled:focus-visible {
  background: var(--profile-shelf);
}

.profile-receipt-link {
  align-self: center;
  justify-self: center;
  color: var(--profile-accent-dark);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.profile-action--danger {
  border-color: #a34242;
  background: #a34242;
}

.profile-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.profile-form__inline {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.profile-form__inline label {
  color: var(--profile-ink);
  font-weight: 700;
  white-space: nowrap;
}

.profile-form__inline .profile-action {
  min-width: 84px;
}

.profile-auth-form {
  margin-top: 0;
}

.profile-auth-form__field {
  display: grid;
  gap: 7px;
}

.profile-auth-form__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.profile-form input[type="email"],
.profile-auth-form input {
  width: 100%;
  margin: 0;
  border: 1px solid var(--profile-line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--profile-ink);
}

.profile-form__help {
  font-size: 0.9rem;
}

.profile-form__help a {
  color: var(--profile-accent-dark);
  font-weight: 700;
}

.profile-auth-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.profile-theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.profile-theme-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--profile-line);
  border-radius: 8px;
  background: var(--profile-page);
  color: var(--profile-ink);
  font: inherit;
  line-height: 1.1;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.profile-theme-option:hover,
.profile-theme-option:focus-visible,
.profile-theme-option.is-active {
  border-color: var(--profile-line-strong);
  background: var(--profile-shelf);
  outline: none;
}

.profile-theme-option__swatch {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid rgba(30, 26, 22, 0.24);
}

.profile-theme-option__swatch--wood {
  background: linear-gradient(135deg, #8c5f38, #2b1b12 62%, #6f8b55);
}

.profile-theme-option__swatch--light {
  background: linear-gradient(135deg, #fff9ec, #c7b28f);
}

.profile-theme-option__swatch--amber {
  background: linear-gradient(135deg, #ffe7a6, #b8792b);
}

.profile-theme-option__swatch--dark {
  background: linear-gradient(135deg, #9aa2ad, #101215);
}

.profile-note {
  padding: 12px 14px;
}

.profile-note__quote {
  margin: 0;
  color: var(--profile-ink);
  font-size: 1rem;
  line-height: 1.5;
}

.profile-note__meta {
  margin-top: 6px;
  font-size: 0.84rem;
}

.profile-tip-list {
  margin-top: 12px;
}

.profile-tip h3 {
  margin-bottom: 6px;
}

.profile-legal-content {
  color: var(--profile-ink);
  line-height: 1.68;
}

.profile-legal-content > *:first-child {
  margin-top: 0;
}

.profile-legal-content > *:last-child {
  margin-bottom: 0;
}

.profile-legal-content h2,
.profile-legal-content h3 {
  line-height: 1.12;
  margin: 1.5rem 0 0.7rem;
}

.profile-legal-content p,
.profile-legal-content li {
  color: var(--profile-muted);
}

@media (max-width: 860px) {
  .profile-shell {
    grid-template-columns: 1fr;
    gap: 12px;
    min-height: auto;
  }

  .profile-sections {
    position: static;
  }

  .profile-sections__inner,
  .profile-panel--main {
    padding: 14px;
  }

  .profile-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .profile-nav__button {
    min-height: 72px;
    padding: 10px;
  }

  .profile-nav__label {
    font-size: 0.92rem;
  }

  .profile-nav__meta {
    font-size: 0.72rem;
    line-height: 1.25;
  }
}

@media (max-width: 700px) {
  .profile-sections__title {
    font-size: 1rem;
  }

  .profile-sections__intro {
    font-size: 0.9rem;
  }

  .profile-section__header h2 {
    font-size: 1.55rem;
  }

  .profile-card__header {
    flex-direction: column;
  }

  .profile-book {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
    padding: 13px 14px;
  }

  .profile-book__cover {
    width: 40px;
    height: 58px;
  }

  .profile-book__actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
    min-width: 0;
  }

  .profile-book__version {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .profile-book__version .profile-status-chip {
    justify-self: start;
  }

  .profile-auth-form__actions {
    flex-direction: column;
  }

  .profile-action {
    width: 100%;
  }

  .profile-form__inline {
    grid-template-columns: 1fr;
  }

  .profile-form__inline label {
    white-space: normal;
  }

  .profile-theme-grid {
    grid-template-columns: 1fr;
  }
}
