* { box-sizing: border-box; }
:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #182238;
  background: #f3f6fc;
  --blue: #005dcc;
  --definition-color: #274865;
  --muted: #526077;
  --edge: #b1bdd28c;
  --radius: 1.25em;
  --page-gutter: clamp(12px, 2vw, 44px);
}
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 90% 0%, #d6e1ff 0%, transparent 48%),
    radial-gradient(ellipse at 5% 46%, #dce9fa 0%, transparent 50%),
    linear-gradient(158deg, #fafbfe, #edf2fb 68%, #fafbff);
  background-attachment: fixed;
}
button, input, textarea, select { font: inherit; }
button, input:not([type=checkbox]), textarea, select { border-radius: var(--radius); }
button, input:not([type=checkbox]) { min-height: 44px; line-height: 1.4; }
button, input[type="checkbox"], a, summary { cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
button {
  border: 1px solid transparent;
  padding: .56rem 1.14rem;
  font-weight: 650;
  transition: transform 180ms cubic-bezier(.2,.8,.2,1), background 180ms, box-shadow 180ms;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:active:not(:disabled) { transform: scale(.96); }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid #3782f2; outline-offset: 3px; }
.primary { background: var(--blue); color: white; box-shadow: 0 6px 18px #1163d32b, inset 0 1px 0 #ffffff4f; }
.primary:hover:not(:disabled) { background: #0870e9; box-shadow: 0 8px 24px #1163d34a; }
.secondary { background: #e5f0ff; color: #114d9c; border-color: #a8c7ee; }
.secondary:hover:not(:disabled), .quiet:hover:not(:disabled) { background: #d5e9ff; }
.quiet { color: #1b548e; background: #ffffff68; border-color: #b8ceed9c; }
.top { position: sticky; top: 0; z-index: 5; border-bottom: 1px solid #ffffffc2; background: #f6faffb3; backdrop-filter: blur(20px) saturate(145%); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 0; margin-inline: var(--page-gutter); }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: #173553; text-decoration: none; font-weight: 750; }
.brand-icon { display: grid; place-items: center; border-radius: var(--radius); width: 40px; height: 40px; background: linear-gradient(145deg, #3888ec, #065bcb); box-shadow: inset 0 1px #fff9, 0 3px 10px #1f79db34; color: white; font-family: Georgia, serif; }
.connections { display: flex; align-items: center; gap: .85rem; }
.library-toggle { display: none; }
.layout {
  display: grid;
  grid-template-columns: minmax(220px, 270px) minmax(0, 1fr);
  align-items: start;
  gap: 1.5rem;
  margin: clamp(1rem, 4vw, 3rem) var(--page-gutter) 5rem;
}
main { min-width: 0; }
.reading-open .library-toggle { display: inline-block; }
.reading-open .layout {
  grid-template-columns: minmax(0, 1fr);
  margin-top: clamp(1rem, 2.5vw, 2rem);
}
.reading-open:not(.library-open) .library { display: none; }
.reading-open.library-open .layout { grid-template-columns: minmax(190px, 255px) minmax(0, 1fr); }
h1 {
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1.12;
  letter-spacing: -.045em;
  margin: 0 0 1.75rem;
  color: #182238;
  overflow-wrap: anywhere;
}
.glass {
  border-radius: var(--radius);
  background: linear-gradient(140deg, #fffffff0, #f7f9ffe0);
  backdrop-filter: blur(17px) saturate(138%);
  border: 1px solid #fff;
  box-shadow: 0 14px 48px #2c426e16, inset 0 0 0 1px #a5b5d830;
}
.workbench { padding: clamp(1.15rem, 4.2vw, 2.55rem); margin-bottom: 1.35rem; scroll-margin-top: 5rem; }
h2 { margin: 0 0 1.25rem; font-size: 1.5rem; letter-spacing: -.024em; }
.field { display: grid; gap: .55rem; margin-bottom: 1rem; }
label { color: #2b4563; font-weight: 650; font-size: .93rem; }
.optional { color: var(--muted); font-size: .85em; font-weight: 450; margin-inline-start: .3em; }
input:not([type=checkbox]), textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--edge);
  background: #fbfdffd6;
  padding: .77rem .95rem;
  color: #102842;
  transition: box-shadow 180ms, background 180ms;
}
input:not([type=checkbox]) { padding-block: .56rem; }
input:not([type=checkbox]):focus, textarea:focus { outline: none; border-color: #5199ee; background: #fff; box-shadow: 0 0 0 4px #5d9ced29; }
input::placeholder, textarea::placeholder { color: #5d718a; }
textarea { display: block; resize: vertical; line-height: 1.65; min-height: 9rem; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
[role=status], .section-header p { color: var(--muted); margin: 0; font-size: .92rem; }
.library { position: sticky; top: 5rem; padding: 1.25rem; scroll-margin-top: 5rem; }
.library-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem .65rem; margin-bottom: .85rem; }
.library h2 { margin: 0; font-size: 1.2rem; }
.library-heading span { color: var(--muted); font-size: .76rem; }
#librarySearch { font-size: .92rem; padding-inline: .75rem; margin-bottom: .6rem; }
#libraryMessage:empty, #ankiMessage:empty { display: none; }
.reading-list { list-style: none; margin: 0; padding: .2rem; max-height: max(8rem, calc(100dvh - 15rem)); overflow: auto; }
.reading-list:empty { display: none; }
.reading-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .15rem; }
.reading-list li + li { margin-top: .35rem; }
.reading-link {
  display: grid;
  gap: .3rem;
  text-align: start;
  padding: .62rem .63rem;
  color: #182238;
  background: transparent;
  overflow-wrap: anywhere;
}
.reading-link:hover, .reading-link[aria-current] { background: #e6efff; }
.reading-link strong { font-size: .95rem; line-height: 1.4; }
.reading-meta { display: flex; flex-wrap: wrap; column-gap: .6rem; color: var(--muted); font-size: .76rem; font-weight: 450; }
.remove-reading { color: #7b3f48; padding-inline: .5rem; font-size: .78rem; }
.danger { color: white; background: #aa2436; }
.danger:hover { background: #8e2030; }
#deletePrompt { overflow-wrap: anywhere; line-height: 1.65; }
.reader-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .65rem 1.5rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.reader-heading h1 { margin: 0; font-size: clamp(1.85rem, 4.5vw, 2.85rem); }
.reader-heading button { flex: 0 0 auto; }
.reader-tools {
  position: sticky;
  z-index: 2;
  top: 4.75rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .6rem 1rem;
  padding: .65rem .75rem;
}
.reader-voices { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem .75rem; }
.reader-tools select {
  min-height: 44px;
  color: #1b548e;
  background: #f8fbff;
  padding: .45rem .65rem;
  border: 1px solid var(--edge);
}
.reading-speed { display: inline-flex; align-items: center; gap: .5rem; }
.reader-voices p { flex: 1 1 auto; }
.translation-bar { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; padding: 1rem 0; }
#ankiMessage { margin-top: .65rem; }
.reader { --paragraph-padding: clamp(1rem, 2vw, 1.65rem); }
.reading-paragraphs { display: grid; gap: 1.25rem; }
.reading-group {
  min-width: 0;
  border-radius: var(--radius);
  border: 1px solid #c8d4e866;
  background: #ffffffb3;
}
.reading-group-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .85rem;
  padding: .45rem var(--paragraph-padding);
  border-bottom: 1px solid #dfe7f491;
}
.reading-group-heading h2 { margin: 0; font-size: 1rem; }
.reading-group-heading span { color: var(--muted); font-size: .83rem; }
.reading-group-heading button { margin-inline-start: auto; }
.reading-sentence {
  scroll-margin-top: 11rem;
  transition: background 180ms;
}
.reading-sentence + .reading-sentence { border-top: 1px solid #dfe7f491; }
.paragraph-source {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .65rem;
  align-items: start;
  padding: .8rem var(--paragraph-padding) .3rem;
}
.reading-sentence.speaking { background: #deedff; }
.group-audio {
  font-size: .82rem;
  font-weight: 650;
  padding: .38rem .65rem;
  white-space: nowrap;
}
.sentence-audio {
  display: inline-grid;
  place-items: center;
  width: 44px;
  padding: 0;
  background: #f3f7ff;
}
.sentence-audio.is-playing { color: #064f9d; background: #d5e9ff; border-color: #a8c7ee; }
.reading-original {
  font: clamp(1.2rem, 1.6vw, 1.55rem)/1.65 Georgia, "Times New Roman", serif;
  margin: 0;
  overflow-wrap: anywhere;
}
.reading-token { display: inline-block; max-width: 100%; }
.tap-word {
  min-height: 0;
  padding: 0 .06em;
  margin: 0 -.06em;
  border: 0;
  font: inherit;
  line-height: 1.3;
  background: transparent;
  color: inherit;
  max-width: 100%;
  text-align: start;
  overflow-wrap: anywhere;
}
.tap-word:hover:not(:disabled), .tap-word:active:not(:disabled) { background: #d5e7fc; transform: none; }
.tap-word[aria-expanded] { background: #d5e7fc; }
.tap-phrase {
  text-decoration: underline dashed #5078a5;
  text-decoration-thickness: 1px;
  text-underline-offset: .23em;
  text-decoration-skip-ink: none;
}
.tap-word.is-spoken, .speech-token.is-spoken { background: #a6ceff; color: #0a3673; }
.reading-translation {
  font-size: clamp(.98rem, 1.25vw, 1.12rem);
  line-height: 1.8;
  color: #324766;
  margin: 0;
  padding: 0 var(--paragraph-padding) .8rem;
  padding-inline-start: calc(var(--paragraph-padding) + 44px + .65rem);
  overflow-wrap: anywhere;
}
.reading-translation.pending { color: var(--muted); font-size: .84rem; }
.word-popover {
  position: fixed;
  inset: auto;
  margin: 0;
  width: min(360px, calc(100vw - 24px));
  max-height: min(24rem, 66dvh, calc(100dvh - 24px));
  overflow: hidden;
  padding: 0;
  background: #f8fbfffa;
  color: #182238;
  box-shadow: 0 18px 40px #2c426e35;
}
.word-popover:popover-open { display: flex; flex-direction: column; }
.word-popover-header {
  flex: none;
  padding: .72rem .9rem .65rem;
  background: #f8fbff;
  border-bottom: 1px solid #dfe7f4;
}
.word-heading {
  display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
}
.word-content {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: .65rem .9rem .9rem;
}
.word-heading strong { font-size: 1.3rem; min-width: 0; max-width: 100%; flex: 1 1 auto; overflow-wrap: anywhere; }
.word-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.word-heading button { padding-inline: .65rem; font-size: .85rem; flex: 0 0 auto; }
.word-dictionary-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-top: .55rem; }
.word-dictionary-bar label { font-size: .85rem; }
.word-dictionary-bar select {
  min-height: 44px;
  color: #1b548e;
  border: 1px solid var(--edge);
  background: #f8fbff;
  padding: .32rem .55rem;
  font-size: .85rem;
}
.word-dictionary-bar a { margin-inline-start: auto; color: var(--blue); font-size: .8rem; }
.word-entry-meta { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .75rem; }
.eudic-pronunciations { display: flex; flex-wrap: wrap; gap: .45rem; margin: .55rem 0; }
.eudic-pronunciations button { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .65rem; font-size: .83rem; }
.eudic-pronunciations svg { width: 16px; height: 16px; }
.eudic-pronunciations span:last-child { font-family: Georgia, serif; font-weight: 500; }
.eudic-pronunciations span:empty { display: none; }
.word-content .word-definition, .word-rich-definition .definition {
  margin: 0; min-width: 0; font-size: .96rem; line-height: 1.65; overflow-wrap: anywhere;
}
.word-rich-definition { display: grid; grid-template-columns: minmax(0, 1fr); gap: .65rem; padding: 0 .75rem .7rem; }
.definition-glyph-filter { position: absolute; }
#definition-glyph-ink feFlood { flood-color: var(--definition-color); }
.word-popover .definition-glyph { filter: url("#definition-glyph-ink"); }
.word-rich-definition .definition-glyph { vertical-align: -.1em; }
#readerWordImage {
  display: block;
  width: min(100%, 148px);
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #f5f8fd;
  border-radius: var(--radius);
}
.dictionary-section { margin: .5rem 0 0; }
.dictionary-section summary { padding: .65rem .75rem; font-size: .87rem; }
.dictionary-section summary span { margin-inline-start: .35rem; color: var(--muted); font-size: .76rem; font-weight: 500; }
.dictionary-section > p { margin: 0; padding: 0 .75rem .65rem; }
.dictionary-lines { margin: 0; padding: 0 .75rem .65rem; list-style: none; }
.dictionary-lines li + li { margin-top: .6rem; padding-top: .55rem; border-top: 1px solid #dfe7f491; }
.dictionary-lines strong { font-size: .88rem; font-weight: 650; overflow-wrap: anywhere; }
.word-popover .word-tap-count { margin: .15rem 0 .35rem; font-size: .8rem; }
#eudicComplete, #wordPhraseMore { padding-inline: .65rem; font-size: .83rem; }
#eudicComplete { margin-top: .55rem; }
#wordPhraseMore { margin: 0 .75rem .55rem; }
.word-tap-count:empty { display: none; }
.card-scope-options { display: grid; gap: .6rem; }
#repeatedCardStatus { margin: .8rem 0 1rem; }
.tap-count { margin-inline-start: .6rem; font-size: .8rem; color: var(--muted); }
.section-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .8rem; align-items: center; }
.section-header h2 { margin: 0 0 .35rem; }
.summary { padding: .9rem 0; color: #335879; }
.lookup-actions { margin: .3rem 0 1rem; }
.phrase-form { display: grid; gap: .45rem; margin: 1.25rem 0; max-width: 29rem; }
.phrase-entry { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: .5rem; }
details { border: 1px solid var(--edge); border-radius: var(--radius); overflow: clip; background: #fcfdff8f; margin: .65rem 0; }
summary { padding: .85rem 1rem; font-weight: 700; }
.original { margin: 0 1rem .7rem; color: var(--muted); font-family: Georgia, serif; line-height: 1.65; }
.term-list { margin: 0; padding: 0; list-style: none; }
.term-row { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: .8rem; padding: .75rem 1rem; border-top: 1px solid #cad9ec79; }
.term-row .check { accent-color: var(--blue); width: 17px; height: 17px; margin: .19rem 0 0; }
.term { font-size: 1.04rem; }
.definition { white-space: pre-line; font-size: .92rem; color: var(--definition-color); margin: .25rem 0 0; }
.definition:empty { display: none; }
.definition-glyph { height: 1em; vertical-align: middle; }
.word-image:not([hidden]) { display: block; max-width: min(100%, 12rem); max-height: 9rem; margin-top: .5rem; object-fit: contain; }
.term-actions { display: grid; justify-items: end; gap: .35rem; }
.term-status { font-size: .83rem; color: #3a597b; text-align: right; }
audio { width: 164px; height: 30px; border-radius: var(--radius); }
#importMessage { margin-top: 1.2rem; white-space: pre-line; }
dialog { border: 1px solid #fff; border-radius: var(--radius); padding: 1.8rem; background: #edf6ffeF; color: #182238; box-shadow: 0 20px 70px #1a49795e; width: min(400px, calc(100% - 32px)); }
dialog::backdrop { background: #0a2a4c51; backdrop-filter: blur(7px); }
@media (max-width: 780px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: .3rem; }
  .library { position: static; grid-row: 2; }
  .reading-list { max-height: 16rem; }
  .library-toggle { display: inline-block; }
  .reading-open.library-open .layout { grid-template-columns: minmax(0, 1fr); }
  .reading-open.library-open .library { grid-row: 1; margin-bottom: .75rem; }
}
@media (max-width: 615px) {
  .top-inner, .brand, .connections { gap: .45rem; }
  .connections .quiet { padding-inline: .6rem; font-size: .84rem; }
  .brand-icon { width: 34px; height: 34px; }
  .reader-tools { padding: .55rem; }
  .reader-tools .actions { gap: .45rem; }
  .reader-tools button { padding-inline: .72rem; font-size: .88rem; }
  .phrase-entry input { padding-inline: .65rem; }
  .term-row { grid-template-columns: auto 1fr; }
  .term-actions { grid-column: 2; justify-items: start; }
  .term-status { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  button:hover, button:active { transform: none !important; }
}
