:root {
  --bg: #f6efe6;
  --bg-warm: #eadcc8;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --panel-soft: rgba(255, 247, 238, 0.88);
  --border: rgba(70, 52, 33, 0.11);
  --text: #23180e;
  --muted: #6f604f;
  --shadow: 0 24px 60px rgba(115, 80, 34, 0.12);
  --shadow-soft: 0 16px 34px rgba(115, 80, 34, 0.08);
  --accent: #ff7a30;
  --accent-dark: #bb4c14;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 184, 108, 0.28), transparent 30%),
    radial-gradient(circle at top right, rgba(255, 219, 190, 0.5), transparent 32%),
    linear-gradient(180deg, #fbf7f2 0%, var(--bg) 45%, #efe3d4 100%);
}

body {
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.home-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.page-header,
.hero-panel,
.install-panel,
.shelf-panel,
.list-panel,
.reader-book-card,
.reader-header,
.reader-sidebar,
.frame-shell,
.modal-card {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.page-header,
.hero-panel,
.install-panel,
.shelf-panel,
.list-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
}

.page-header h1,
.hero-panel h2,
.section-head h2,
.modal-head h2,
.reader-header h1,
.reader-book-card h2 {
  margin: 0;
  letter-spacing: -0.03em;
}

.page-header h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.eyebrow,
.book-type,
.featured-label,
.sidebar-label,
.hero-kicker {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.header-copy,
.hero-copy p,
.section-copy,
.reader-copy,
.reader-tip,
.reader-book-card p,
.install-copy p,
.book-tile p,
.sidebar-note {
  color: var(--muted);
  line-height: 1.6;
}

.header-actions,
.hero-actions,
.card-actions,
.modal-actions,
.toolbar,
.meta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.9fr);
  gap: 18px;
  margin-top: 18px;
  padding: 22px;
}

.hero-copy h2 {
  font-size: clamp(2rem, 3.8vw, 3rem);
  margin: 10px 0 14px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  color: var(--muted);
}

.featured-card {
  position: relative;
  overflow: hidden;
  display: flex;
  gap: 18px;
  min-height: 100%;
  padding: 24px;
  border-radius: 24px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--book-accent) 18%, white 82%), rgba(255,255,255,0.86)),
    var(--panel-strong);
  border: 1px solid rgba(255,255,255,0.42);
  box-shadow: var(--shadow-soft);
}

.featured-card::after {
  content: "";
  position: absolute;
  inset: auto -30% -40% 20%;
  height: 220px;
  background: radial-gradient(circle, color-mix(in srgb, var(--book-accent) 26%, transparent) 0%, transparent 66%);
  pointer-events: none;
}

.featured-cover,
.book-cover,
.list-cover {
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--book-accent) 72%, white 28%) 0%, color-mix(in srgb, var(--book-accent) 50%, black 20%) 100%);
  color: white;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 18px 30px rgba(70, 45, 22, 0.18);
}

.featured-cover,
.book-cover {
  border-radius: 20px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.featured-cover {
  width: 116px;
  height: 156px;
  font-size: 1.45rem;
}

.featured-body {
  position: relative;
  z-index: 1;
}

.featured-body h3 {
  margin: 10px 0;
  font-size: 1.6rem;
}

.featured-meta {
  margin-top: 16px;
  color: var(--accent-dark);
  font-weight: 700;
}

.install-panel,
.shelf-panel,
.list-panel {
  margin-top: 16px;
  padding: 18px 22px;
}

.install-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255, 239, 223, 0.92));
}

.install-note {
  font-size: 0.95rem;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-head.compact {
  margin-bottom: 12px;
}

.toolbar {
  margin-bottom: 14px;
}

.search-input,
.reader-settings-grid select,
.reader-settings-grid input[type="range"],
.book-form input,
.book-form textarea {
  width: 100%;
  border: 1px solid rgba(70, 52, 33, 0.12);
  background: rgba(255,255,255,0.82);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
}

.search-input {
  min-width: min(100%, 320px);
  flex: 1 1 320px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.book-tile {
  --book-accent: var(--accent);
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,250,245,0.84));
  border: 1px solid rgba(70, 52, 33, 0.1);
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.book-cover {
  width: 72px;
  height: 104px;
  font-size: 1.02rem;
  margin-bottom: 14px;
}

.book-cover.large {
  width: 94px;
  height: 132px;
  font-size: 1.3rem;
}

.book-tile h3 {
  margin: 8px 0 6px;
  font-size: 1.12rem;
}

.book-foot {
  color: var(--accent-dark);
  font-size: 0.88rem;
  font-weight: 700;
  min-height: 1.4em;
  margin-bottom: 12px;
}

.book-tile p {
  font-size: 0.94rem;
  min-height: 4.6em;
  margin: 0 0 10px;
}

.is-clickable {
  cursor: pointer;
}

.book-tile.is-clickable:hover,
.book-tile.is-clickable:focus-visible,
.featured-card.is-clickable:hover,
.featured-card.is-clickable:focus-visible,
.list-row.is-clickable:hover,
.list-row.is-clickable:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(191, 83, 24, 0.2);
  box-shadow: 0 18px 36px rgba(115, 80, 34, 0.12);
}

