.library {
  color: var(--ink);
  min-width: 0;
}
.library h1,
.library h2,
.lib-dialog h2,
.library p,
.lib-dialog p {
  margin: 0;
}
.library h1 {
  font-size: 24px;
  font-weight: 550;
}
.library h2 {
  font-size: 15px;
  font-weight: 650;
}
.library button,
.lib-dialog button {
  font: inherit;
  cursor: pointer;
}
.library small,
.lib-dialog small {
  font-size: 12px;
  color: var(--secondary);
  display: block;
}
.lib-body {
  display: grid;
  gap: 12px;
  margin: 14px auto 0;
}
.lib-list-head,
.lib-bar {
  margin: -14px calc(-1 * var(--gutter)) 0;
  padding: 12px var(--gutter);
  background: white;
  border-bottom: 1px solid var(--line);
}
.lib-list-head > div:first-child,
.lib-bar,
.lib-stat-row,
.lib-state,
.lib-actions,
.lib-editor-head,
.lib-preview p {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lib-list-head > div:first-child,
.lib-stat-row,
.lib-editor-head,
.lib-preview p {
  justify-content: space-between;
}
.lib-list-head > div > a,
.lib-bar a:last-child,
.lib-bar button,
.lib-extra {
  color: var(--orange);
  font-size: 15px;
  font-weight: 600;
}
.lib-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f4f4;
  border-radius: 10px;
  padding: 0 12px;
  color: var(--muted);
}
.lib-search svg {
  width: 16px;
  height: 16px;
}
.lib-search input {
  min-height: 38px;
  background: none;
  border: none;
  min-width: 0;
  width: 100%;
  font-size: 14px;
}
.lib-list-head .lib-search,
.lib-list-head .lib-chips {
  margin-top: 12px;
}
.lib-chips {
  display: flex;
  gap: 8px;
  overflow: auto;
}
.lib-chips button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 99px;
  padding: 5px 13px;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 600;
}
.lib-chips button[aria-pressed='true'] {
  color: white;
  background: var(--orange);
  border-color: var(--orange);
}
.lib-deck,
.lib-box {
  background: white;
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 14px;
}
.lib-deck {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}
.lib-deck > div,
.manage-row .grow {
  flex: 1;
  min-width: 0;
}
.lib-symbol {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  color: var(--orange);
  background: var(--tint);
}
.lib-symbol.daily {
  background: #ebfaff;
}
.lib-symbol.exam {
  background: #f5eefb;
}
.lib-deck small {
  margin: 3px 0 5px;
}
.lib-deck progress {
  display: block;
  appearance: none;
  background: #f1efed;
  width: 100%;
  height: 5px;
  border: none;
  border-radius: 99px;
}
.lib-deck progress::-webkit-progress-bar {
  background: #f1efed;
  border-radius: 99px;
}
.lib-deck progress::-webkit-progress-value {
  background: var(--orange);
  border-radius: 99px;
}
.lib-deck progress::-moz-progress-bar {
  background: var(--orange);
  border-radius: 99px;
}
.lib-chevron {
  color: #aaa;
  font-size: 22px;
}
.lib-bar {
  min-height: 48px;
}
.lib-bar h1 {
  flex: 1;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 18px;
  font-weight: 650;
}
.lib-bar h1:has(.lib-symbol) {
  justify-content: flex-start;
}
.lib-bar .lib-symbol {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}
.lib-bar .lib-symbol svg {
  width: 17px;
}
.lib-bar > a:first-child {
  font-size: 27px;
  line-height: 1;
  color: var(--secondary);
  min-width: 32px;
}
.lib-bar button,
.manage-row button,
.lib-new button,
.lib-close,
.lib-editor-head button,
.lib-mode-list button {
  background: none;
  border: 0;
}
.lib-box {
  padding: 16px;
}
.lib-box h2 {
  font-size: 14px;
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
}
.lib-box h2 small {
  font-size: 11px;
  font-weight: 400;
}
.lib-summary {
  display: flex;
  align-items: center;
  gap: 16px;
}
.lib-ring {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: conic-gradient(var(--orange) var(--pct), #f1e7df 0);
}
.lib-ring > div {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.lib-ring b {
  font-size: 19px;
}
.lib-ring small {
  font-size: 9px;
}
.lib-summary dl {
  margin: 0;
  flex: 1;
}
.lib-summary dl div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 6px 0;
  gap: 8px;
}
.lib-summary dt {
  font-size: 12px;
  color: var(--secondary);
}
.lib-summary dd {
  font-size: 14px;
  font-weight: 650;
  margin: 0;
}
.lib-summary dd small {
  display: inline;
  font-size: 10px;
}
.lib-summary dl div:nth-child(2) dd {
  color: #288749;
}
.lib-summary dl div:last-child dd {
  color: var(--orange);
}
.lib-segments {
  display: flex;
  background: var(--line);
  overflow: hidden;
  border-radius: 99px;
  height: 8px;
  margin: 4px 0 7px;
}
.state-new {
  background: #9de4ff;
}
.state-learning {
  background: #facaa7;
}
.state-reviewing {
  background: #f7a25f;
}
.state-mastered {
  background: var(--orange);
}
.lib-state {
  padding: 7px 0;
  font-size: 14px;
}
.lib-state i {
  width: 11px;
  height: 11px;
  border-radius: 4px;
  flex: none;
}
.lib-state div {
  flex: 1;
}
.lib-state small,
.lib-stat-row small {
  font-size: 11px;
}
.lib-stat-row {
  padding: 9px 0;
  font-size: 14px;
  border-top: 1px solid var(--line);
}
.lib-stat-row button,
.lib-actions button:not(.primary):not(.lib-danger) {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 5px 10px;
}
.lib-note,
.lib-empty,
.lib-hint {
  font-size: 12px;
  color: var(--secondary);
  line-height: 1.5;
}
.lib-note {
  background: var(--tint);
  padding: 10px;
  border-radius: 9px;
}
.lib-bars {
  height: 68px;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
}
.lib-bars > div {
  flex: 1;
  text-align: center;
}
.lib-bars i {
  display: block;
  background: var(--peach);
  max-width: 28px;
  margin: auto;
  border-radius: 4px;
}
.lib-bars small {
  font-size: 10px;
  margin-top: 4px;
}
.lib-extra,
.lib-close {
  display: block;
  text-align: center;
  padding: 8px;
}
.lib-empty {
  text-align: center;
  padding: 32px 12px;
}
.lib-empty p {
  margin: 10px 0;
}
.manage-row {
  gap: 10px;
  font-size: 14px;
}
.manage-row button {
  padding: 6px;
  color: var(--secondary);
}
.manage-row .remove {
  border-radius: 50%;
  background: #fef1f1;
  color: #c33;
  width: 26px;
  height: 26px;
  padding: 0;
  font-weight: 700;
}
.manage-row .lib-symbol {
  width: 38px;
  height: 38px;
}
.lib-new {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px;
}
.lib-new label {
  flex: 1;
  font-size: 13px;
}
.lib-new input {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
}
.lib-new button {
  color: var(--orange);
  padding: 8px;
}
.lib-dialog {
  color: var(--ink);
  width: min(460px, calc(100% - 24px));
  max-height: 90dvh;
  box-sizing: border-box;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: 0 10px 32px #1e223425;
}
.lib-dialog::backdrop {
  background: rgb(0 0 0 / 44%);
}
.lib-dialog form,
.lib-dialog label {
  display: grid;
  gap: 13px;
}
.lib-dialog label {
  gap: 6px;
  color: var(--secondary);
  font-weight: 500;
  font-size: 13px;
}
.lib-dialog h2 {
  font-size: 19px;
}
.lib-dialog h3 {
  font-size: 12px;
}
.lib-dialog input:not([type='checkbox']),
.lib-dialog textarea,
.lib-dialog select {
  font: inherit;
  font-size: 16px;
  box-sizing: border-box;
  width: 100%;
  border: 1px solid #e2e2e2;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  padding: 11px 13px;
  min-width: 0;
}
.lib-dialog textarea {
  resize: vertical;
}
.lib-dialog :is([role='alert'], .lib-error),
.library [role='alert'] {
  color: #a93232;
  font-size: 13px;
}
.lib-dialog :is([role='alert'], small):empty,
.library [role='alert']:empty {
  display: none;
}
.lib-actions {
  justify-content: flex-end;
}
.lib-danger,
.lib-danger-outline {
  padding: 10px 16px;
  border: 1px solid #edc5c5;
  border-radius: 10px;
  background: white;
  color: #ac3939;
}
.lib-mode-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}
.lib-mode-list button {
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.lib-mode-list b {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: #ebfaff;
  color: #3289a9;
}
.lib-mode-list button:first-child {
  background: var(--tint);
  border-color: var(--orange);
}
.lib-mode-list button:first-child b {
  background: var(--orange);
  color: white;
}
.lib-mode-list button:last-child b {
  background: #f5eefb;
  color: #9168ae;
}
.lib-mode-list strong {
  font-size: 15px;
}
.lib-mode-list em {
  background: white;
  border-radius: 99px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--orange);
  font-style: normal;
}
.lib-handle {
  width: 38px;
  height: 4px;
  border-radius: 9px;
  background: #dedede;
  margin: 0 auto 16px;
}
.lib-tabs {
  display: flex;
  padding: 3px;
  background: #f2f2f2;
  border-radius: 10px;
  margin: 12px 0 16px;
}
.lib-tabs button {
  flex: 1;
  border: 0;
  border-radius: 8px;
  background: none;
  padding: 7px;
  font-size: 13px;
  font-weight: 600;
}
.lib-tabs button[aria-pressed='true'] {
  background: var(--orange);
  color: white;
}
.lib-editor-head button {
  min-width: 38px;
  font-size: 23px;
  color: var(--secondary);
}
.lib-editor-head [data-save] {
  font-size: 15px;
  color: var(--orange);
  font-weight: 600;
}
.lib-editor form {
  gap: 14px;
}
.lib-editor header + div[data-fields] {
  margin-top: 18px;
}
.lib-audio-input {
  position: relative;
}
.lib-audio-input input {
  padding-right: 49px !important;
}
.lib-audio-input button {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  border-radius: 99px;
  background: var(--tint);
  width: 30px;
  height: 30px;
  font-size: 11px;
  color: var(--orange);
}
.lib-select,
.lib-today {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
}
.lib-dialog .lib-select select {
  flex: 0 1 auto;
  width: auto;
  max-width: 80%;
  font-size: 14px;
  border: 0;
  padding: 4px;
}
.lib-today input {
  appearance: none;
  width: 43px;
  height: 26px;
  border-radius: 99px;
  background: #bbb;
  position: relative;
}
.lib-today input:checked {
  background: var(--orange);
}
.lib-today input:after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
}
.lib-today input:checked:after {
  left: 20px;
}
.lib-preview {
  font-size: 13px;
}
.lib-preview > strong {
  color: #288749;
}
.lib-preview h3 {
  margin: 10px 0;
}
.lib-preview p {
  padding: 5px;
  border-top: 1px solid var(--line);
}
.lib-preview p span,
.word-entry small {
  color: var(--orange);
}
.lib-dialog .lib-file {
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 12px;
  border: 1.5px dashed #d8d8d8;
  border-radius: 12px;
  background: white;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.lib-file::before {
  content: '';
  width: 16px;
  height: 16px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2v13m-4-4 4 4 4-4M7 8H4v13h16V8h-3'/%3E%3C/svg%3E") center / contain no-repeat;
}
.lib-dialog .lib-file input[type='file'] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.lib-file:focus-within {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
.word-groups {
  display: grid;
  gap: 14px;
}
.word-groups h2 {
  margin: 2px 0 7px;
  color: var(--secondary);
  font-size: 13px;
}
.word-groups .lib-box {
  padding: 0 13px;
}
.word-entry {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 11px 0;
  border: 0;
  background: transparent;
}
.word-entry + .word-entry {
  border-top: 1px solid var(--line);
}
.word-entry > span:first-child {
  flex: 1;
}
.word-entry em {
  font-size: 11px;
  font-style: normal;
  text-transform: capitalize;
  border-radius: 99px;
  background: var(--tint);
  padding: 3px 8px;
}
@media (max-width: 600px) {
  .native-sheet:has(.lib-mode-list),
  .lib-editor {
    margin: auto auto 0;
    width: 100%;
    max-height: 94dvh;
    border-radius: 22px 22px 0 0;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  .lib-editor {
    min-height: 88dvh;
  }
}

.lib-box:has(.lib-state) h2,
.lib-box:has(.lib-bars) h2,
.lib-box:has(.lib-stat-row) h2 {
  text-transform: uppercase;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 1.4px;
}
.lib-box h2 small {
  text-transform: none;
  letter-spacing: normal;
}
.lib-box:has(.lib-bars) h2,
.lib-box:has(.lib-stat-row) h2 {
  justify-content: center;
}
.lib-stat-row:first-of-type {
  border-top: none;
}
.lib-state {
  padding: 6px 0;
}
