:root {
  --paper: #f8f1e7;
  --ink: #1d1b19;
  --accent: #f0704f;
  --accent-dark: #c04e38;
  --mint: #b8e2d0;
  --sky: #d6ecff;
  --shadow: rgba(17, 16, 15, 0.18);
  --panel: #ffffff;
  --panel-strong: #f7e4d0;
  --radius: 22px;
  --radius-lg: 30px;
  --mono: "Space Grotesk", "Helvetica Neue", sans-serif;
  --serif: "Fraunces", "Georgia", serif;
}

* {
  box-sizing: content-box;
}

.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;
}


html {
  background: var(--paper);
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--mono);
  color: var(--ink);
  overscroll-behavior: none;
  background: radial-gradient(circle at 20% 20%, #fff6d1 0%, transparent 55%),
    radial-gradient(circle at 80% 0%, #cfe3ff 0%, transparent 45%),
    linear-gradient(140deg, #f8c9b9 0%, #f2ecd6 50%, #dbe7f7 100%);
}

.page {
  padding: 0;
  max-width: none;
  margin: 0;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 10px 20px 0;
  gap: 16px;
}

.page-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  min-height: 12px;
}

.page-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: none;
  padding: 0;
  background: rgba(29, 27, 25, 0.25);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: width 0.2s ease, height 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.page-dot.is-active {
  width: 18px;
  height: 18px;
  background: var(--ink);
  transform: scale(1.05);
}

.page-dot-icon {
  width: 10px;
  height: 10px;
  background: #fff;
  opacity: 0;
  -webkit-mask: var(--dot-icon) center/contain no-repeat;
  mask: var(--dot-icon) center/contain no-repeat;
  transition: opacity 0.2s ease;
}

.page-dot.is-active .page-dot-icon {
  opacity: 1;
}

.page-dot:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(240, 112, 79, 0.4);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-button {
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.brand-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(240, 112, 79, 0.4);
  border-radius: 12px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.brand-title {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.3px;
  font-size: 16px;
}

.brand-subtitle {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  opacity: 0.6;
}

.layout {
  display: flex;
  gap: 0;
  align-items: flex-start;
  background: var(--paper);
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
  scroll-padding-inline: 0;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  box-shadow: 0 -18px 28px rgba(17, 16, 15, 0.22);
}

.layout::before {
  content: "";
  position: fixed;
  top: 54px;
  left: 0;
  right: 0;
  width: 100%;
  height: 8px;
  display: block;
  background: linear-gradient(to bottom, var(--paper), rgba(0, 0, 0, 0));
  pointer-events: none;
  z-index: 2;
}

.requires-key .layout {
  overflow-x: hidden;
  touch-action: pan-y;
}

.layout.is-locked {
  overflow-x: hidden;
  touch-action: pan-y;
}

.layout > * {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-x: auto;
  overscroll-behavior-y: contain;
}

.layout::-webkit-scrollbar {
  display: none;
}

.layout > * {
  flex: 0 0 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.book-panel {
  background: var(--paper);
  border-radius: 0;
  padding: 26px;
  padding-bottom: calc(26px + env(safe-area-inset-bottom));
  position: relative;
  overflow: auto;
  box-sizing: border-box;
}

.book-panel::after {
  content: none;
}

.library-panel {
  padding: 0;
  overflow: hidden;
  position: relative;
}

.library-panel {
  --library-pull: 0px;
}

.library-stack {
  height: 100%;
  width: 100%;
  position: relative;
}

.library-view {
  position: absolute;
  inset: 0;
  flex: 0 0 100%;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: none;
  padding: 26px;
  padding-bottom: calc(26px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.library-view.is-active {
  position: relative;
  opacity: 1;
  pointer-events: auto;
}

.library-hint {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  margin: -12px auto 8px;
  width: fit-content;
  max-width: 100%;
  text-align: center;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.45;
  transform: translateY(calc(var(--library-pull) * 0.12));
  transition: transform 0.2s ease, opacity 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0px;
  align-items: center;
  align-self: center;
  cursor: pointer;
}

.library-panel.is-pulling .library-hint {
  opacity: 0.7;
}

.library-hint:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.45);
  outline-offset: 4px;
}

.library-hint-label {
  line-height: 1.05;
}

.library-hint-arrow {
  letter-spacing: 2px;
  line-height: 0.9;
}

.home-library {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

.home-library + .home-library {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.home-library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.home-library-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.home-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(20px, 2.4vw, 28px);
}

.home-subtitle {
  margin: 0;
  font-size: 13px;
  opacity: 0.65;
}

.home-list {
  display: grid;
  gap: 12px;
}

.rss-feed-list {
  display: grid;
  gap: 12px;
}

.rss-feed-list.is-loading .home-item {
  opacity: 0.45;
  pointer-events: none;
}

.rss-feed-list.is-loading .home-item.is-loading {
  opacity: 1;
  pointer-events: auto;
}

.rss-feed-list.is-loading .home-item.is-loading .home-item-content {
  transform: translateY(-2px);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.14);
  border-color: rgba(0, 0, 0, 0.18);
}

.rss-item-loading-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.rss-item-loading {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: rgba(26, 102, 60, 0.85);
  animation: rssPulse 1.1s ease-in-out infinite;
}

@keyframes rssPulse {
  0% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.4;
  }
}

.rss-item-abort {
  border: 1px solid rgba(176, 70, 54, 0.45);
  border-radius: 999px;
  background: rgba(176, 70, 54, 0.12);
  color: rgba(176, 70, 54, 0.95);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 6px 10px;
}

.rss-feed-item {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  padding: 14px 16px;
  border-radius: 18px;
  display: grid;
  gap: 6px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.rss-feed-item.is-read {
  opacity: 0.65;
}

.rss-feed-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
}

.rss-feed-title a {
  color: inherit;
  text-decoration: none;
}

.rss-feed-title a:hover {
  text-decoration: underline;
}

.rss-feed-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  opacity: 0.65;
}

.rss-feed-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(26, 102, 60, 0.9);
}