.book-list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255,255,255,0.76);
  border: 1px solid var(--border);
  border-radius: 18px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.list-open {
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.list-cover {
  --book-accent: var(--accent);
  width: 44px;
  height: 60px;
  border-radius: 12px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.list-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-copy strong {
  font-size: 1rem;
}

.list-copy span,
.list-meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 999px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.static-btn {
  pointer-events: none;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.icon-btn:hover,
.section-btn:hover,
.term-btn:hover,
.switcher-item:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, #ff8d4d, var(--accent-dark));
  color: white;
  box-shadow: 0 14px 22px rgba(191, 83, 24, 0.2);
}

.secondary-btn {
  background: rgba(255,255,255,0.88);
  color: var(--text);
  border: 1px solid var(--border);
}

.ghost-btn,
.icon-btn {
  background: rgba(255,255,255,0.55);
  color: var(--text);
  border: 1px solid rgba(70, 52, 33, 0.09);
}

.compact-btn {
  padding: 10px 14px;
  font-size: 0.92rem;
}

.stack {
  flex-direction: column;
}

.empty-state {
  padding: 24px;
  border-radius: 20px;
  background: rgba(255,255,255,0.65);
  color: var(--muted);
  border: 1px dashed rgba(70, 52, 33, 0.18);
}

.empty-state.compact {
  padding: 16px;
}

.code-inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.94em;
  padding: 0.18rem 0.35rem;
  background: rgba(73, 42, 13, 0.08);
  border-radius: 8px;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(31, 22, 12, 0.36);
  z-index: 20;
}

.modal-shell.hidden {
  display: none;
}

.modal-card {
  width: min(100%, 620px);
  padding: 24px;
  background: rgba(255,255,255,0.96);
  border-radius: 28px;
  border: 1px solid rgba(70, 52, 33, 0.12);
  box-shadow: 0 30px 60px rgba(53, 35, 16, 0.22);
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  font-size: 1.6rem;
  line-height: 1;
}

.book-form {
  display: grid;
  gap: 16px;
}

.book-form label {
  display: grid;
  gap: 8px;
}

.book-form span {
  font-weight: 700;
}

.book-form textarea {
  resize: vertical;
}

.reader-settings-grid select {
  appearance: none;
}

.reader-settings-grid input[type="range"] {
  padding: 10px 0;
  box-shadow: none;
  background: transparent;
}

.form-row {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-help {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 242, 227, 0.88);
  color: var(--muted);
  border: 1px solid rgba(70, 52, 33, 0.08);
}

.reader-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: 100vh;
}

body[data-reader-theme="night"] {
  --panel: rgba(22, 24, 29, 0.92);
  --panel-strong: rgba(22, 24, 29, 0.97);
  --panel-soft: rgba(17, 19, 23, 0.94);
  --border: rgba(255, 244, 228, 0.1);
  --text: #f5efe6;
  --muted: #cabfb0;
  background:
    radial-gradient(circle at top left, rgba(255, 164, 88, 0.12), transparent 30%),
    linear-gradient(180deg, #111317 0%, #171a20 100%);
}

.reader-sidebar {
  background: linear-gradient(180deg, var(--panel-strong), var(--panel-soft));
  border-right: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.sidebar-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.reader-book-card {
  --book-accent: var(--accent);
  padding: 20px;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--panel-strong), color-mix(in srgb, var(--book-accent) 10%, white 90%));
  border: 1px solid rgba(70, 52, 33, 0.1);
  box-shadow: var(--shadow-soft);
}

.reader-book-card h2 {
  margin: 14px 0 8px;
  font-size: 1.35rem;
}

.reader-settings-panel {
  background: rgba(255,255,255,0.75);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
}

.reader-settings-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 700;
}

.reader-settings-panel summary::-webkit-details-marker {
  display: none;
}

.reader-settings-panel[open] summary {
  border-bottom: 1px solid var(--border);
}

.reader-settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 14px 18px 18px;
}

.reader-settings-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.94rem;
}

.reader-settings-grid label span {
  font-weight: 700;
}

.sidebar-group {
  display: grid;
  gap: 10px;
}

.library-switcher,
.section-list,
.term-list {
  display: grid;
  gap: 8px;
}

.switcher-item,
.section-btn,
.term-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.68);
  color: var(--text);
  border: 1px solid rgba(70, 52, 33, 0.09);
}

.switcher-item.active {
  background: rgba(255,255,255,0.94);
  border-color: rgba(191, 83, 24, 0.22);
  box-shadow: inset 0 0 0 1px rgba(191, 83, 24, 0.12);
}

.compact-search {
  min-width: 0;
}

.reader-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
}

.reader-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow-soft);
}

.reader-header h1 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.reader-tip {
  max-width: 300px;
  font-size: 0.94rem;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.frame-shell {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow-soft);
}

iframe {
  width: 100%;
  min-height: calc(100vh - 120px);
  border: 0;
  border-radius: 18px;
  background: white;
}

@media (max-width: 1060px) {
  .reader-shell {
    grid-template-columns: 1fr;
  }

  .reader-sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .install-panel,
  .page-header,
  .section-head,
  .reader-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .reader-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .home-shell,
  .reader-main {
    padding: 18px 14px 32px;
  }

  .page-header,
  .hero-panel,
  .install-panel,
  .shelf-panel,
  .list-panel,
  .reader-header {
    padding: 20px;
    border-radius: 22px;
  }

  .list-row {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .reader-settings-grid {
    grid-template-columns: 1fr;
  }

  iframe {
    min-height: 72vh;
  }
}
