/* Web-app surfaces — home (paste box) + view (translation reader). */

html,
body {
  background: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
  /* Long German compounds (e.g. "Korrespondentendinner") would otherwise
     force horizontal scroll on phones, which makes sticky elements stop
     short of the right edge and bleed the canvas colour through. */
  overflow-x: clip;
}

body {
  line-height: 1.7;
  font-size: 17px;
}

a {
  color: var(--blue);
}

/* =================================================
   MASTHEAD — shared by home + view
   ================================================= */
.masthead {
  background: var(--ink);
  border-bottom: 3px solid var(--blue);
  padding: 14px 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.masthead-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--paper);
}
.masthead-mark,
.brand-mark {
  width: 32px;
  height: 32px;
  font-size: 15px;
  background: var(--blue);
  color: var(--paper);
}
.masthead-mark .dot,
.brand-mark .dot {
  color: var(--paper);
}
.masthead-wordmark,
.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--paper);
  letter-spacing: -0.01em;
}
.masthead-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.25);
}
.masthead-meta,
.brand-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
}
.brand-meta {
  margin-left: auto;
}
.masthead-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  font-weight: 600;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: all 0.15s;
  margin-left: auto;
}
.masthead-link:hover {
  color: var(--paper);
  border-color: var(--paper);
}
.brand-meta + .masthead-link {
  margin-left: 8px;
}
.masthead-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.iconbtn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.15s;
}
.iconbtn:hover {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.1);
}

/* =================================================
   SUBBAR — view only
   ================================================= */
.subbar {
  background: var(--off);
  border-bottom: 1px solid var(--ink);
  padding: 10px 28px;
}
.subbar-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pill {
  background: var(--blue);
  color: var(--paper);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.source-label {
  color: var(--ink-3);
  font-weight: 400;
  white-space: nowrap;
}
.source-link {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid var(--ink-3);
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
}
.source-link:hover {
  color: var(--blue);
  border-bottom-color: var(--blue);
}
@media (max-width: 640px) {
  .subbar-inner {
    gap: 8px;
    flex-wrap: wrap;
  }
  .source-label {
    display: none;
  }
}

/* =================================================
   HOME — paste box
   ================================================= */
.home {
  padding: 64px 28px 48px;
  background: var(--paper);
}
.home-inner {
  max-width: 640px;
  margin: 0 auto;
}
.home-eyebrow {
  display: inline-block;
  background: var(--blue);
  color: var(--paper);
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 18px;
}
.home-title {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
  text-wrap: balance;
  color: var(--ink);
}
.home-lede {
  font-size: 21px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink-2);
  margin-bottom: 40px;
  max-width: 56ch;
}

.url-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  background: var(--paper);
  border: 2px solid var(--ink);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  font-weight: 600;
}
.url-input {
  font-family: var(--font-sans);
  font-size: 17px;
  padding: 12px 14px;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  outline: none;
}
.url-input:focus {
  outline: 2px solid var(--blue);
  outline-offset: 0;
}

/* Shared segmented toggle */
.toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--ink);
}
.toggle button {
  padding: 12px 14px;
  border: none;
  background: var(--paper);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
}
.toggle button + button {
  border-left: 1px solid var(--ink);
}
.toggle button.on {
  background: var(--ink);
  color: var(--paper);
}
.toggle button .sub {
  display: block;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
}
.toggle button.on .sub {
  color: rgba(255, 255, 255, 0.7);
}

.submit-btn {
  align-self: stretch;
  border: none;
  background: var(--blue);
  color: var(--paper);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 14px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.15s;
}
.submit-btn:hover {
  background: var(--blue-deep);
}

.home-foot {
  margin-top: 32px;
  font-size: 14px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
.home-foot p + p {
  margin-top: 6px;
}

/* =================================================
   ACCELERATORS — bookmarklet, Android share, extension
   ================================================= */
.accel {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 2px solid var(--ink);
}
.accel-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 6px;
}
.accel-lede {
  font-size: 16px;
  color: var(--ink-2);
  margin-bottom: 22px;
  max-width: 56ch;
}
.accel-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 720px) {
  .accel-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}
