/* E-book maker (wah-kit.com/ebook/) */
.eb { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.eb > *, .eb-main > * { min-width: 0; max-width: 100%; }
.eb .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.eb-signin { text-align: center; padding: 32px 18px; }
.eb-signin p { color: var(--ink-soft); max-width: 520px; margin: 10px auto 18px; }
body.eb-inbook main.wrap { padding-top: 10px; }
.eb-toast { position: fixed; left: 50%; bottom: calc(18px + var(--tabbar, 0px)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 90; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14.5px; transition: .2s; box-shadow: 0 8px 24px rgba(29,26,57,.25); }
.eb-toast.on { opacity: 1; transform: translate(-50%, 0); }
.eb-tiny { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.eb-sub { font: 700 12px/1.2 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 10px 0 6px; }
.eb-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.eb-up { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; }

/* my books */
.eb-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.eb-head h2 { margin: 0; font-size: 22px; }
.eb-head .muted { font-size: 14px; color: var(--muted); flex: 1; }
.eb-new { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.eb-new label, .eb-f { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; color: var(--ink-soft); min-width: 0; }
.eb input:not([type=checkbox]):not([type=range]):not([type=file]), .eb select, .eb textarea {
  font: 16px var(--font-body); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; min-height: 44px; width: 100%; }
.eb textarea { resize: vertical; line-height: 1.45; }
.eb-f small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.eb-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.eb-card { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.eb-card:hover { border-color: #B9B6CC; color: var(--ink); }
.eb-thumb { width: 60px; height: 96px; border-radius: 4px; object-fit: cover; flex: none; box-shadow: 0 2px 8px rgba(29,26,57,.2); }
.eb-blank { display: flex; align-items: center; justify-content: center; text-align: center; padding: 4px; font: 700 10px/1.2 Georgia, serif; color: #fff; background: linear-gradient(160deg, #0F2A44, #1F5F8B); overflow: hidden; }
.eb-ci { display: flex; flex-direction: column; min-width: 0; }
.eb-ci b { font-size: 16.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.eb-ci small { color: var(--muted); font-size: 13px; }
.eb-hint { font-size: 14px; color: var(--ink-soft); margin: 4px 0 0; }

/* a book: top line and tabs */
.eb-top { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.eb-back { flex: none; text-decoration: none; font-weight: 700; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; }
.eb-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.eb-saved { flex: none; font-size: 13px; color: var(--muted); }
.eb-saved.saved { color: #15803D; }
.eb-saved.error { color: #B91C1C; font-weight: 700; }
.eb-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin: 0 -4px; padding: 0 4px; }
.eb-tabs::-webkit-scrollbar { display: none; }
.eb-tabs a { flex: none; padding: 9px 12px; text-decoration: none; color: var(--ink-soft); font-weight: 700; font-size: 14.5px; border-bottom: 3px solid transparent; white-space: nowrap; }
.eb-tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }

/* Write */
.eb-write { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.eb-side { position: sticky; top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px 12px; max-height: calc(100dvh - 30px); overflow-y: auto; }
.eb-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.eb-chbtn { display: none; }
.eb-chs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.eb-chs li { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.eb-chs li.on { background: var(--accent-soft); }
.eb-chs li.dragging { opacity: .6; outline: 2px dashed #8FB2F5; }
.eb-chs a { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; padding: 7px 4px; color: var(--ink); text-decoration: none; font-size: 14.5px; }
.eb-chs a .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.eb-chs a .n { color: var(--muted); margin-right: 2px; }
.eb-chs a small { width: 100%; color: var(--muted); font-size: 12px; padding-left: 1.3em; }
.eb-grip { flex: none; width: 26px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: grab; color: #9A97B0; touch-action: none; user-select: none; font-size: 18px; }
.eb-x { flex: none; width: 34px; height: 34px; border: none; background: transparent; border-radius: 8px; cursor: pointer; opacity: .45; font-size: 14px; }
.eb-x:hover { opacity: 1; background: #FEE2E2; }
.eb-add { width: 100%; margin-top: 8px; min-height: 40px; }
.eb-chtitle { font: 700 20px/1.3 Georgia, serif !important; }
.eb-toolrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; position: sticky; top: 0; z-index: 5; background: var(--ground); padding: 4px 0; }
.eb-tools { display: flex; gap: 4px; align-items: center; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.eb-tools::-webkit-scrollbar { display: none; }
.eb select.eb-blk { width: auto; min-height: 36px; height: 36px; padding: 0 8px; font-size: 14px; flex: none; }
.eb-tb { flex: none; min-width: 36px; height: 36px; padding: 0 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font: 600 16px var(--font-body); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; }
.eb-tb:hover { background: #F1F5F9; }
.eb-tb.on { background: var(--accent-soft); border-color: #F5B7A5; }
.eb-langbox { flex: none; }
.eb-ed { min-height: max(320px, calc(100dvh - 330px)); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; outline: none;
  font: 18px/1.65 Georgia, 'Noto Serif', 'Nirmala UI', serif; color: #1A1A1A; position: relative; overflow-wrap: anywhere; }
.eb-ed:focus { border-color: #8FB2F5; box-shadow: 0 0 0 3px rgba(143,178,245,.3); }
.eb-ed p { margin: 0 0 .55em; }
.eb-ed h2 { font-size: 1.3em; margin: 1em 0 .4em; }
.eb-ed h3 { font-size: 1.1em; margin: .9em 0 .3em; }
.eb-ed blockquote { margin: .6em 1.4em; font-style: italic; color: #333; border-left: 3px solid var(--line); padding-left: .8em; }
.eb-ed[dir=rtl] blockquote { border-left: 0; border-right: 3px solid var(--line); padding: 0 .8em 0 0; }
.eb-ed .center { text-align: center; }
.eb-ed .right { text-align: right; }
.eb-ed hr.scene { border: 0; height: 1.6em; margin: .6em 0; text-align: center; }
.eb-ed hr.scene::after { content: '⁂'; color: #777; }
.eb-ed figure { margin: .8em 0; text-align: center; }
.eb-ed img { max-width: 100%; height: auto; border-radius: 4px; }
.eb-ed img:hover { outline: 2px solid #8FB2F5; }
.eb-ed .eb-loading { color: var(--muted); font: 15px var(--font-body); }
.eb-ed:has(> p:only-child > br:only-child)::before { content: attr(data-ph); position: absolute; top: 18px; left: 22px; right: 22px; color: #9A97B0; pointer-events: none; font-size: 16px; }
.eb-pn { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 14px; }
.eb-pn a { text-decoration: none; font-weight: 600; max-width: 35%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eb-words { color: var(--muted); font-size: 13px; text-align: center; }
.eb-chdlg { width: min(460px, calc(100vw - 20px)); max-height: calc(100dvh - 40px); padding: 6px 12px 14px; border: 1px solid var(--line); border-radius: 16px; }
.eb-chdlg::backdrop { background: rgba(29,26,57,.45); }
.eb-dlghead { display: flex; align-items: center; justify-content: space-between; font-size: 17px; }
@media (max-width: 899px) {
  .eb-write { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
  .eb-tabs { gap: 0; }
  .eb-tabs a { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; padding: 4px 2px 6px; font-size: 12.5px; line-height: 1.2; }
  .eb-tabs a span { font-size: 18px; }
  .eb-side { display: none; }
  .eb-chbtn { display: flex; align-items: center; gap: 2px; width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: 600 15px var(--font-body); color: var(--ink); cursor: pointer; text-align: start; }
  .eb-chbtn .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .eb-chtitle { font-size: 18px !important; min-height: 40px !important; padding: 6px 10px !important; }
  .eb-ed { padding: 14px; font-size: 17px; min-height: max(300px, calc(100dvh - 300px)); }
  .eb-ed:has(> p:only-child > br:only-child)::before { top: 14px; left: 14px; }
  .eb-toolrow .eb-langbox .pickbtn { max-width: 130px; }
}

/* Details */
.eb-details { display: flex; flex-direction: column; gap: 10px; max-width: 820px; }
.eb-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.eb-sec > summary { cursor: pointer; padding: 14px 16px; font-weight: 800; font-size: 16px; list-style: none; display: flex; justify-content: space-between; }
.eb-sec > summary::after { content: '▾'; color: var(--muted); }
.eb-sec[open] > summary::after { content: '▴'; }
.eb-sec > summary::-webkit-details-marker { display: none; }
.eb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; padding: 0 16px 16px; }
.eb-grid > .eb-f:has(textarea), .eb-grid > .eb-check, .eb-grid > .eb-tiny { grid-column: 1 / -1; }
.eb-check { display: flex; gap: 8px; align-items: center; font-size: 15px; }
.eb-check input { width: 20px; height: 20px; }
.eb-danger { padding: 6px 0 0; }
.eb-del { color: #B91C1C; }

/* Cover */
.eb-cover { display: grid; grid-template-columns: minmax(200px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.eb-cvbox { position: sticky; top: 10px; }
.eb-cv { width: 100%; aspect-ratio: 1600 / 2560; height: auto; display: block; border-radius: 6px; box-shadow: 0 8px 28px rgba(29,26,57,.28); background: #ddd; object-fit: cover; }
.eb-cvctl { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.eb-sw { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.eb-swb { width: 46px; height: 46px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; font: 700 15px Georgia, serif; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.eb-swb.on { border-color: var(--accent); box-shadow: 0 0 0 2px #fff inset; }
.eb-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.eb-seg button { border: 0; background: transparent; padding: 0 14px; min-height: 38px; font: 600 14px var(--font-body); color: var(--ink-soft); cursor: pointer; }
.eb-seg button + button { border-left: 1px solid var(--line); }
.eb-seg button.on { background: var(--ink); color: #fff; }
.eb-dim { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.eb-cvstate { margin: 8px 0 2px; font-size: 14px; color: var(--muted); }
.eb-cvstate.ok { color: #15803D; font-weight: 600; }
.eb-cvstate.bad { color: #B91C1C; }
@media (max-width: 899px) {
  .eb-cover { grid-template-columns: 38% minmax(0, 1fr); gap: 12px; }
  .eb-cvctl .btn { min-height: 40px; padding: 0 12px; font-size: 14px; }
  .eb-swb { width: 38px; height: 38px; }
  .eb-seg button { padding: 0 10px; }
}

/* Preview */
.eb-pvbar { align-self: flex-start; }
.eb-pv { margin: 0 auto; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; color: #111; max-height: calc(100dvh - 190px); overflow-y: auto; transition: max-width .2s; }
.eb-pv-phone { max-width: 390px; }
.eb-pv-tablet { max-width: 600px; background: #FBF8F1; }
.eb-pv-wide { max-width: 860px; }
.eb-bk .eb-pg { padding: 0 0 1.4em; margin-bottom: 1.6em; border-bottom: 1px dashed #DDD; }
.eb-bk .eb-pcov { text-align: center; margin-bottom: 1.6em; }
.eb-bk .eb-pcov img { max-width: 100%; max-height: 70vh; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.eb-bk .tp, .eb-bk .cp, .eb-bk .ded { margin-top: 1em; }

/* Publish */
.eb-publish { display: flex; flex-direction: column; gap: 12px; max-width: 860px; }
.eb-pub { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.eb-pub h3 { margin: 0 0 8px; font-size: 17px; }
.eb-checks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 14.5px; }
.eb-checks li.ok span { color: #15803D; font-weight: 800; }
.eb-checks li.todo span { color: #B45309; font-weight: 800; }
.eb-where { margin: 0 0 10px; font-size: 14.5px; }
.eb-dl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.eb-dlb { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: start; padding: 10px 12px; min-height: 64px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; color: var(--ink); text-decoration: none; font: 15px var(--font-body); }
.eb-dlb:hover { border-color: #B9B6CC; background: #FAFAFD; color: var(--ink); }
.eb-dlb:disabled { opacity: .55; cursor: wait; }
.eb-dlb small { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.eb-dlb.locked { background: #F7F7FA; }
.eb-prog { margin: 6px 0 0; font-size: 14px; color: var(--blue); min-height: 0; }
.eb-prog:empty { display: none; }
.eb-share { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.eb-share p { margin: 0 0 8px; font-size: 14.5px; }
.eb-url { flex: 1 1 220px; font-size: 14px !important; }
.eb-linkoff { margin-top: 6px; border: 0; background: none; color: #B91C1C; font: 13px var(--font-body); cursor: pointer; padding: 4px 0; }
.eb-guides { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.eb-guides h2 { font-size: 20px; margin: 10px 0 2px; }
.eb-publish .eb-guides h2 { display: none; }
.eb-g { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.eb-g > summary { cursor: pointer; padding: 13px 16px; font-weight: 800; font-size: 16px; }
.eb-steps { margin: 0; padding: 0 18px 10px 40px; font-size: 15px; }
.eb-steps li { margin: 0 0 8px; }
.eb-g .eb-tiny { padding: 0 16px 14px; }
@media (max-width: 899px) {
  .eb-dl { grid-template-columns: 1fr 1fr; }
  .eb-checks { grid-template-columns: 1fr; }
  .eb-grid { grid-template-columns: 1fr; }
  .eb-new { grid-template-columns: 1fr; }
}

/* the language button and picker (as on the Group Message Planner) */
.pickbtn { display: inline-flex; align-items: center; gap: 6px; height: 36px; max-width: 220px; min-width: 0; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: 500 13.5px var(--font-body); cursor: pointer; }
.pickbtn:hover { background: #F8FAFC; }
.pickbtn .val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pickbtn svg { flex: none; }
#langDialog { width: min(520px, calc(100vw - 24px)); max-height: min(640px, calc(100dvh - 48px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: #fff; box-shadow: 0 20px 60px rgba(29,26,57,.25); }
#langDialog[open] { display: flex; flex-direction: column; }
#langDialog::backdrop { background: rgba(29,26,57,.45); }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 16px; }
.dlg-head h2 { flex: 1; font-size: 19px; margin: 0; }
.iconbtn { width: 44px; height: 44px; border: none; background: transparent; border-radius: 10px; cursor: pointer; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.iconbtn:hover { background: #F1F5F9; }
#langSearch { margin: 0 16px 10px; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; font: 16px var(--font-body); color: var(--ink); }
#langList { overflow-y: auto; padding: 0 8px 12px; display: flex; flex-direction: column; }
.pick { text-align: start; min-height: 46px; padding: 10px 12px; border: none; border-radius: 10px; background: transparent; font: 15px var(--font-body); color: var(--ink); cursor: pointer; }
.pick:hover { background: #F1F5F9; }
.pick.on { background: #FDE7E0; font-weight: 700; }
#langList .none { padding: 12px; color: #6B7280; margin: 0; }
