@font-face {
  font-family: Manrope;
  src: url('/assets/vendor/manrope/Manrope-variable.ttf') format('truetype');
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}

:root {
  font-family: Manrope, system-ui, sans-serif;
  color: #302839;
  background: #fff;
  font-size: 18px;
  line-height: 1.55;
  font-synthesis: none;
  --canvas: #f7f4fc;
  --surface: #fff;
  --ink: #302839;
  --muted: #665d73;
  --accent: #7046b8;
  --accent-hover: #60399f;
  --accent-soft: #f5f0fc;
  --line: #e8e3f1;
  --warning: #79530c;
  --warning-bg: #fbf1d8;
  --danger: #a03b4a;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
button, select, summary { cursor: pointer; }
button { color: var(--surface); background: var(--accent); border: 1px solid var(--accent); border-radius: 9px; padding: 12px 23px; min-height: 48px; font-weight: 650; line-height: 1.4; }
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: .58; cursor: wait; }
button.secondary { background: var(--surface); color: var(--accent); border-color: #b8a4d9; }
button.secondary:hover { background: var(--accent-soft); border-color: var(--accent); }
button.text-button { background: transparent; color: var(--muted); border-color: transparent; padding: 9px 12px; }
button.text-button:hover { color: var(--accent); background: var(--accent-soft); }
button.danger { color: var(--danger); background: var(--surface); border-color: #d6a3ac; }
button.danger:hover { background: #fff2f3; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid #9874d0; outline-offset: 4px; }
input, select, textarea { color: var(--ink); background: var(--surface); border: 1px solid #cfc5de; border-radius: 8px; padding: 12px 15px; min-height: 48px; max-width: 100%; }
input, textarea { width: 100%; }
textarea { resize: vertical; min-height: 88px; }
input::placeholder, textarea::placeholder { color: #8a8197; opacity: 1; }
label { display: block; margin: 16px 0 8px; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.25; }
h1, h2 { letter-spacing: -.035em; }
h1, h2 { font-size: 30px; font-weight: 750; }
h3 { font-size: 21px; letter-spacing: -.025em; }
h4 { font-size: 17px; font-weight: 750; }
ul { padding-left: 22px; }
li + li { margin-top: 6px; }
.muted, .form-hint { color: var(--muted); }
.form-hint { font-size: 14px; margin-top: 12px; line-height: 1.6; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 200; top: 8px; left: 8px; padding: 12px 20px; background: white; transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.app-header { min-height: 88px; background: var(--canvas); display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 3.5%; }
.brand { display: inline-flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; font-size: 28px; line-height: 1.25; font-weight: 800; letter-spacing: -.045em; flex-shrink: 0; }
.brand-icon, .queue-arrow { filter: invert(32%) sepia(46%) saturate(1826%) hue-rotate(231deg) brightness(87%) contrast(85%); }
.parent-nav { align-self: stretch; display: flex; gap: 26px; align-items: stretch; }
.parent-nav button { position: relative; padding: 20px 0; border: 0; border-radius: 0; font-weight: 550; color: var(--muted); background: transparent; white-space: nowrap; }
.parent-nav button:hover, .parent-nav button[aria-current='page'] { color: var(--accent); }
.parent-nav button[aria-current='page'] { font-weight: 750; }
.parent-nav button[aria-current='page']::after { content: ''; position: absolute; height: 2px; bottom: 17px; left: 0; right: 0; background: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.child-switcher { display: flex; align-items: center; gap: 10px; margin: 0; }
.child-avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: #e5daf6; color: #543189; font-size: 20px; }
.child-switcher select { background: transparent; border-color: transparent; padding: 10px 22px 10px 0; max-width: 150px; font-weight: 750; }
.logout-button { font-size: 13px; }

#workspace { max-width: 1600px; margin: 0 auto; padding: 38px 3.5% 44px; min-height: calc(100vh - 150px); }
#workspace[data-view='requests'] { display: grid; grid-template-columns: minmax(280px, 32.5%) minmax(0, 1fr); align-items: start; gap: 0; }
#workspace:focus { outline: none; }
.request-queue { padding-right: 34px; min-width: 0; }
.queue-heading { margin: 0 14px 27px; }
.queue-heading h1, .queue-heading h2 { font-size: 40px; }
.queue-heading p { margin-top: 12px; color: var(--muted); max-width: 340px; }
.queue-list { display: flex; flex-direction: column; }
.queue-item { display: flex; align-items: center; gap: 18px; position: relative; text-align: left; width: 100%; background: var(--surface); color: var(--ink); border: 0; border-radius: 7px; padding: 17px 20px; min-height: 128px; font-weight: 500; }
.queue-item + .queue-item { border-top: 1px solid var(--line); }
.queue-item:hover { background: #faf8fe; border-color: var(--line); }
.queue-item.is-selected { background: var(--accent-soft); border-color: transparent; }
.queue-item.is-selected + .queue-item { border-top-color: transparent; }
.queue-copy { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; flex: 1; gap: 6px; }
.queue-title { font-size: 20px; line-height: 1.3; font-weight: 800; overflow-wrap: anywhere; }
.queue-author { color: var(--muted); font-size: 18px; line-height: 1.45; }
.queue-state { color: var(--muted); font-size: 16px; line-height: 1.45; }
.queue-state { margin-top: 5px; }
.queue-arrow { width: 16px; height: 16px; flex-shrink: 0; }
.queue-archive { margin: 22px 14px; color: var(--muted); }
.queue-archive > summary { min-height: 44px; padding: 10px 0; }
.queue-archive .queue-item { min-height: 100px; padding-left: 6px; padding-right: 6px; }
.queue-archive .cover-small { width: 52px; height: 68px; }

.book-cover { display: block; flex-shrink: 0; overflow: hidden; background: var(--canvas); border-radius: 5px; }
.book-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-small { width: 76px; height: 100px; }
.cover-large { width: clamp(175px, 19vw, 264px); aspect-ratio: 3 / 4; }
.cover-large:not(.cover-fallback) { background: var(--surface); }
.cover-large img { object-fit: contain; }
.book-cover.cover-fallback { padding: 20px; opacity: .7; }
.book-cover.cover-fallback img { object-fit: contain; }
.review-view { min-width: 0; }
body[data-view='requests'] .review-view { border-left: 1px solid var(--line); padding-left: 38px; }
.book-detail { width: 100%; }
.book-hero { display: flex; gap: 42px; align-items: flex-start; }
.book-info { flex: 1; min-width: 0; padding-top: 30px; }
.book-title { font-size: clamp(26px, 2.45vw, 36px); font-weight: 800; letter-spacing: -.035em; overflow-wrap: anywhere; }
.book-author { margin-top: 12px; font-size: 25px; line-height: 1.4; }
.badge { display: inline-block; margin-top: 18px; padding: 8px 17px; border-radius: 8px; background: var(--warning-bg); color: var(--warning); font-size: 17px; font-weight: 550; }
.badge.approved { background: #edf5ef; color: #365940; }
.badge.rejected { background: #faecee; color: #893645; }
.child-note { margin-top: 30px; }
.child-note p:first-child { font-size: 16px; color: var(--muted); margin-bottom: 8px; }
.child-note p:last-child { font-size: 21px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.analysis-section { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 22px; }
.analysis-section h3 { margin-bottom: 16px; }
.analysis-section h4 { margin: 20px 0 8px; }
.analysis-section p + p { margin-top: 5px; }
.analysis-section > p { color: var(--muted); }
.analysis-details { margin-top: 18px; }
.analysis-details > summary { background: var(--accent-soft); border-radius: 7px; color: var(--muted); padding: 14px 20px; min-height: 50px; }
.analysis-details[open] > summary { margin-bottom: 16px; }
.analysis-details > :not(summary) { margin-left: 12px; margin-right: 12px; }
.analysis-details button { margin-top: 14px; }
.analysis-details details { margin: 16px 12px; }
.analysis-details details summary { min-height: 44px; padding: 10px 0; }
.decision-section { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 20px; }
.decision-section h3 { margin-bottom: 10px; }
.decision-section label { color: var(--muted); margin-top: 12px; font-size: 17px; }
.decision-actions { display: flex; gap: 18px; margin-top: 20px; }
.decision-actions button { min-width: 210px; }
.decision-history { margin-top: 20px; color: var(--muted); font-size: 14px; }
.decision-history summary { min-height: 44px; padding: 10px 0; }
.decision-history p { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }
.warning { border-left: 3px solid #d6b359; padding: 12px 16px; margin: 18px 0; background: #fffbf1; color: var(--warning); border-radius: 0 5px 5px 0; }
.empty-state, .loading-state { padding: 42px 22px; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin-bottom: 10px; }
.empty-state p { max-width: 420px; }
.empty-state button, .loading-state button { margin-top: 22px; }
.row { display: flex; flex-wrap: wrap; gap: 18px; }
.form-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 24px; }

body:not([data-view='requests']) .review-view, .onboarding-view, .privacy-view { max-width: 1140px; margin: 0 auto; }
.view-heading { margin: 0 0 32px; }
.view-heading p { color: var(--muted); margin-top: 12px; }
.view-heading button { margin-top: 16px; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 44px 32px; }
.library-book { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.library-book-info { display: grid; grid-template-rows: auto 1fr auto auto; justify-items: start; flex: 1; width: 100%; }
.library-book .book-cover { width: 150px; height: 198px; margin-bottom: 16px; }
.library-book h3 { font-size: 18px; line-height: 1.35; margin-bottom: 7px; }
.library-book p { color: var(--muted); font-size: 14px; }
.library-book button { width: 100%; margin: 16px 0 0; padding: 11px 14px; font-size: 15px; line-height: 1.4; white-space: normal; overflow-wrap: break-word; }
.library-grid + button { margin-top: 24px; }
.profile-summary { max-width: 780px; padding: 26px 0 28px; }
.profile-facts { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px 24px; margin: 22px 0 26px; }
.profile-facts dt { color: var(--muted); font-size: 14px; }
.profile-facts dd { margin: 0; overflow-wrap: anywhere; }
.profile-summary p { margin: 8px 0; }
.settings-section { border-top: 1px solid var(--line); padding: 26px 0; }
.settings-section h3 { margin-bottom: 12px; }
.settings-section p { color: var(--muted); margin: 10px 0; max-width: 660px; }
.settings-section button + button { margin-left: 12px; }
.device-list { margin: 18px 0; }
.device-list > * { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding: 14px 0; max-width: 780px; }
.profile-form, .pair-form { max-width: 680px; }
.profile-form label, .pair-form label { color: var(--muted); margin-top: 20px; }
.profile-form select { width: 100%; padding-right: 44px; appearance: none; background-image: url('/assets/vendor/phosphor/caret-down.svg'); background-repeat: no-repeat; background-position: right 16px center; background-size: 16px; }
.profile-form h3 { margin: 30px 0 10px; }
.onboarding-view { max-width: 640px; padding-top: 42px; }
.onboarding-view p { margin: 16px 0; color: var(--muted); }
.onboarding-view form { max-width: 440px; }
.onboarding-view form button { margin-top: 22px; }
.privacy-view h2 { margin-bottom: 18px; }
.privacy-view h3 { margin: 28px 0 12px; }
.privacy-view p { color: var(--muted); margin-bottom: 18px; max-width: 680px; }
.privacy-view button { margin: 8px 12px 8px 0; }
.deletion-reference { overflow-wrap: anywhere; }
code { display: block; padding: 20px; margin: 22px 0; background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; font-family: ui-monospace, monospace; font-size: 17px; overflow-wrap: anywhere; }

.login-view { width: min(560px, 100%); margin: 8vh auto 0; }
.login-context { color: var(--accent); margin-bottom: 18px; font-weight: 650; }
.login-view h1 { font-size: clamp(32px, 4vw, 48px); line-height: 1.18; font-weight: 800; }
.login-description { margin-top: 24px; color: var(--muted); font-size: 18px; line-height: 1.7; max-width: 500px; }
.login-form { max-width: 440px; margin-top: 32px; }
.login-form label { color: var(--muted); }
.login-form button { width: 100%; margin-top: 18px; }
#exchange { margin-top: 32px; }
.status-message:empty { display: none; }
.status-message:not(:empty) { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(580px, calc(100vw - 48px)); padding: 16px 22px; border: 1px solid #d9cbed; background: #faf7ff; box-shadow: 0 4px 20px #30283912; border-radius: 9px; color: var(--ink); }
.status-message:not(:empty) { display: flex; align-items: center; gap: 12px; }
.status-message button { flex-shrink: 0; min-height: 44px; }
.status-dismiss-icon { width: 18px; height: 18px; display: block; }
.app-footer { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 24px 22px; }
dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 28px; color: var(--ink); box-shadow: 0 12px 60px #30283925; }
dialog::backdrop { background: #30283955; }
dialog h2 { font-size: 24px; }
dialog form > button { margin: 24px 12px 0 0; }

@media (min-width: 1600px) {
  .app-header { padding-left: max(3.5%, calc((100vw - 1488px) / 2)); padding-right: max(3.5%, calc((100vw - 1488px) / 2)); }
}
@media (max-width: 1200px) {
  :root { font-size: 16px; }
  .app-header { flex-wrap: wrap; padding-top: 16px; gap: 6px 20px; }
  .brand { font-size: 21px; }
  .parent-nav { order: 3; width: 100%; justify-content: center; min-height: 64px; }
  .parent-nav button { padding-top: 14px; padding-bottom: 18px; }
  .parent-nav button[aria-current='page']::after { bottom: 9px; }
  .request-queue { padding-right: 20px; }
  body[data-view='requests'] .review-view { padding-left: 26px; }
  .queue-item { gap: 12px; padding: 16px 12px; }
  .queue-title { font-size: 16px; }
  .queue-author, .queue-state { font-size: 14px; }
  .cover-small { width: 60px; height: 80px; }
  .book-hero { gap: 24px; }
  .book-author { font-size: 17px; }
  .book-info { padding-top: 10px; }
}
@media (max-width: 900px) {
  #workspace[data-view='requests'] { grid-template-columns: 280px minmax(0, 1fr); }
  .queue-heading { margin-left: 4px; }
  .queue-heading h1, .queue-heading h2 { font-size: 27px; }
  .book-hero { gap: 18px; }
  .cover-large { width: 125px; }
  .book-title { font-size: 25px; }
  .book-author { font-size: 16px; }
  .child-note { margin-top: 20px; }
  .child-note p:last-child { font-size: 16px; }
  .badge { font-size: 13px; padding: 6px 10px; margin-top: 12px; }
  .decision-actions { flex-wrap: wrap; gap: 12px; }
  .decision-actions button { min-width: 150px; flex: 1; }
}
@media (max-width: 720px) {
  .app-header { padding: 16px 20px 0; }
  .brand { font-size: 18px; gap: 9px; }
  .brand-icon { width: 26px; height: 26px; }
  .header-actions { gap: 0; }
  .child-avatar { width: 32px; height: 32px; font-size: 16px; }
  .child-switcher { gap: 6px; }
  .child-switcher select { max-width: 100px; padding-right: 6px; font-size: 14px; }
  .logout-button { padding: 8px !important; }
  .parent-nav { gap: 22px; justify-content: flex-start; overflow-x: auto; margin-top: 4px; }
  .parent-nav button { font-size: 14px; flex-shrink: 0; }
  #workspace { padding: 28px 20px 32px; }
  #workspace[data-view='requests'] { display: block; }
  .request-queue { padding-right: 0; }
  .queue-heading { margin: 0 0 20px; }
  .queue-heading h1, .queue-heading h2 { font-size: 28px; }
  .queue-heading p { max-width: 100%; font-size: 14px; }
  .queue-list { flex-direction: row; overflow-x: auto; gap: 10px; padding: 4px 4px 14px; margin: 0 -4px; scroll-snap-type: x proximity; }
  .queue-list .queue-item { min-width: 245px; width: 245px; min-height: 108px; padding: 12px; border: 1px solid var(--line); scroll-snap-align: start; }
  .queue-list .queue-item.is-selected { border-color: #dfd1f1; }
  .queue-list .cover-small { width: 48px; height: 65px; }
  .queue-list .queue-copy { gap: 4px; }
  .queue-list .queue-title { font-size: 14px; }
  .queue-list .queue-author, .queue-list .queue-state { font-size: 12px; }
  .queue-list .queue-arrow { display: none; }
  .queue-archive { margin: 0 0 14px; font-size: 13px; }
  body[data-view='requests'] .review-view { border-left: 0; padding: 24px 0 0; border-top: 1px solid var(--line); }
  .book-hero { gap: 22px; }
  .cover-large { width: 115px; }
  .book-title { font-size: 24px; }
  .book-author { font-size: 15px; margin-top: 8px; }
  .book-info { padding-top: 0; }
  .child-note { margin-top: 18px; }
  .analysis-section h3, .decision-section h3 { font-size: 19px; }
  .analysis-section > p { font-size: 15px; }
  .analysis-details > summary { font-size: 15px; padding: 13px 16px; }
  .decision-actions button { min-width: 0; font-size: 15px; padding: 13px 12px; }
  .profile-facts { grid-template-columns: 110px minmax(0, 1fr); gap: 12px 18px; font-size: 14px; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 20px; }
  .library-book .book-cover { width: min(150px, 100%); height: auto; aspect-ratio: 3 / 4; }
  .library-book h3 { font-size: 16px; }
  .library-book button { padding: 11px 12px; font-size: 14px; }
  .login-view { margin-top: 5vh; }
  .login-description { font-size: 16px; }
  .settings-section button + button { margin-left: 0; margin-top: 12px; }
  .status-message:not(:empty) { right: 16px; bottom: 16px; max-width: calc(100vw - 32px); font-size: 14px; padding: 14px 18px; }
}
@media (max-width: 420px) {
  .app-header { gap: 12px 0; }
  .brand { font-size: 17px; }
  .header-actions { width: 100%; justify-content: space-between; }
  .parent-nav { gap: 18px; min-height: 58px; }
  .book-title { font-size: 21px; }
  .book-hero { gap: 16px; }
  .cover-large { width: 100px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