.rss-feed-source {
  font-weight: 600;
}

.rss-feed-read {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 10px;
}

.rss-status {
  margin: 0;
}

.rss-status.is-error {
  color: #b04636;
}

.rss-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.rss-search-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

#rssUrlInput {
  flex: 1;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 16px;
  background: #fff;
}

#rssSearchInput {
  flex: 1;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 16px;
  background: #fff;
}

.rss-search-results {
  display: grid;
  gap: 10px;
}

.rss-attribution {
  margin: 0;
  font-size: 12px;
  opacity: 0.6;
}

.rss-attribution a {
  color: inherit;
  text-decoration: none;
}

.rss-attribution a:hover {
  text-decoration: underline;
}

.rss-search-item {
  display: grid;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.rss-search-meta {
  display: grid;
  gap: 4px;
}

.rss-search-actions {
  display: flex;
  justify-content: flex-end;
}

.rss-search-title {
  font-weight: 600;
  font-size: 14px;
}

.rss-search-url {
  font-size: 12px;
  opacity: 0.7;
  word-break: break-all;
}

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

.rss-subscription-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.rss-subscription-url {
  font-size: 13px;
  word-break: break-all;
  flex: 1 1 auto;
  min-width: 0;
}

.rss-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-basis: 100%;
}

.rss-subscription-actions {
  display: flex;
  justify-content: flex-end;
  flex-basis: 100%;
}

.rss-level {
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 6px 10px;
}

.rss-level.is-active {
  background: var(--mint);
  border-color: transparent;
  color: rgba(0, 0, 0, 0.75);
}

.rss-item-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-basis: 100%;
}

.rss-item-levels .rss-level {
  text-transform: lowercase;
  letter-spacing: 0.4px;
}

.home-item {
  position: relative;
  box-sizing: border-box;
}

.home-item-content {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  padding: 14px 16px;
  border-radius: 18px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  width: 100%;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.home-item-content.has-thumbnail {
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.rss-item-thumbnail {
  width: 86px;
  height: 86px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.rss-item-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rss-item-body {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.home-item {
  -webkit-tap-highlight-color: transparent;
}

.home-item-content:focus,
.home-item-content:focus-visible {
  outline: none;
}

.home-item-content:active {
  background: #fff;
  transform: none;
}

.home-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.06);
  flex: 0 0 auto;
}

.home-item-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.home-item-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.home-item-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.2s ease;
}

.home-item-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  font-family: var(--serif);
}

.home-item-status {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.65);
}

.home-item.is-read .home-item-status {
  background: var(--mint);
  color: rgba(0, 0, 0, 0.75);
}

.home-item.is-read .home-item-content {
  opacity: 0.72;
  background: rgba(248, 241, 231, 0.7);
  border-color: rgba(0, 0, 0, 0.04);
}

.home-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 0;
  display: none;
  flex-wrap: wrap;
}

.home-action {
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border: none;
}

