* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: #f7f5f0;
  color: #101e33;
  font: 15px Arial, sans-serif;
  line-height: 1.6;
}

header {
  padding: 26px max(20px, calc((100% - 960px) / 2));
  background: #101e33;
  color: white;
}

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

.brand img {
  border-radius: 10px;
}

.brand strong {
  font-size: 14px;
}

.brand small {
  display: block;
  color: #c9a96a;
  letter-spacing: 2px;
}

h1, h2 {
  font-family: Georgia, serif;
}

h1 {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: normal;
}

.header-links {
  display: flex;
  gap: 20px;
}

.header-links a {
  color: #e4c88d;
}

main {
  max-width: 1000px;
  min-height: 65vh;
  margin: auto;
  padding: 20px;
}

.tabs, .tools, .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.tabs {
  margin: 22px 0;
}

button, select, .actions a {
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid #c9a96a;
  border-radius: 7px;
  background: white;
  color: #101e33;
  font: 600 14px Arial, sans-serif;
}

button, .actions a {
  cursor: pointer;
  text-decoration: none;
}

button[aria-pressed="true"] {
  background: #101e33;
  color: #e4c88d;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid #b08c45;
  outline-offset: 3px;
}

.danger {
  color: #9b2635;
  border-color: #e3b8be;
}

.tools {
  padding-bottom: 16px;
  border-bottom: 1px solid #ddd;
}

.card, #reader, .empty {
  margin: 14px 0;
  padding: 20px;
  background: white;
  border: 1px solid #e0e4e8;
  border-radius: 10px;
}

.card h2 {
  margin: 8px 0;
  font-size: 21px;
  overflow-wrap: anywhere;
}

.card small, .card p, #reader-meta {
  color: #64748b;
}

#reader-warning {
  padding: 12px;
  background: #f7f5f0;
  border-left: 3px solid #c9a96a;
}

#reader-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.85;
}

footer {
  padding: 24px;
  padding-bottom:
    calc(24px + env(safe-area-inset-bottom, 0px));
  background: #101e33;
  color: #e4c88d;
  text-align: center;
}

@media (max-width: 480px) {
  main {
    padding: 14px;
  }

  .tabs button {
    flex: 1;
  }

  .tools select {
    flex: 1;
    min-width: 0;
  }

  .card, #reader {
    padding: 16px;
  }
}

.library-search {
  display: grid;
  gap: 8px;
  margin: 20px 0;
}

.library-search label {
  font-weight: 700;
}

.library-search input {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  border: 1px solid #a9b2bf;
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-size: 16px;
  background: #fff;
  color: #101e33;
}

.library-search input:focus-visible {
  outline: 3px solid #c9a96a;
  outline-offset: 2px;
}

#library-search-hint {
  margin: 0;
  font-size: .85rem;
  line-height: 1.5;
}

.audio-library {
  margin: 36px 0;
  padding-top: 24px;
  border-top: 1px solid #cbd3df;
  scroll-margin-top: 20px;
}

#audio-storage-meter {
  width: 100%;
  height: 12px;
  accent-color: #c9a96a;
}

#audio-library .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

#audio-library button[aria-pressed="true"] {
  background: #101e33;
  color: white;
}

#audio-search {
  box-sizing: border-box;
  width: 100%;
  padding: 12px;
  border: 1px solid #cbd3df;
  border-radius: 9px;
  font: inherit;
}

#audio-items {
  display: grid;
  gap: 12px;
}

#offline-player {
  margin-top: 20px;
  padding: 18px;
  border-radius: 14px;
  background: #101e33;
  color: white;
}

#offline-player[hidden] {
  display: none;
}

#offline-audio {
  display: block;
  width: 100%;
  margin: 15px 0;
}

#offline-speed {
  padding: 10px;
  border-radius: 8px;
  font: inherit;
}
