/* One calm, responsive reading theme. No generated images or icon font required. */
:root {
  --paper: #f5f4f0;
  --surface: #fdfdfa;
  --ink: #303b36;
  --muted: #626c65;
  --line: #dedfd7;
  --accent: #4b6658;
  --accent-hover: #3e584a;
  --sage: #eef1e9;
  --highlight: #e1ead7;
  --sans: 'DM Sans', Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
  color: inherit;
  border: 0;
  background: none;
}

button:disabled {
  cursor: default;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button, a, input, select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid #627e55;
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.sr, .skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.skip:focus {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 30;
  background: white;
  padding: 12px;
}

/* Header and reading status */
.header {
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 25px 5%;
  background: #fafaf7;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.7px;
  line-height: 1;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 35px;
  height: 38px;
  margin-right: 10px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 24px;
}

.brand-icon span {
  position: absolute;
  top: 0;
  right: 1px;
  font-size: 14px;
  color: #e1e9d8;
}

.brand-dot {
  color: #6c8268;
}

.header nav {
  display: flex;
  gap: 30px;
  font-size: 13px;
  font-weight: 500;
}

.header nav a {
  color: var(--muted);
  padding: 8px 0;
}

.header nav a:hover {
  color: var(--ink);
}

#nav-count {
  display: inline-block;
  padding: 0 6px;
  margin-left: 3px;
  border-radius: 12px;
  background: #e8ece3;
  color: var(--accent);
  font-size: 11px;
}

.edition {
  margin-left: auto;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1.2px;
}

.shell {
  max-width: 1400px;
  margin: auto;
  padding: 0 5%;
}

.edition-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .6px;
}

#feed-label {
  color: var(--accent);
}

.edition-right {
  margin-left: auto;
}

.feed-status {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.feed-status p {
  margin: 9px 0;
  color: var(--muted);
  font-size: 12px;
}

.text-button {
  color: var(--accent);
  font-size: 12px;
  text-decoration: underline;
  padding: 10px;
}

/* Article and companion */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 5px 22px #303b3605;
}

.reader {
  padding: 38px 44px;
  min-width: 0;
}

.reader:focus {
  outline: none;
}
.reader:focus-visible {
  outline: 2px solid #627e55;
  outline-offset: 3px;
}

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

.pill {
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--accent);
  background: #eaf0e7;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
}

.read-time {
  font-size: 11px;
  color: var(--muted);
}

.article-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

h1 {
  font-size: clamp(29px, 3vw, 38px);
  font-weight: 600;
  line-height: 1.27;
  letter-spacing: -.85px;
  margin: 22px 0 20px;
  overflow-wrap: anywhere;
}

.article-title-row h1 {
  flex: 1;
  min-width: 0;
}

.title-next {
  flex-shrink: 0;
  white-space: nowrap;
  margin-top: 24px;
}

.source-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 21px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.source-mark {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #6b7c6c;
  color: white;
  font-size: 12px;
}

.reader-guide {
  font-size: 15px;
  line-height: 1.6;
  font-weight: 600;
  color: #35483b;
  background: #e8efdf;
  border-left: 4px solid #718b60;
  padding: 14px 17px;
  margin: 20px 0 10px;
  border-radius: 6px;
}

.keyboard-guide {
  color: var(--muted);
  font-size: 11px;
  margin: 0 0 24px;
}

.article-copy {
  max-width: 760px;
  color: #3d4640;
  font-size: 17px;
  line-height: 2;
  overflow-wrap: break-word;
}

.article-copy p {
  margin: 0 0 23px;
}

.token {
  padding: 0;
  border-radius: 2px;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
}

.token:hover {
  background: #e8eee1;
}

.token.chosen {
  background: #dce7d3;
  color: var(--ink);
  box-shadow: 0 1px 0 #9eaf95;
}

.token.saved-word {
  background: var(--highlight);
  color: #35492d;
  box-shadow: 0 1px 0 #a9bc98;
  font-weight: 500;
}

.token.saved-word:hover {
  background: #d3e1c6;
}

.story-navigation, .reader-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
  padding-top: 20px;
  margin-top: 26px;
  border-top: 1px solid var(--line);
}

.story-position {
  font-size: 12px;
  color: var(--muted);
}

.source-link, .listen {
  font-size: 12px;
  color: var(--accent);
}

.listen {
  padding: 8px 0;
}

.demo-disclaimer {
  font-size: 11px;
  line-height: 1.8;
  color: var(--muted);
  margin: 18px 0 0;
}

.primary {
  padding: 12px 19px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 500;
}

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

.primary:disabled {
  color: #526449;
  background: #dce4d5;
  border-color: #c7d4bd;
}

/* Sticky word companion, independently scrollable on shorter screens. */
.word-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  min-width: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 13px 13px 0;
  background: var(--sage);
  scrollbar-color: #b0bca8 var(--sage);
}

.column-label {
  display: flex;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid #d9dfd1;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 1px;
}

.word-form {
  padding: 18px 22px 0;
}

.word-form label, .sense-label {
  display: block;
  margin-bottom: 7px;
  color: #58694f;
  font-size: 11px;
}

.word-input-row {
  display: flex;
  background: #fafcf7;
  border: 1px solid #bdc9b5;
  border-radius: 7px;
}

.word-input-row input {
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.lookup-button {
  padding: 8px 12px;
  color: var(--accent);
  font-size: 18px;
}

#word-content {
  padding: 23px 22px;
}

.word-panel h2 {
  margin: 0;
  color: #35483b;
  font-size: 29px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -.6px;
  overflow-wrap: anywhere;
}

.word-panel p {
  color: #53604f;
  font-size: 13px;
  line-height: 1.85;
}