.home-action.is-active {
  background: var(--mint);
  color: rgba(0, 0, 0, 0.75);
}

.home-action.delete {
  background: var(--accent);
  color: #fff;
}

.home-action.toggle {
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.7);
}

.home-item.is-read .home-action.toggle {
  background: var(--mint);
  color: rgba(0, 0, 0, 0.75);
}

.home-item.is-menu-open .home-item-actions {
  display: flex;
}

.home-list.has-active .home-item:not(.is-active) {
  opacity: 0.55;
  filter: grayscale(0.2);
  pointer-events: none;
}

.home-item.is-active .home-item-content {
  transform: translateY(-2px);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.14);
  border-color: rgba(0, 0, 0, 0.18);
  opacity: 1;
}

.home-item-excerpt {
  margin: 0;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.72);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-empty {
  margin: 0;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  opacity: 0.6;
}

.reader-view {
  display: block;
  position: relative;
  z-index: 1;
}

.reader-progress {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  transform: translate(-26px, -20px);
  width: calc(100% + 46px);
  height: 3px;
  margin: 0;
  background: transparent;
  border-radius: 999px;
  overflow: hidden;
  z-index: 6;
  opacity: 0;
}

.reader-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.05s linear;
}

.reader-panel {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.reader-panel::-webkit-scrollbar {
  display: none;
}

.reader-end {
  height: 1px;
}

.book-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  z-index: 1;
  font-family: var(--serif);
}

.book-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(26px, 3vw, 34px);
}

.book-header h1 {
  font-family: inherit;
}

.book-header h1 {
  font-size: clamp(20px, 2.3vw, 28px);
  cursor: pointer;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--mint);
  font-size: 12px;
  font-weight: 600;
}

.instructions {
  margin: 18px 0 0;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.7);
  position: relative;
  z-index: 1;
}

.api-panel {
  margin-top: 18px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  padding: 12px 14px;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(8px);
}

.api-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  opacity: 0.6;
  margin-bottom: 6px;
}

#apiKey {
  width: min(320px, 60vw);
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 16px;
  background: #fff;
}

.api-modal-body {
  display: grid;
  gap: 12px;
}

.api-modal-body #apiKey {
  width: 100%;
  box-sizing: border-box;
}

.api-key-help {
  font-size: 12px;
  opacity: 0.6;
  margin: 0;
}

.api-key-error {
  color: #b04636;
  display: none;
  opacity: 1;
}

.api-key-error.is-visible {
  display: block;
}

.api-key-help a {
  color: var(--accent);
  text-decoration: none;
  opacity: 1;
}

.api-key-help a:hover {
  text-decoration: underline;
}

.api-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.settings-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  margin: 6px 0;
}

.theme-modal-body {
  display: grid;
  gap: 16px;
}

.settings-panel .home-library {
  max-width: 720px;
  margin: 0 auto 18px;
}

.training-panel .home-library {
  max-width: 720px;
  margin: 0 auto 18px;
}

.settings-panel .settings-body {
  display: grid;
  gap: 16px;
  background: var(--panel);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 18px 30px rgba(17, 16, 15, 0.12);
}

.settings-desktop-warning {
  display: none;
  max-width: 720px;
  margin: 0 auto 16px;
  padding: 22px 24px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 72, 72, 0.2), rgba(255, 140, 0, 0.18));
  border: 1px solid rgba(255, 72, 72, 0.55);
  color: #3b0a0a;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.35px;
  text-align: center;
}

.settings-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding-bottom: 12px;
}

.training-card {
  display: grid;
  gap: 16px;
  background: var(--panel);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 18px 30px rgba(17, 16, 15, 0.12);
}

.training-progress {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.training-progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.training-list-view {
  display: grid;
  gap: 12px;
}

.training-item-status {
  margin-top: 6px;
}

.training-item-status-label {
  margin: 0;
}

.training-item-status.is-error .training-item-status-label {
  color: #b04636;
  opacity: 1;
}

.training-item-status.is-error .rss-item-loading {
  animation: none;
  color: #b04636;
}

.training-panel.is-training-active .home-library-header,
.training-panel.is-training-active .home-subtitle {
  display: none;
}

.training-detail-view {
  display: grid;
  gap: 18px;
}

.training-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.training-detail-heading {
  display: grid;
  gap: 4px;
}

.training-detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.training-detail-view.is-summary .training-detail-header {
  display: none;
}

.training-screen-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
}