.accel-card {
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.accel-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue);
  font-weight: 700;
}
.accel-help {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  flex: 1;
}
.bookmarklet {
  display: inline-block;
  align-self: flex-start;
  margin-top: 4px;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  cursor: grab;
  user-select: none;
}
.bookmarklet:hover {
  background: var(--blue);
}
.accel-pill {
  display: inline-block;
  align-self: flex-start;
  margin-top: 4px;
  padding: 6px 10px;
  background: var(--off);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  border: 1px solid var(--rule);
}

/* =================================================
   SETTINGS — provider, keys, level, voice
   ================================================= */
.settings {
  padding: 64px 28px 48px;
  background: var(--paper);
}
.settings-inner {
  max-width: 640px;
  margin: 0 auto;
}
.settings-card {
  margin-top: 32px;
  background: var(--paper);
  border: 2px solid var(--ink);
}
.group {
  padding: 22px 28px;
  border-bottom: 1px solid var(--ink);
}
.group:last-of-type {
  border-bottom-width: 2px;
}
.group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.group-head h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.group-idx {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--blue);
  letter-spacing: 0.08em;
  font-weight: 700;
  text-transform: uppercase;
}
.help {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  margin-bottom: 14px;
  max-width: 60ch;
}
.help a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1px solid var(--blue);
}
.help-sm {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
  margin-bottom: 10px;
}
.help-sm a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1px solid var(--blue);
}
.help-sm code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--off);
  padding: 1px 5px;
  border: 1px solid var(--rule);
}
.group .field {
  margin-top: 18px;
}
.group .field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.key-input {
  display: flex;
  background: var(--paper);
  border: 1px solid var(--ink);
  overflow: hidden;
}
.key-input:focus-within {
  outline: 2px solid var(--blue);
  outline-offset: 0;
}
.key-input input {
  flex: 1;
  padding: 12px 14px;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
.key-input input::placeholder {
  color: var(--ink-3);
}
.eye {
  width: 44px;
  border: none;
  background: var(--off);
  color: var(--ink-2);
  cursor: pointer;
  border-left: 1px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.eye:hover {
  color: var(--ink);
}
.select {
  position: relative;
}
.select select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 12px 14px;
  padding-right: 36px;
  background: var(--paper);
  border: 1px solid var(--ink);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.select select:focus {
  outline: 2px solid var(--blue);
  outline-offset: 0;
}
.select::after {
  content: "▾";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-2);
  pointer-events: none;
  font-size: 12px;
}
.actions {
  background: var(--off);
  padding: 20px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.local-note {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.actions-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.save-status {
  font-size: 13px;
  color: var(--ok, #1f7a3a);
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
.save {
  padding: 12px 28px;
  background: var(--blue);
  color: var(--paper);
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s;
}
.save:hover {
  background: var(--blue-deep);
}
.hidden {
  display: none !important;
}

/* =================================================
   READER — shared with view/error templates
   ================================================= */
.reader {
  background: var(--paper);
  padding: 48px 28px 64px;
  min-height: 60vh;
}
.reader-inner {
  max-width: 640px;
  margin: 0 auto;
}
.eyebrow {
  display: inline-block;
  background: var(--blue);
  color: var(--paper);
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.title {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
  text-wrap: balance;
  color: var(--ink);
  overflow-wrap: anywhere;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.meta-row {
  display: flex;
  align-items: center;
  gap: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-bottom: 18px;
  margin-bottom: 28px;
  border-bottom: 2px solid var(--ink);
  flex-wrap: wrap;
}
.meta-row .sep {
  color: var(--blue);
  padding: 0 8px;
}
.meta-row a {
  color: var(--ink);
  border-bottom: 1px solid var(--ink-3);
  text-decoration: none;
}
.meta-row a:hover {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* =================================================
   BODY COPY — translated content
   ================================================= */
.body-copy {
  font-size: var(--body-size, 19px);
  line-height: var(--body-lh, 1.7);
  color: var(--ink);
  hyphens: auto;
  -webkit-hyphens: auto;
}
.body-copy h1,
.body-copy h2,
.body-copy h3,
.body-copy h4 {
  overflow-wrap: anywhere;
}
.body-copy p,
.body-copy li {
  overflow-wrap: break-word;
}
.body-copy p {
  margin-bottom: 18px;
  max-width: 60ch;
  text-wrap: pretty;
}
.body-copy > p:first-of-type,
.body-copy p.lead {
  font-size: calc(var(--body-size, 19px) * 1.1);
  font-weight: 500;
  color: var(--ink);
}
.body-copy h2 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 36px;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
  padding-left: 14px;
  border-left: 4px solid var(--blue);
}
.body-copy h3 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 32px;
  margin-bottom: 10px;
}
.body-copy strong {
  font-weight: 700;
}
.body-copy em {
  font-style: italic;
}
.body-copy ul,
.body-copy ol {
  list-style: none;
  padding: 0;
  margin: 16px 0 24px;
}
.body-copy li {
  position: relative;
  padding-left: 28px;
  margin-bottom: 8px;
  max-width: 60ch;
}
.body-copy ul li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: calc(var(--body-lh, 1.7) * 0.5em - 5px);
  width: 10px;
  height: 10px;
  background: var(--blue);
}
.body-copy ol {
  counter-reset: ls-counter;
}
.body-copy ol li {
  counter-increment: ls-counter;
}
.body-copy ol li::before {
  content: counter(ls-counter);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--blue);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  line-height: inherit;
}
.body-copy hr {
  border: none;
  height: 1px;
  background: var(--ink);
  margin: 32px 0;
}

/* =================================================
   LOADING / ERROR
   ================================================= */
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--rule);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.error-box {
  background: var(--ink);
  color: var(--paper);
  padding: 14px 20px;
  font-size: 15px;
  line-height: 1.5;
}
.error-box p {
  margin: 0;
}
.error-box a {
  color: var(--paper);
  border-bottom: 1px solid var(--paper);
  text-decoration: none;
}
.back-link {
  margin-top: 24px;
}

/* =================================================
   A11Y DOCK
   ================================================= */
.page {
  position: relative;
}
.a11y-dock {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 5;
}
@media (max-width: 900px) {
  .a11y-dock {
    top: auto;
    bottom: 20px;
    transform: translateX(50%);
    right: 50%;
    flex-direction: row;
  }
  .a11y-sep {
    width: 1px;
    height: auto;
    margin: 4px 2px;
    background: var(--rule);
  }
}
.a11y-btn {
  width: 36px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.a11y-btn:hover {
  background: var(--off);
  color: var(--ink);
}
.a11y-btn.on {
  background: var(--ink);
  color: var(--paper);
}
.a11y-btn--mono {
  width: auto;
  min-width: 44px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
}
.a11y-btn[data-state="playing"] .ic-play {
  display: none;
}
.a11y-btn[data-state="paused"] .ic-pause {
  display: none;
}
.a11y-sep {
  height: 1px;
  background: var(--rule);
  margin: 4px 6px;
}

/* Read-aloud word highlight via CSS Custom Highlight API */
::highlight(speech-word) {
  background-color: var(--blue);
  color: var(--paper);
}

/* =================================================
   READER CONTROLS
   ================================================= */
.page[data-size="s"] {
  --body-size: 17px;
}
.page[data-size="m"] {
  --body-size: 19px;
}
.page[data-size="l"] {
  --body-size: 22px;
}
.page[data-size="xl"] {
  --body-size: 25px;
}
.page[data-spacing="tight"] {
  --body-lh: 1.55;
}
.page[data-spacing="normal"] {
  --body-lh: 1.7;
}
.page[data-spacing="loose"] {
  --body-lh: 1.95;
}
