/* Vie 世界书独立主链样式：统一使用 Vie 全局导航栏、开关与图标系统。 */
.vie-worldbook-app {
  --wb-card: var(--vie-page-surface-strong);
  --wb-text: var(--vie-text-primary);
  --wb-secondary: var(--vie-text-muted);
  --wb-line: rgba(203,203,203,.55);
  width: 100%;
  min-width: 0;
  min-height: 0;
  color: var(--wb-text);
  background: transparent;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.vie-worldbook-shell {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: transparent;
}
.vie-worldbook-app button { font-family: inherit; }
.vie-worldbook-app input,
.vie-worldbook-app textarea,
.vie-worldbook-app select { font: inherit; }
.vie-worldbook-app input,
.vie-worldbook-app textarea { user-select: text; -webkit-user-select: text; }
.vie-worldbook-view {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transform: translateX(100%);
  transition: transform .38s cubic-bezier(.32,.72,.24,1), opacity .2s ease;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.vie-worldbook-view.is-visible { opacity: 1; pointer-events: auto; transform: translateX(0); }
.vie-worldbook-library { z-index: 2; }
.vie-worldbook-detail { z-index: 3; }
.vie-worldbook-editor { z-index: 4; }
.vie-worldbook-book-editor { z-index: 5; }
.vie-worldbook-content {
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 100%;
  margin: 0;
  padding: 0 var(--app-inline-inset) calc(30px + var(--vie-safe-bottom));
}
.vie-worldbook-nav {
  min-width: 0;
  margin-bottom: 14px;
}
.vie-worldbook-nav .vie-app-nav-leading {
  gap: 10px;
}
.vie-worldbook-library .vie-worldbook-nav-leading { max-width: calc(100% - 42px); }
.vie-worldbook-detail .vie-worldbook-nav-leading { max-width: calc(100% - 152px); }
.vie-worldbook-editor .vie-worldbook-nav-leading,
.vie-worldbook-book-editor .vie-worldbook-nav-leading { max-width: calc(100% - 42px); }
.vie-worldbook-actions { min-width: 0; }
.vie-worldbook-icon-button,
.vie-worldbook-nav-action {
  width: 38px;
  height: 42px;
  flex: 0 0 auto;
}
.vie-worldbook-data-status { margin-top: -4px; }

.vie-worldbook-icon-button svg,
.vie-worldbook-nav-action svg {
  width: var(--vie-nav-action-icon-size);
  height: var(--vie-nav-action-icon-size);
}
.vie-worldbook-tool {
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  color: var(--vie-text-primary);
  background: var(--vie-page-surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  font-size:calc(14px * var(--vie-font-scale));
  cursor: pointer;
}
.vie-worldbook-tool.is-danger { width: 100%; color: #ff3b30; }
.vie-worldbook-tool.is-destructive { width: 100%; color: #d85d59; }
.vie-worldbook-folder-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 16px 12px;
}
.vie-worldbook-folder-card {
  --worldbook-folder-ink: #2e2d70;
  min-width: 0;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 15px;
  color: var(--vie-text-primary);
  background: transparent;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.vie-worldbook-folder-art-shell { width: 100%; position: relative; display: block; aspect-ratio: 512/406; }
.vie-worldbook-folder-art {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  display: block;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.08));
}
.vie-worldbook-folder-glass-front {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  height: 50%;
  overflow: hidden;
  border: var(--glass-border);
  border-radius: 17px 17px 15px 15px;
  background: var(--vie-page-surface);
  box-shadow: var(--app-icon-shadow), inset 0 1px 0 rgba(255,255,255,.55);
  -webkit-backdrop-filter: var(--soft-glass-blur);
  backdrop-filter: var(--soft-glass-blur);
  pointer-events: none;
}
.vie-worldbook-folder-front-content {
  position: absolute;
  right: 7.5%;
  bottom: 7.2%;
  left: 12.5%;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  color: var(--worldbook-folder-ink);
  pointer-events: none;
}
.vie-worldbook-folder-meta { min-width: 0; display: flex; flex: 1 1 auto; flex-direction: column; align-items: flex-start; gap: 3px; }
.vie-worldbook-folder-name { max-width: 100%; overflow: hidden; color: inherit; font-size:calc(15px * var(--vie-font-scale)); font-weight: 600; line-height: 1.22; text-overflow: ellipsis; white-space: nowrap; }
.vie-worldbook-folder-kind { color: inherit; font-size:calc(12px * var(--vie-font-scale)); font-weight: 500; line-height: 1.2; }
.vie-worldbook-folder-editor {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  margin: -3px -4px -3px 4px;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
}
.vie-worldbook-folder-editor svg { width: 12px; height: 12px; display: block; fill: currentColor; }

.vie-worldbook-empty {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 20px;
  color: var(--wb-secondary);
  text-align: center;
}
.vie-worldbook-empty svg { width: 42px; height: 42px; margin-bottom: 4px; fill: #c7c7cc; }
.vie-worldbook-empty strong { color: var(--vie-text-primary); font-size:calc(16px * var(--vie-font-scale)); font-weight: 500; }
.vie-worldbook-empty span { max-width: 280px; font-size:calc(13px * var(--vie-font-scale)); line-height: 1.45; }
.vie-worldbook-summary {
  display: grid;
  gap: 0;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--wb-card);
}
.vie-worldbook-summary-row {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 15px;
  color: var(--wb-text);
  font-size:calc(15px * var(--vie-font-scale));
}
.vie-worldbook-summary-row + .vie-worldbook-summary-row { border-top: .5px solid var(--wb-line); }
.vie-worldbook-summary-label { color: var(--wb-secondary); }
.vie-worldbook-entry-list { display: grid; gap: 10px; }
.vie-worldbook-entry-card {
  --entry-book-color: #5856d6;
  width: 100%;
  min-height: 96px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  overflow: hidden;
  padding: 14px 52px 14px 16px;
  border: 0;
  border-radius: 14px;
  color: var(--wb-text);
  background: var(--wb-card);
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
  text-align: left;
  cursor: pointer;
}
.vie-worldbook-entry-card::after {
  width: 15px;
  height: 28px;
  position: absolute;
  top: 0;
  right: 17px;
  border-radius: 0 0 4px 4px;
  background: var(--entry-book-color);
  clip-path: polygon(0 0,100% 0,100% 100%,50% 78%,0 100%);
  content: "";
}
.vie-worldbook-entry-name { max-width: 100%; overflow: hidden; color: var(--wb-text); font-size:calc(16px * var(--vie-font-scale)); font-weight: 500; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.vie-worldbook-entry-description { display: -webkit-box; overflow: hidden; color: var(--wb-secondary); font-size:calc(13px * var(--vie-font-scale)); line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.vie-worldbook-entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--wb-secondary); font-size:calc(12px * var(--vie-font-scale)); line-height: 1.2; }
.vie-worldbook-entry-meta span + span::before { width: 4px; height: 4px; display: inline-block; margin: 0 7px 2px 0; border-radius: 50%; background: var(--vie-text-faint); content: ""; }
.vie-worldbook-field-label { display: block; margin: 0 0 7px; color: var(--vie-text-muted); font-size:calc(13px * var(--vie-font-scale)); font-weight: 500; }
.vie-worldbook-editor-input,
.vie-worldbook-editor-select,
.vie-worldbook-editor-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 0;
  border-radius: 10px;
  outline: 0;
  color: var(--wb-text);
  background: rgba(246,246,247,.86);
  font-size:calc(16px * var(--vie-font-scale));
  user-select: text;
  -webkit-user-select: text;
}
.vie-worldbook-segment { height: 37px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-bottom: 16px; padding: 3px; border-radius: 10px; background: var(--vie-page-soft-surface); }
.vie-worldbook-segment button { border: 0; border-radius: 8px; color: var(--vie-text-muted); background: transparent; font-size:calc(14px * var(--vie-font-scale)); cursor: pointer; }
.vie-worldbook-segment button[aria-pressed="true"] { color: var(--wb-text); background: var(--vie-page-surface-strong); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.vie-worldbook-role-note { margin: 8px 2px 0; color: var(--wb-secondary); font-size:calc(10px * var(--vie-font-scale)); line-height: 1.45; }
.vie-worldbook-color-row { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.vie-worldbook-color-choice,
.vie-worldbook-custom-color { width: 28px; height: 28px; position: relative; display: block; overflow: hidden; padding: 0; border-radius: 50%; cursor: pointer; }
.vie-worldbook-color-choice { border: 0; background: var(--worldbook-choice); }
.vie-worldbook-color-choice::after { position: absolute; inset: 5px; border: 2px solid #fff; border-radius: 50%; content: ""; opacity: 0; }
.vie-worldbook-color-choice.is-selected::after { opacity: 1; }
.vie-worldbook-custom-color { margin-left: auto; border: 2px solid #d1d1d6; background: conic-gradient(#ff3b30,#fc0,#34c759,#007aff,#af52de,#ff3b30); }
.vie-worldbook-custom-color input { width: 100%; height: 100%; display: block; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.vie-worldbook-editor-content { padding-bottom: 48px; }
.vie-worldbook-editor-group {
  margin-bottom: 16px;
  padding: 15px;
  border: .5px solid rgba(203,203,203,.28);
  border-radius: 14px;
  background: var(--wb-card);
  box-shadow: 0 7px 20px rgba(0,0,0,.055),0 2px 5px rgba(0,0,0,.035);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
}
.vie-worldbook-editor-input { height: 43px; padding: 0 12px; }
.vie-worldbook-editor-select { height: 43px; padding: 0 38px 0 12px; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg,transparent 50%,var(--vie-text-muted) 50%),linear-gradient(135deg,var(--vie-text-muted) 50%,transparent 50%); background-position: calc(100% - 19px) 19px,calc(100% - 14px) 19px; background-size: 5px 5px,5px 5px; background-repeat: no-repeat; }
.vie-worldbook-entry-settings-group { padding: 0; overflow: hidden; }
.vie-worldbook-entry-settings-row { min-height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 15px; }
.vie-worldbook-entry-settings-row + .vie-worldbook-entry-settings-row,
.vie-worldbook-keyword-input-wrap + .vie-worldbook-entry-settings-row { border-top: .5px solid var(--wb-line); }
.vie-worldbook-entry-settings-label { flex: 0 0 auto; color: var(--wb-text); font-size:calc(16px * var(--vie-font-scale)); line-height: 1.25; }
.vie-worldbook-entry-settings-group .vie-worldbook-editor-input,
.vie-worldbook-entry-settings-group .vie-worldbook-editor-select { min-width: 0; height: 51px; flex: 1; padding-top: 0; padding-bottom: 0; border-radius: 0; background-color: transparent; text-align: right; }
.vie-worldbook-switch { margin-left: auto; }
.vie-worldbook-keyword-input-wrap { max-height: 0; overflow: hidden; opacity: 0; transition: max-height .22s ease,opacity .18s ease; }
.vie-worldbook-keyword-group.is-expanded .vie-worldbook-keyword-input-wrap { max-height: 160px; opacity: 1; }
.vie-worldbook-keyword-row { display: block; min-height: 0; padding-top: 12px; padding-bottom: 14px; border-top: .5px solid var(--wb-line); }
.vie-worldbook-editor-textarea { min-height: 86px; resize: vertical; padding: 11px 12px; line-height: 1.45; }
.vie-worldbook-keywords { min-height: 75px; }
.vie-worldbook-body-group { min-height: 286px; display: flex; flex-direction: column; }
.vie-worldbook-content-textarea { min-height: 266px; flex: 1; }
.vie-worldbook-help { margin: -8px 4px 16px; color: var(--wb-secondary); font-size:calc(12px * var(--vie-font-scale)); line-height: 1.5; }
.vie-worldbook-toast { min-width: 120px; max-width: calc(100% - 52px); position: absolute; left: 50%; bottom: 28px; z-index: 30; padding: 10px 14px; border-radius: 999px; color: #fff; background: rgba(28,28,30,.9); font-size:calc(13px * var(--vie-font-scale)); line-height: 1.3; text-align: center; opacity: 0; pointer-events: none; transform: translate(-50%,12px); transition: opacity .2s ease,transform .2s ease; }
.vie-worldbook-toast.is-visible { opacity: 1; transform: translate(-50%,0); }
.vie-worldbook-file-input { width: 0; height: 0; position: absolute; overflow: hidden; opacity: 0; pointer-events: none; }
.vie-worldbook-folder-card:focus-visible,
.vie-worldbook-icon-button:focus-visible,
.vie-worldbook-switch:focus-visible,
.vie-worldbook-entry-card:focus-visible { outline: 2px solid rgba(0,122,255,.45); outline-offset: 2px; }
@media (max-width: 340px) {
  .vie-worldbook-folder-grid { gap: 14px 9px; }
}