.training-screen-subtitle {
  margin: 0;
  font-size: 13px;
  opacity: 0.68;
}

.training-body {
  display: grid;
  gap: 12px;
}

.training-controls {
  display: grid;
  gap: 12px;
  border-radius: 18px;
}

.training-controls .training-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.training-controls .option-button {
  min-height: 52px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 16px;
}

.training-summary {
  display: grid;
  gap: 12px;
  text-align: center;
}

.training-summary-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
}

.training-summary-score {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.training-summary-note {
  margin: 0;
  font-size: 13px;
  opacity: 0.7;
}

.training-explain-card {
  display: grid;
  gap: 8px;
}

.training-explain-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.training-explain-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.training-sentence {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.45;
  -webkit-user-select: none;
  user-select: none;
}

.training-gap {
  display: inline-block;
  min-width: 46px;
  text-align: center;
  padding: 2px 8px;
  border-bottom: 2px dashed rgba(0, 0, 0, 0.35);
  letter-spacing: 1.4px;
  font-weight: 700;
}

.training-gap.is-active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.training-answer {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  font-weight: 700;
}

.training-answer.word {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  margin: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  font-weight: 700;
}

.training-prompt {
  margin: 0;
  font-size: 14px;
  opacity: 0.75;
}

.training-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.training-gender {
  display: flex;
  align-items: center;
  gap: 8px;
}

.training-gender-value {
  font-size: 14px;
  font-weight: 600;
}

.training-feedback,
.training-status {
  margin: 0;
}

.training-feedback.is-error,
.training-status.is-error {
  color: #b04636;
}

.training-controls-card {
  display: grid;
  gap: 8px;
  padding: 4px 2px 0;
}

.training-controls-card .training-actions {
  justify-content: center;
}

.training-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

.option-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}

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

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-label {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.7;
}

.slider-value {
  font-size: 12px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.06);
  padding: 4px 8px;
  border-radius: 999px;
  min-width: 44px;
  text-align: center;
}

.size-slider {
  flex: 1;
  accent-color: var(--accent);
}

.option-button {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: transparent;
  font-weight: 700;
  font-size: 12px;
  min-width: 44px;
  text-align: center;
  cursor: pointer;
}

.option-button.active {
  background: var(--panel-strong);
  border-color: rgba(0, 0, 0, 0.1);
}

.requires-key .top-bar,
.requires-key .page-dots {
  pointer-events: none;
  opacity: 0.35;
}

.requires-key .layout > :not([data-screen="settings"]) {
  pointer-events: none;
  opacity: 0.35;
}

.requires-key .settings-panel [data-settings-section]:not([data-settings-section="core"]),
.requires-key .settings-footer {
  display: none;
}

.requires-key .settings-panel .settings-language-block {
  display: none;
}

.requires-language .top-bar,
.requires-language .page-dots {
  pointer-events: none;
  opacity: 0.35;
}

.requires-language .layout > :not([data-screen="settings"]) {
  pointer-events: none;
  opacity: 0.35;
}

.requires-language .settings-panel [data-settings-section]:not([data-settings-section="core"]),
.requires-language .settings-footer {
  display: none;
}

.requires-language .settings-panel .settings-api-block {
  display: none;
}

