:root {
  --peach: rgb(250, 146, 112);
  --teal: rgb(114, 197, 197);
  --cream: rgb(245, 239, 232);
  --ink: rgb(29, 29, 31);
  --muted: rgb(105, 112, 112);
  --line: rgb(226, 221, 216);
  --surface: rgb(255, 255, 255);
  --soft: rgb(242, 242, 247);
  --danger: rgb(255, 59, 48);
  --shadow: 0 14px 34px rgba(35, 31, 27, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  padding: 18px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  width: 75vw;
  max-width: 1180px;
  min-height: calc(100vh - 36px);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

body[data-view='appView'] .app-shell {
  grid-template-columns: 1fr;
}

body[data-view='appView'] .brand-panel {
  display: none;
}

body[data-view='appView'] .workspace {
  padding: 20px 22px;
}

.brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 24px;
  min-height: 100%;
  padding: 26px 24px;
  background:
    linear-gradient(rgba(245, 239, 232, 0.95), rgba(245, 239, 232, 0.86)),
    var(--cream);
  border-right: 1px solid var(--line);
}

.brand-mark,
.result-head,
.button-row,
.account-strip,
.search-form {
  display: flex;
  align-items: center;
}

.brand-mark {
  gap: 12px;
  align-self: flex-start;
}

.brand-mark img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.brand-mark strong {
  display: block;
  font-size: 1.02rem;
}

.brand-mark span {
  font-size: 0.88rem;
}

.brand-mark span,
.message,
.section-heading p,
.result-head p,
.brand-copy p {
  color: var(--muted);
}

.book-art {
  width: min(90%, 180px);
  align-self: center;
  object-fit: contain;
}

.brand-copy h1 {
  max-width: 10ch;
  margin: 0 0 14px;
  font-size: 1.75rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.brand-copy p {
  max-width: 190px;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.auth-view,
.age-view,
.main-view {
  min-height: calc(100vh - 84px);
}

.auth-view,
.age-view {
  display: grid;
  place-items: center;
}

.auth-box,
.age-panel,
.definition-panel,
.examples-panel,
.search-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-box,
.age-panel {
  width: min(100%, 520px);
  padding: 24px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 16px;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-tab {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.auth-tab[aria-pressed='true'] {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(35, 31, 27, 0.08);
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading p,
.eyebrow {
  display: block;
  margin: 0 0 6px;
  color: var(--peach);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-heading h2,
.section-heading h3,
.topbar h2 {
  margin: 0;
}

.section-heading h2 {
  font-size: 1.82rem;
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  padding: 0 14px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(114, 197, 197, 0.2);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.text-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  color: white;
  background: var(--peach);
}

.secondary-button {
  color: var(--ink);
  background: rgba(114, 197, 197, 0.16);
  border-color: rgba(114, 197, 197, 0.6);
}

.ghost-button {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.icon-button {
  color: var(--teal);
  background: var(--surface);
  border-color: var(--teal);
  min-width: 54px;
}

.text-button {
  min-height: auto;
  justify-self: end;
  padding: 2px 0;
  color: var(--teal);
  background: transparent;
}

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

.button-row button {
  width: 100%;
}

#toggleAuthMode {
  grid-column: 1 / -1;
}

.secondary-button img {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  vertical-align: middle;
}

.message {
  min-height: 22px;
  margin: 10px 0 0;
  line-height: 1.45;
}

.message:empty {
  display: none;
}

.message.error {
  color: var(--danger);
}

.age-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.age-option {
  display: grid;
  gap: 10px;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px;
  text-align: left;
}

.age-option[aria-pressed='true'] {
  border-color: var(--peach);
  background: rgba(250, 146, 112, 0.13);
}

.age-option img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.age-option strong {
  font-size: 1rem;
}

.main-view {
  display: grid;
  align-content: start;
  gap: 18px;
}

body[data-view='appView'] .main-view {
  width: min(100%, 1240px);
  min-height: calc(100vh - 76px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 16px;
  margin: 0 auto;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-height: 42px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

body[data-view='appView'] .topbar h2 {
  font-size: 1.45rem;
}

body[data-view='appView'] .eyebrow,
body[data-view='appView'] .section-heading p {
  margin-bottom: 3px;
  font-size: 0.72rem;
}

.account-strip {
  gap: 10px;
  justify-content: flex-end;
  margin-left: auto;
}

.account-strip .ghost-button,
.account-strip select {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.95rem;
}

.account-strip select {
  width: 160px;
}

.search-band {
  padding: 18px;
}

body[data-view='appView'] .search-band {
  width: min(100%, 720px);
  align-self: center;
  justify-self: center;
  padding: 38px 42px 34px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(35, 31, 27, 0.08);
}

.search-hero {
  display: grid;
  justify-items: center;
  margin-bottom: 30px;
}

.search-hero img {
  width: min(54%, 210px);
  height: auto;
  object-fit: contain;
}

.search-form {
  gap: 10px;
}

.search-form input {
  flex: 1;
  font-size: 1.1rem;
}

body[data-view='appView'] input,
body[data-view='appView'] select,
body[data-view='appView'] .primary-button,
body[data-view='appView'] .secondary-button,
body[data-view='appView'] .ghost-button,
body[data-view='appView'] .icon-button {
  min-height: 40px;
}

body[data-view='appView'] .search-form input {
  font-size: 1rem;
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.55fr);
  gap: 18px;
}

.definition-panel,
.examples-panel {
  padding: 22px;
}

body[data-view='appView'] .definition-panel,
body[data-view='appView'] .examples-panel {
  padding: 14px 16px;
  box-shadow: 0 8px 22px rgba(35, 31, 27, 0.07);
}

body[data-view='appView'] .saved-section .section-heading {
  display: none;
}

body[data-view='appView'] .saved-section {
  position: absolute;
  top: 54px;
  right: 0;
  z-index: 5;
  width: min(100%, 360px);
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

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

body[data-view='appView'] .result-head {
  margin-bottom: 12px;
}

.result-head h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.definition-list,
.example-list,
.bookmark-list {
  display: grid;
  gap: 12px;
}

.definition-item,
.example-item,
.bookmark-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

body[data-view='appView'] .definition-item,
body[data-view='appView'] .example-item,
body[data-view='appView'] .bookmark-item {
  padding: 12px;
}

.definition-item strong {
  display: block;
  color: var(--teal);
  margin-bottom: 8px;
}

.definition-item p,
.example-item p,
.bookmark-item p {
  margin: 0;
  line-height: 1.55;
}

.example-item {
  background: rgba(245, 239, 232, 0.7);
}

.bookmark-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.bookmark-item button {
  min-height: 36px;
}

body[data-view='appView'] .saved-section .bookmark-list {
  gap: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
}

body[data-view='appView'] .saved-section .bookmark-item {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

body[data-view='appView'] .saved-section .bookmark-item:first-child {
  border-top: 0;
}

body[data-view='appView'] .saved-section .empty-state {
  margin: 0;
  padding: 14px;
}

.empty-state {
  color: var(--muted);
  margin: 0;
}

[hidden] {
  display: none !important;
}

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

  .brand-panel {
    min-height: auto;
    justify-content: flex-start;
    gap: 0;
    padding: 14px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-mark img {
    width: 32px;
    height: 32px;
  }

  .brand-mark span {
    font-size: 0.82rem;
  }

  .book-art {
    display: none;
  }

  .brand-copy {
    display: none;
  }

  .workspace {
    padding: 12px;
  }

  .auth-view,
  .age-view,
  .main-view {
    min-height: auto;
  }

  .auth-view,
  .age-view {
    display: block;
  }

  .auth-box,
  .age-panel {
    width: 100%;
    padding: 16px;
    box-shadow: 0 8px 22px rgba(35, 31, 27, 0.08);
  }

  .section-heading {
    margin-bottom: 12px;
  }

  .section-heading h2 {
    font-size: 1.55rem;
  }

  input,
  select,
  .primary-button,
  .secondary-button,
  .ghost-button,
  .icon-button {
    min-height: 40px;
  }

  .auth-tabs {
    margin-bottom: 12px;
  }

  .secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 8px;
    white-space: nowrap;
    font-size: 0.92rem;
  }

  .secondary-button img {
    flex: 0 0 auto;
    margin-right: 0;
  }

  label {
    gap: 6px;
  }

  .result-layout,
  .age-options {
    grid-template-columns: 1fr;
  }

  .topbar,
  .result-head,
  .search-form,
  .account-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .account-strip select,
  .search-form input,
  .search-form button {
    width: 100%;
  }

  body[data-view='appView'] .workspace {
    padding: 14px;
  }

  body[data-view='appView'] .main-view {
    min-height: calc(100vh - 64px);
  }

  body[data-view='appView'] .topbar,
  body[data-view='appView'] .account-strip {
    align-items: center;
    flex-direction: row;
  }

  body[data-view='appView'] .account-strip {
    flex-wrap: wrap;
  }

  body[data-view='appView'] .account-strip select,
  body[data-view='appView'] .account-strip button {
    width: auto;
  }

  body[data-view='appView'] .search-band {
    padding: 28px 16px 24px;
  }

  .search-hero img {
    width: min(68%, 170px);
  }
}

@media (max-height: 760px) and (min-width: 981px) {
  .brand-panel {
    gap: 18px;
  }

  .book-art {
    width: min(84%, 150px);
  }

  .brand-copy h1 {
    font-size: 1.45rem;
  }

  .brand-copy p {
    font-size: 0.82rem;
  }

  .auth-box,
  .age-panel {
    padding: 22px;
  }
}