.word-panel .word-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 20px;
}

.word-heading h2 {
  flex: 1;
}

.clear-word {
  flex-shrink: 0;
  padding: 5px;
  font-size: 21px;
  color: var(--muted);
}

.word-context summary {
  cursor: pointer;
}

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

.sound-button {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #bdcbb5;
  border-radius: 50%;
  background: #f8faf5;
  color: var(--accent);
  font-size: 17px;
}

.sound-button:hover {
  background: #e0e9d7;
}

.word-context {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #d5ddcd;
}

.eyebrow {
  color: #58694f;
  font-size: 10px;
  letter-spacing: 1px;
}

.word-context p {
  font-style: italic;
  margin-bottom: 0;
}

.translation-box {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #d5ddcd;
}

.sense-select {
  width: 100%;
  padding: 11px;
  border: 1px solid #bdc9b5;
  border-radius: 7px;
  background: #fafcf7;
  color: var(--ink);
  font-size: 12px;
}

.word-panel .primary {
  width: 100%;
  margin-top: 13px;
}

.word-panel .translation-result {
  color: #35483b;
  font-size: 18px;
  font-weight: 500;
  min-height: 24px;
  margin: 15px 0;
}

.word-panel .translation-result.error {
  color: #92452f;
  font-size: 13px;
}

.word-panel .translation-credit {
  font-size: 10px;
  color: var(--muted);
}

/* Browser-local vocabulary and backup controls. */
.collection {
  padding: 46px 0 55px;
}

.collection h2 {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -.5px;
  margin: 0 0 12px;
}

#collection-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 10px;
  vertical-align: middle;
}

.collection-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.collection-tools p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.backup-actions {
  display: flex;
  gap: 12px;
}

.backup-actions button {
  padding: 12px 22px;
  min-height: 46px;
  border: 1px solid #b9c6b2;
  border-radius: 8px;
  background: #fafbf7;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
}

.backup-actions button:hover {
  background: #e7eedf;
  border-color: #9eb18f;
}

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

.saved-card {
  position: relative;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfcf8;
}

.saved-open {
  display: block;
  text-align: left;
  padding: 0;
  margin-right: 16px;
}

.saved-card h3 {
  color: #35483b;
  font-size: 23px;
  line-height: 1.2;
  font-weight: 500;
  overflow-wrap: anywhere;
  margin: 0 0 10px;
}

.saved-translation {
  color: var(--accent);
  font-size: 15px;
  margin: 0 0 10px;
}

.saved-language, .saved-source {
  display: block;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
}

.saved-source {
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.remove-word {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 32px;
  height: 32px;
  color: var(--muted);
  font-size: 20px;
}

.remove-word:hover {
  background: #e8eee1;
  border-radius: 5px;
}

.empty-collection {
  grid-column: 1 / -1;
  padding: 30px;
  border: 1px dashed #cbd4c3;
  border-radius: 10px;
  background: #fafbf7;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  max-width: 90vw;
  padding: 13px 20px;
  border: 1px solid #647d5c;
  border-radius: 9px;
  background: #43594b;
  color: white;
  box-shadow: 0 5px 20px #303b3615;
  font-size: 13px;
  opacity: 0;
  transform: translate(-50%, 15px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}

#toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1100px) {
  .edition {
    display: none;
  }

  .saved-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

}

@media (max-width: 1000px) {
  .article-title-row {
    flex-wrap: wrap;
    gap: 0;
  }

  .article-title-row h1 {
    flex-basis: 100%;
    margin-bottom: 14px;
  }

  .title-next {
    margin: 0 0 20px;
  }

}

@media (max-width: 850px) {
  .header {
    justify-content: space-between;
    gap: 20px;
  }

  .header nav {
    gap: 18px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 255px;
  }

  .reader {
    padding: 29px;
  }

}

@media (max-width: 640px) {
  .reader {
    scroll-margin-top: calc(43dvh + 24px);
  }
  .header {
    flex-wrap: wrap;
    padding: 22px 5% 15px;
    gap: 17px;
  }

  .header nav {
    width: 100%;
    justify-content: space-between;
  }

  .brand {
    font-size: 21px;
  }

  .edition-bar {
    font-size: 9px;
    gap: 12px;
  }

  .edition-right {
    display: none;
  }

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

  .reader {
    padding: 25px 22px;
  }

  .article-copy {
    font-size: 16px;
    line-height: 1.95;
  }

  .reader-guide {
    font-size: 14px;
    padding: 13px 14px;
  }

  .word-panel {
    top: 0;
    z-index: 5;
    grid-row: 1;
    max-height: 43dvh;
    border-left: 0;
    border-bottom: 1px solid #cbd4c3;
    border-radius: 13px 13px 0 0;
  }

  .column-label {
    padding: 10px 18px;
    font-size: 9px;
  }

  .word-form {
    padding: 10px 18px 0;
  }

  .word-panel.has-word .word-form {
    display: none;
  }

  #word-content {
    padding: 14px 18px;
  }

  .word-panel h2 {
    font-size: 25px;
  }

  .word-context {
    margin-top: 12px;
    padding-top: 10px;
  }

  .word-context p {
    max-height: 65px;
    overflow: auto;
  }

  .translation-box {
    margin-top: 12px;
    padding-top: 10px;
  }

  .word-panel .primary {
    padding: 10px;
    margin-top: 9px;
  }

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

  .collection h2 {
    font-size: 28px;
  }

  .collection-tools {
    align-items: flex-start;
  }

}

@media (max-width: 360px) {
  .saved-grid {
    grid-template-columns: 1fr;
  }

}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }

}