.reader {
  margin-top: 28px;
  font-family: var(--serif);
  font-size: clamp(18px, 2.4vw, 22px);
  line-height: var(--reader-leading, 1.45);
  word-spacing: -0.02em;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  position: relative;
  z-index: 1;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body[data-reader-font="sans"] .reader {
  font-family: var(--mono);
}

body[data-reader-font="sans"] .book-header {
  font-family: var(--mono);
}

body[data-reader-font="sans"] .story-heading {
  font-family: var(--mono);
}

body[data-reader-size] .reader {
  font-size: clamp(10px, calc(var(--reader-size, 20) * 1px), 30px);
}

.reader-cta {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.reader-status {
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(74, 171, 118, 0.16);
  color: rgba(26, 102, 60, 0.95);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.reader-status-label {
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.reader-status-lemmas {
  display: block;
  margin: 6px 0 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  opacity: 0.85;
  text-transform: none;
  color: rgba(26, 102, 60, 0.9);
}

.reader-status.is-visible {
  opacity: 1;
  transform: translateY(0);
  animation: readerStatusPop 0.45s ease;
}

@keyframes readerStatusPop {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  60% {
    opacity: 1;
    transform: translateY(-1px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.story {
  margin: 0;
}

.story-heading {
  margin: 18px 0 6px;
  font-family: var(--serif);
  font-size: 1.15em;
}

.sentence {
  display: inline;
  margin: 0;
  padding: 1px 2px;
  border-radius: 6px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background 0.2s ease;
}

.sentence.active {
  background: rgba(240, 112, 79, 0.16);
  box-shadow: 0 10px 18px rgba(29, 27, 25, 0.12);
  transform: translateY(-2px);
  padding: 0 2px;
}

.sentence.active.sentence-translation {
  padding: 0 1px;
}

.sentence.sentence-translation {
  border: 1px solid rgba(240, 112, 79, 0.45);
  box-shadow: 0 14px 22px rgba(240, 112, 79, 0.2);
}

.reader.has-active-sentence .sentence {
  pointer-events: none;
  opacity: 0.5;
}

.reader.has-active-sentence .sentence.active {
  pointer-events: auto;
  opacity: 1;
}

.word {
  display: inline;
  position: relative;
  z-index: 0;
  padding: 1px;
  margin: 0 -1px;
  border-radius: 6px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
  cursor: pointer;
  transition: transform 0.2s ease;
}

body[data-reader-hyphenation="off"] .reader,
body[data-reader-hyphenation="off"] .word {
  -webkit-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

body[data-reader-justify="justify"] .reader {
  text-align: justify;
  text-justify: inter-word;
}

.word.active {
  background: rgba(240, 112, 79, 0.2);
  box-shadow: 0 0 0 1px rgba(240, 112, 79, 0.4);
}

.word.tts-active {
  background: rgba(255, 199, 74, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 199, 74, 0.6);
}

.word.tts-fade {
  transition: transform 0.2s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.word.loading {
  animation: wordPulse 1.1s ease-in-out infinite;
  background: rgba(240, 112, 79, 0.2);
  box-shadow:
    0 0 0 0 rgba(240, 112, 79, 0.35),
    0 0 0 2px rgba(240, 112, 79, 0.12);
}

@keyframes wordPulse {
  0%,
  100% {
    background: rgba(240, 112, 79, 0.18);
    box-shadow:
      0 0 0 0 rgba(240, 112, 79, 0.2),
      0 0 0 2px rgba(240, 112, 79, 0.2);
  }
  50% {
    background: rgba(240, 112, 79, 0.35);
    box-shadow:
      0 0 0 6px rgba(240, 112, 79, 0.2),
      0 0 0 2px rgba(240, 112, 79, 0.2);
  }
}

.word.governing {
  background: rgba(29, 27, 25, 0.12);
  box-shadow: 0 0 0 1px rgba(29, 27, 25, 0.2);
}

.word.governing-gender {
  background: rgba(184, 226, 208, 0.55);
  box-shadow: 0 0 0 1px rgba(90, 130, 116, 0.4);
}

.word.governing-case {
  background: rgba(255, 210, 170, 0.6);
  box-shadow: 0 0 0 1px rgba(184, 120, 80, 0.4);
}

.word.separable {
  background: rgba(179, 201, 232, 0.55);
  box-shadow: 0 0 0 1px rgba(88, 112, 145, 0.45);
}

.panel-grammar .governing-gender,
.sheet-grammar .governing-gender,
.governing-legend .governing-gender {
  background: rgba(184, 226, 208, 0.55);
  box-shadow: inset 0 0 0 1px rgba(90, 130, 116, 0.4);
  border-radius: 6px;
  padding: 0 4px;
}

.panel-grammar .governing-case,
.sheet-grammar .governing-case,
.governing-legend .governing-case {
  background: rgba(255, 210, 170, 0.6);
  box-shadow: inset 0 0 0 1px rgba(184, 120, 80, 0.4);
  border-radius: 6px;
  padding: 0 4px;
}

.translation-panel {
  background: var(--panel);
  border-radius: 0;
  padding: 22px;
  padding-bottom: calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 24px 40px rgba(17, 16, 15, 0.18);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  top: auto;
  min-height: 320px;
}

.governing-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  opacity: 0.7;
}

.governing-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.governing-legend .legend-swatch {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel-body {
  display: grid;
  gap: 10px;
}

.panel-german {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
}

.translation-panel.is-sentence .panel-german {
  font-size: 16px;
  font-weight: 400;
}

.panel-english {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  opacity: 0.8;
}

.panel-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 999px;
}

.sentence-divider {
  margin: 6px 0 4px;
}

.sheet-divider {
  margin: 6px 0;
}

.translation-panel.is-sentence .panel-divider:not(#lemmaDiffDivider) {
  order: 1;
}

.translation-panel.is-sentence .panel-german {
  order: 0;
}

.translation-panel.is-sentence .panel-english {
  order: 2;
}

.translation-panel.is-sentence .panel-grammar,
.translation-panel.is-sentence .panel-lemma-diff,
.translation-panel.is-sentence .grammar-meta,
.translation-panel.is-sentence .governing-legend {
  order: 3;
}

.translation-panel.is-sentence #lemmaDiffDivider {
  order: 4;
}

.grammar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-size: 11px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.meta-label {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 9px;
  opacity: 0.6;
}

.meta-value {
  font-weight: 600;
}

.is-hidden {
  display: none !important;
}

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

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.45);
  display: grid;
  place-items: center;
  z-index: 6;
  padding: 24px;
}

.modal-content {
  width: min(720px, 100%);
  background: var(--panel);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2);
  display: grid;
  gap: 18px;
  max-height: 90vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

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

h2 {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 28px;
}

.mode-switch {
  display: flex;
  gap: 10px;
  background: rgba(0, 0, 0, 0.05);
  padding: 6px;
  border-radius: 999px;
}

.mode-button {
  border-radius: 999px;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid transparent;
  font-size: 13px;
}

.mode-button.active {
  background: var(--panel-strong);
  border-color: rgba(0, 0, 0, 0.1);
}

.mode-panel {
  display: grid;
  gap: 10px;
}

.mode-panel.is-hidden {
  display: none;
}

.form-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  opacity: 0.6;
}

#pasteTitle,
#pasteBody,
#promptBody {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 16px;
  background: #fff;
  box-sizing: border-box;
}

#pasteBody,
#promptBody {
  resize: vertical;
  min-height: 110px;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.scan-row {
  align-items: stretch;
}

.prompt-row {
  justify-content: space-between;
  align-items: center;
}

.prompt-row .form-label {
  margin: 0;
}

.form-row input {
  flex: 1;
  font-size: 16px;
}

.helper-text {
  font-size: 12px;
  opacity: 0.6;
  margin: 0;
}

.scan-status.is-error {
  color: #b04636;
}

.saved-section {
  display: grid;
  gap: 10px;
}

.lemma-search {
  margin-top: 2px;
  position: sticky;
  top: -20px;
  z-index: 2;
  background: var(--paper);
  padding: 6px 0 8px;
}

#lemmaSearch {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 16px;
  background: #fff;
}

.saved-title {
  margin: 0;
  font-weight: 600;
}

.learned-title {
  margin-top: 8px;
}

.saved-list {
  display: grid;
  gap: 8px;
}

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

.saved-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.04);
}

.lemma-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.04);
}

.lemma-item.is-collapsible {
  cursor: pointer;
}

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

.lemma-metrics {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lemma-name {
  font-weight: 600;
  font-family: var(--serif);
  hyphens: auto;
  overflow-wrap: anywhere;
}

.lemma-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.lemma-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.lemma-toggle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.lemma-originals {
  display: none;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0, 0, 0, 0.15);
}

.lemma-item.is-expanded .lemma-originals {
  display: grid;
}

.lemma-original {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}

.lemma-original-word {
  font-weight: 600;
}

.lemma-original-translation {
  opacity: 0.7;
}

.lemma-original-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 6px;
}

.lemma-delete {
  border-color: rgba(240, 112, 79, 0.4);
  color: var(--accent);
}

.empty-state {
  margin: 0;
  font-size: 13px;
  opacity: 0.6;
}

.saved-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.saved-actions .ghost.is-feedback {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.2);
}

#openLemmas {
  position: relative;
}

#openLemmas::after {
  content: attr(data-badge);
  position: absolute;
  top: -6px;
  right: -10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#openLemmas[data-badge]:not([data-badge="0"])::after {
  opacity: 1;
}

.saved-item button {
  padding: 6px 12px;
  font-size: 12px;
}

.panel-grammar {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  opacity: 0.75;
}

.panel-lemma-diff {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  opacity: 0.7;
}

.panel-footer {
  display: flex;
  gap: 10px;
}

button {
  border: none;
  font-family: var(--mono);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
}

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

.mini {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  display: block;
}

.circle {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.danger {
  background: #d1463f;
  color: #fff;
  border: none;
}

@media (hover: hover) and (pointer: fine) {
  .sentence:hover {
    background: rgba(240, 112, 79, 0.12);
  }

  .word:hover {
    background: rgba(240, 112, 79, 0.2);
    box-shadow: 0 0 0 2px rgba(240, 112, 79, 0.4);
    transform: translateY(-2px);
  }

  .home-item:hover .home-item-content {
    transform: translateY(-2px);
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.16);
  }

  .primary:hover {
    background: var(--accent-dark);
  }

  .danger:hover {
    background: #b63a35;
  }
}

.ghost {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.2);
  color: var(--ink);
}

.bottom-sheet {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: none;
  z-index: 5;
  animation: rise 0.4s ease;
  transition: transform 0.2s ease;
  touch-action: pan-y;
  perspective: 1200px;
}

.bottom-sheet-inner {
  display: grid;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
  min-height: 0;
  width: 100%;
}

.bottom-sheet-face {
  grid-area: 1 / 1;
  transition: opacity 0.2s ease;
  backface-visibility: hidden;
  background: var(--panel);
  border-radius: 24px;
  padding: 16px 18px 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  box-sizing: border-box;
}

.bottom-sheet-front {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.bottom-sheet-back {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transform: rotateY(180deg);
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

.bottom-sheet.is-ask {
  top: auto;
  bottom: calc(12px + env(safe-area-inset-bottom));
  height: calc(100dvh - (12px + env(safe-area-inset-top)) - (12px + env(safe-area-inset-bottom)));
}

.bottom-sheet.is-ask .bottom-sheet-inner {
  height: 100%;
  transform: rotateY(180deg);
}

.bottom-sheet.is-ask .bottom-sheet-front {
  opacity: 0;
  pointer-events: none;
}

.bottom-sheet.is-ask .bottom-sheet-back {
  min-height: 100%;
  opacity: 1;
  pointer-events: auto;
  padding-bottom: 18px;
}

.sheet-back-close {
  margin-left: auto;
}

.sheet-ask-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

.sheet-ask-title {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  opacity: 0.7;
}

.sheet-ask-context {
  margin: 0;
  padding-bottom: 15px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-line;
  opacity: 0.8;
  width: 100%;
}

.sheet-chat-empty {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.sheet-chat-empty.is-hidden {
  display: none;
}

.sheet-chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  width: 100%;
  overflow-y: auto;
  padding-right: 2px;
  min-height: 0;
  padding-bottom: calc(8px + var(--ask-keyboard-offset, 0px));
  transition: padding-bottom 0.25s ease;
}

.sheet-chat-hint {
  margin: 0;
  font-size: 11px;
  opacity: 0.6;
  width: 100%;
}

.sheet-chat-quick {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.sheet-chat-quick button {
  align-self: flex-start;
}

.sheet-chat-quick.is-hidden {
  display: none;
}

.sheet-chat-form {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: stretch;
  transform: translateY(calc(-1 * var(--ask-keyboard-offset, 0px)));
  margin-bottom: calc(-1 * var(--ask-keyboard-offset, 0px));
  transition: transform 0.25s ease;
}

.sheet-chat-input {
  flex: 1 1 auto;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  resize: none;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  outline: none;
  box-shadow: none;
}

.sheet-chat-input:disabled {
  opacity: 0.6;
}

.sheet-chat-send {
  align-self: stretch;
  min-width: 44px;
  padding: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.sheet-chat-send svg {
  width: 18px;
  height: 18px;
  display: block;
}

.sheet-chat-message {
  max-width: 85%;
  padding: 8px 10px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.06);
}

.sheet-chat-message p {
  margin: 0 0 6px;
}

.sheet-chat-message p:last-child {
  margin-bottom: 0;
}

.sheet-chat-message ul,
.sheet-chat-message ol {
  margin: 6px 0 0 18px;
  padding: 0;
}

.sheet-chat-message code {
  padding: 1px 4px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.08);
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.sheet-chat-message.is-user {
  align-self: flex-end;
  background: rgba(39, 123, 59, 0.14);
}

.sheet-chat-message.is-assistant {
  align-self: flex-start;
}

.sheet-chat-message.is-loading {
  opacity: 0.6;
  font-style: italic;
}

.bottom-sheet.is-dragging {
  transition: none;
}

.bottom-sheet.is-visible {
  display: block;
}

.bottom-sheet.is-closing {
  display: block;
  opacity: 0;
  transform: translateY(18px);
  transition: transform 0.36s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 0.36s ease;
}
.is-standalone .bottom-sheet {
  corner-shape: squircle;
  left: 12px;
  right: 12px;
  bottom: 12px;
}
.is-standalone .bottom-sheet-face {
  border-radius: 55px;
  padding: 24px;
  padding-top: 18px;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
}

.is-standalone .bottom-sheet.is-ask-focused .bottom-sheet-face {
  border-radius: 24px;
  padding: 16px 18px 18px;
}

.bottom-sheet.is-hidden {
  display: none;
}

.sheet-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 7px;
  position: relative;
}

.sheet-tip {
  margin: 0 auto 0 0;
  font-size: 10px;
  line-height: 1.2;
  opacity: 0.6;
  max-width: 120px;
  min-width: 0;
  flex: 1 1 120px;
}

.sheet-actions-buttons {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.bottom-sheet.is-sentence .sheet-tip {
  display: none;
}

.sheet-actions button {
  transition: opacity 0.3s ease;
}

.sheet-actions.is-swapping button {
  transition: opacity 0.3s ease, transform 0.35s ease;
}

.sheet-actions.is-hinting button {
  opacity: 0;
  pointer-events: none;
}

.bottom-sheet.is-loading .sheet-actions {
  display: none;
}


.sheet-grammar-stack {
  display: grid;
  gap: 10px;
}
.is-standalone .sheet-actions {
  margin-wight: 8px;
}

.sheet-handle {
  width: 38px;
  height: 5px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 999px;
  margin: 0 auto 6px;
}

.sheet-swipe-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  transform-origin: center;
  z-index: 2;
}

.sheet-swipe-overlay.is-accept {
  background: rgba(52, 168, 83, 0.22);
  color: #0f3d1f;
}

.sheet-swipe-overlay.is-ignore {
  background: rgba(219, 72, 61, 0.22);
  color: #4a120e;
}

.sheet-swipe-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16);
}

.sheet-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  font-size: 11px;
  opacity: 0.6;
}

.sheet-german {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
}

.bottom-sheet.is-sentence .sheet-german {
  font-size: 16px;
  font-weight: 400;
}

.sheet-english {
  margin: 0;
  font-size: 13px;
  opacity: 0.8;
}

.sheet-swipe-hint {
  margin: 0;
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: rgba(39, 123, 59, 0.9);
  text-align: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.sheet-swipe-hint.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sheet-compound {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.sheet-compound.is-hidden {
  display: none;
}

.sheet-compound-list {
  display: grid;
  gap: 4px;
}

.sheet-compound-item {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  opacity: 0.85;
}

.sheet-compound-word {
  font-weight: 600;
}

.sheet-compound-sep {
  opacity: 0.6;
}

.sheet-compound-translation {
  opacity: 0.85;
}

.sheet-grammar {
  margin: 0;
  font-size: 12px;
  opacity: 0.75;
}

.sheet-morphology {
  display: none;
  gap: 8px;
  margin-top: 6px;
}

.bottom-sheet.is-expanded .sheet-morphology {
  display: grid;
}

.sheet-morphology-text {
  margin: 0;
  font-size: 12px;
  opacity: 0.8;
}

.sheet-morphology-table {
  display: grid;
  gap: 6px;
}

.sheet-morphology-row {
  display: grid;
  grid-template-columns: 1fr 0.9fr 1.4fr;
  gap: 8px;
  font-size: 12px;
}

.sheet-morphology-cell {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sheet-morphology-row .sheet-morphology-cell:first-child {
  font-weight: 600;
}

@keyframes rise {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.theme-b {
  --paper: #e7f0f5;
  --panel: #0f1e2e;
  --panel-strong: #1b2e44;
  --ink: #0e0b0c;
  --accent: #ffb246;
  --accent-dark: #e19533;
  --mint: #ffd8a8;
}

.theme-b .translation-panel,
.theme-b .bottom-sheet {
  color: #f7efe1;
}

.theme-b .meta-pill {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.theme-b .panel-english,
.theme-b .panel-grammar,
.theme-b .sheet-english,
.theme-b .sheet-grammar {
  opacity: 0.75;
}

@media (min-width: 601px) {
  .settings-desktop-warning {
    display: block;
  }
}

@media (max-width: 960px) {
  .bottom-sheet {
    display: flex;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 0;
  }

  .top-bar {
    flex-wrap: wrap;
    gap: 12px;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .modal-content {
    padding: 18px;
  }

  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

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

  .book-panel {
    padding: 20px;
  }

  .library-panel {
    padding: 0;
  }

  .library-view {
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .word {
    padding: 1px;
    margin: 0 -1px;
  }
}
