:root {
  --bg: #ffffff;
  --card: #ffffff;
  --card-border: #e3e4e8;
  --text: #1f2328;
  --muted: #6b7280;
  --pill: #eceef1;
  --pill-text: #4b5563;
  --on: #1f2328;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --bar-h: 56px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
body { min-height: 100dvh; touch-action: manipulation; }
html.locked-scroll, html.locked-scroll body { overflow: hidden; }
button, .card, .nav-item, .label-btn, .pill-toggle {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  font: inherit; color: inherit;
}
input { font-size: 16px; } /* >=16px avoids iOS focus zoom */
[hidden] { display: none !important; }
svg { display: block; }

#app { min-height: 100dvh; padding: 0 var(--safe-right) calc(72px + var(--safe-bottom)) var(--safe-left); }
#app.mode-me .library-chrome,
#app.mode-me #floatBar,
#app.mode-me #filterLine,
#app.mode-me #listView { display: none !important; }
#app.mode-library .me-home { display: none !important; }
#app.mode-me {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding-bottom: 0;
}
#app.mode-library { overflow-x: hidden; }

/* Floating search bar */
.float-bar.library-chrome, .filter-line.library-chrome, main.library-chrome { }
.float-bar {
  position: fixed; z-index: 20; left: 0; right: 0; top: 0;
  padding: calc(8px + var(--safe-top)) calc(12px + var(--safe-right)) 8px calc(12px + var(--safe-left));
  transition: transform .28s var(--ease);
  pointer-events: none;
}
.float-bar.hide { transform: translateY(calc(-100% - 4px)); }
.search-pill {
  pointer-events: auto; max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 4px; height: var(--bar-h);
  background: #f1f3f4; border-radius: 28px; padding: 0 6px;
  box-shadow: 0 1px 3px rgba(60,64,67,.18), 0 2px 8px rgba(60,64,67,.08);
}
.search-fake {
  flex: 1; height: 100%; border: 0; background: transparent; text-align: left;
  font-size: 16px; color: #5f6368; padding: 0 6px; cursor: text;
}
.round-btn {
  width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 50%;
  background: transparent; display: grid; place-items: center; color: #3c4043; cursor: pointer;
  position: relative; overflow: hidden;
}
.text-btn {
  border: 0; background: transparent; color: #3c4043; font-size: 15px; font-weight: 600;
  padding: 8px 12px; border-radius: 18px; cursor: pointer; position: relative; overflow: hidden;
}

.filter-line {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  max-width: 720px; margin: 0 auto;
  padding: calc(var(--bar-h) + 22px + var(--safe-top)) 16px 4px;
  min-height: 28px; font-size: 13px;
}
.muted { color: var(--muted); }

/* Cards: masonry grid / list */
.cards { max-width: 720px; margin: 0 auto; padding: 6px 8px calc(140px + var(--safe-bottom)); }
.cards.grid { column-count: 2; column-gap: 8px; }
.cards.list { column-count: 1; padding: 6px 12px calc(140px + var(--safe-bottom)); }
.card {
  display: block; width: 100%; text-align: left; break-inside: avoid; margin: 0 0 8px;
  border: 1px solid var(--card-border); background: var(--card); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; position: relative; overflow: hidden;
  transition: transform .14s var(--ease), box-shadow .14s var(--ease);
}
.card.pressed { transform: scale(.97); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.card.ghost { visibility: hidden; }
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 2px; line-height: 1.35; word-break: break-word; }
.card-en { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.card-snip { margin: 0 0 8px; color: #3c4043; font-size: 13px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cards.list .card-snip { -webkit-line-clamp: 2; }
.card-tags, .detail-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pill { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--pill); color: var(--pill-text); }
.tag-pill.local { background: #e2e6eb; }
.card-meta { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 15px; column-span: all; }

/* Ripple */
.ripple { position: absolute; border-radius: 50%; pointer-events: none; background: rgba(60,64,67,.14);
  transform: scale(0); animation: ripple .5s var(--ease) forwards; }
/* nav/label keep overflow:visible so CJK glyphs are not clipped; ripples may slightly spill */
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
.press:active { background-color: rgba(60,64,67,.08); }

/* Drawer */
.edge-zone { position: fixed; left: 0; top: 0; bottom: 0; width: 22px; z-index: 15; }
.scrim, .sheet-scrim {
  position: fixed; inset: 0; background: rgba(32,33,36,.32); opacity: 0; pointer-events: none;
  transition: opacity .28s var(--ease); z-index: 30;
}
.scrim.on, .sheet-scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 55; width: min(84vw, 340px);
  background: #fff; transform: translateX(-102%); transition: transform .3s var(--ease);
  padding: calc(12px + var(--safe-top)) 10px calc(16px + var(--safe-bottom)) calc(10px + var(--safe-left));
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  border-radius: 0 16px 16px 0; box-shadow: 4px 0 24px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
  isolation: isolate; -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
html.drawer-open .float-bar,
html.drawer-open .filter-line { visibility: hidden; pointer-events: none; }
.drawer.open { transform: translateX(0); }
.drawer.dragging, .scrim.dragging { transition: none; }
.drawer-brand { font-size: 20px; font-weight: 600; padding: 10px 14px 14px; letter-spacing: -.01em; }
.drawer-sub { font-size: 12px; color: var(--muted); padding: 14px 14px 6px; letter-spacing: .04em; }
.nav-item {
  display: flex; align-items: center; width: 100%; text-align: left; border: 0;
  background: #fff; color: var(--text);
  padding: 14px 16px; min-height: 52px; border-radius: 0 24px 24px 0;
  font-size: 15px; font-weight: 600; line-height: 24px; letter-spacing: 0;
  cursor: pointer; position: relative; overflow: hidden; flex-shrink: 0;
  -webkit-font-smoothing: antialiased; text-decoration: none !important;
  z-index: 1;
}
.nav-item.on { background: #feefc3; }
.drawer-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid #f0f0f2; }
.label-tree { display: flex; flex-direction: column; }
.label-row { display: flex; align-items: center; }
.label-btn {
  flex: 1; text-align: left; border: 0; background: transparent;
  padding: 14px 10px 14px 16px; min-height: 52px;
  border-radius: 0 24px 24px 0; font-size: 15px; font-weight: 600; line-height: 24px;
  cursor: pointer; position: relative; overflow: hidden;
  display: flex; align-items: center;
}
.label-btn.child { padding-left: 34px; font-weight: 500; font-size: 14px; }
.label-btn.on { background: #feefc3; }
.chev {
  width: 80px; min-height: 48px; align-self: stretch; flex-shrink: 0; border: 0; background: transparent;
  border-radius: 0; display: flex; align-items: center; justify-content: flex-end; padding: 0 10px 0 0;
  cursor: pointer; color: #5f6368; position: relative; overflow: visible;
}
.chev svg { transition: transform .22s var(--ease); }
.chev.open svg { transform: rotate(90deg); }
.chev-spacer { width: 80px; flex-shrink: 0; }
.kids { overflow: hidden; transition: height .24s var(--ease); }

/* Search view */
.search-view {
  position: fixed; inset: 0; z-index: 50; background: #fff; display: flex; flex-direction: column;
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s var(--ease), transform .2s var(--ease);
  padding: 0 var(--safe-right) 0 var(--safe-left);
}
.search-view.open { opacity: 1; transform: none; pointer-events: auto; }
.search-head {
  display: flex; align-items: center; gap: 4px; margin: calc(8px + var(--safe-top)) 12px 0;
  height: var(--bar-h); background: #f1f3f4; border-radius: 28px; padding: 0 6px;
}
#search { flex: 1; border: 0; background: transparent; outline: none; height: 100%; padding: 0 4px; -webkit-appearance: none; }
#search::-webkit-search-cancel-button { display: none; }
.search-view .filter-line { padding: 10px 16px 2px; }
#searchResults { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; width: 100%;
  padding-bottom: calc(24px + var(--safe-bottom)); }

/* Detail (shared-element expand via clip-path) */
.detail {
  position: fixed; inset: 0; z-index: 60; background: #fff; display: flex; flex-direction: column;
  visibility: hidden; pointer-events: none; will-change: clip-path;
}
.detail.open { visibility: visible; pointer-events: auto; }
.detail.anim { transition: clip-path .34s var(--ease), border-radius .34s var(--ease); }
.detail .detail-bar, .detail .detail-scroll { transition: opacity .2s ease; }
.detail.fading .detail-bar, .detail.fading .detail-scroll { opacity: 0; }
.detail-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(6px + var(--safe-top)) calc(8px + var(--safe-right)) 4px calc(8px + var(--safe-left));
}
.detail-scroll { flex: 1; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#detailBody, #detailBody .section, #detailBody .story { max-width: 100%; overflow-x: hidden; overflow-wrap: anywhere; word-break: break-word; }
#detailBody { max-width: 720px; margin: 0 auto;
  padding: 4px calc(20px + var(--safe-right)) calc(40px + var(--safe-bottom)) calc(20px + var(--safe-left)); }
#detailBody h2 { margin: 4px 0 2px; font-size: 24px; letter-spacing: -.01em; line-height: 1.3; }
#detailBody .en { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
#detailBody .detail-tags { margin-bottom: 12px; }
.section { margin: 18px 0; }
.section h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.section p, .section li { font-size: 15px; line-height: 1.65; margin: 0; -webkit-user-select: text; user-select: text; }
.section ul { margin: 0; padding-left: 1.15em; }
.section li + li { margin-top: 6px; }
.ing-line { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f1f1f3; font-size: 15px; }
.ing-line:last-child { border-bottom: 0; }
.ing-amt { color: var(--muted); white-space: nowrap; }
.optional { opacity: .65; }
.story { background: #f7f7f8; border-radius: 12px; padding: 14px 16px; white-space: pre-wrap; font-size: 14px; line-height: 1.7; color: #374151; overflow-wrap: anywhere; word-break: break-word; max-width: 100%; }

/* Tag sheet (long-press) */
.sheet-scrim { z-index: 70; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; background: #fff; max-height: 78dvh;
  border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.12);
  transform: translateY(105%); transition: transform .3s var(--ease); display: flex; flex-direction: column;
  padding: 0 calc(16px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(16px + var(--safe-left));
  max-width: 720px; margin: 0 auto;
}
.sheet.open { transform: none; }
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: #dadce0; margin: 8px auto 4px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 6px 0 8px; }
.sheet-kicker { font-size: 12px; color: var(--muted); }
.sheet-title { font-size: 17px; font-weight: 600; margin-top: 2px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 6px; }
.sheet-group { margin: 10px 0 4px; }
.sheet-group-name { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-toggle {
  border: 1px solid #dadce0; background: #fff; border-radius: 999px; padding: 7px 13px; font-size: 14px; cursor: pointer;
  transition: background .15s, color .15s, transform .12s; position: relative; overflow: hidden;
}
.pill-toggle.on { background: var(--on); border-color: var(--on); color: #fff; }
.pill-toggle:active { transform: scale(.95); }
.sheet-foot { border-top: 1px solid #f0f0f2; padding-top: 6px; display: flex; justify-content: center; }

@media (prefers-reduced-motion: reduce) { * { transition-duration: 0s !important; animation-duration: 0s !important; } }

/* Lock screen */
.lock {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: #f3f4f6; padding: 24px;
}
.lock[hidden] { display: none; }
.lock-card {
  width: 100%; max-width: 360px; background: #fff; border-radius: 20px;
  padding: 28px 22px; box-shadow: 0 6px 24px rgba(0,0,0,.06); text-align: center;
}
.lock-card h1 { margin: 0 0 6px; font-size: 22px; }
.lock-card input[type=password] {
  width: 100%; margin-top: 18px; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 12px 14px; font-size: 17px; background: #f9fafb; text-align: center; letter-spacing: .1em;
}
.lock-card label.remember { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; font-size: 14px; color: #6b7280; }
.lock-card button.go {
  width: 100%; margin-top: 16px; border: 0; border-radius: 12px; padding: 12px;
  font-size: 16px; font-weight: 600; background: #111827; color: #fff;
}
.lock-card button.go:disabled { opacity: .5; }
.lock-err { color: #dc2626; font-size: 14px; min-height: 20px; margin: 10px 0 0; }


/* Favorites / star */
.card { position: relative; }
.card .star-btn {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; display: grid; place-items: center;
  color: #9aa0a6; cursor: pointer; overflow: hidden;
}
.card .star-btn.on { color: #f9ab00; }
.card .star-btn:active { background: rgba(60,64,67,.08); }
.card.has-star .card-title { padding-right: 28px; }
.detail-actions { display: flex; align-items: center; gap: 2px; }
.detail-bar .star-btn { color: #5f6368; }
.detail-bar .star-btn.on { color: #f9ab00; }
.card.fav {
  border-color: #fdd663;
  box-shadow: 0 1px 2px rgba(249,171,0,.12);
}

/* hide empty stars on cards — only filled (favorited) stars appear on list cards */
.card .star-btn:not(.on) { display: none; }


/* Author under title */
.author-line { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.author-link {
  border: 0; background: transparent; padding: 0; margin: 0;
  font: inherit; font-weight: 600; color: #1f2328; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #dadce0;
}
.author-link:active { opacity: .7; }

/* Author profile */
.author-view {
  position: fixed; inset: 0; z-index: 65; background: #fff; display: flex; flex-direction: column;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  padding: 0 var(--safe-right) 0 var(--safe-left);
}
.author-view.open { opacity: 1; transform: none; pointer-events: auto; }
.author-bar {
  display: flex; align-items: center;
  padding: calc(6px + var(--safe-top)) calc(8px + var(--safe-right)) 4px calc(8px + var(--safe-left));
}
.author-head { text-align: center; padding: 8px 20px 12px; }
.author-avatar {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 10px;
  background: #feefc3; color: #5f4b00; display: grid; place-items: center;
  font-size: 26px; font-weight: 700;
}
.author-head h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
#authorList {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding-bottom: calc(24px + var(--safe-bottom));
}

/* Local comments on detail */
.comments .comment-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.comment { background: #f7f7f8; border-radius: 12px; padding: 12px 14px; }
.comment-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.comment-nick { font-size: 14px; font-weight: 600; color: #1f2328; }
.comment-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.comment-text { margin: 0; font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; -webkit-user-select: text; user-select: text; }
.comment-empty { margin: 0 0 8px; font-size: 14px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; }
.comment-nick-input, .comment-input {
  width: 100%; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff;
  padding: 10px 12px; font: inherit; color: inherit; outline: none;
}
.comment-nick-input { font-size: 15px; }
.comment-input { font-size: 16px; resize: vertical; min-height: 72px; line-height: 1.45; }
.comment-send {
  align-self: flex-end; border: 0; border-radius: 20px; padding: 10px 18px;
  font-size: 15px; font-weight: 600; background: #1f2328; color: #fff; cursor: pointer;
}
.comment-send:active { opacity: .85; }
.comment-hint { margin: 6px 0 0; font-size: 12px; }

/* === batch-2026-10-18: UGC / i18n / community === */
.lang-row { padding: 8px 0 4px; }
.lang-toggles { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 10px; }
.lang-toggles .pill-toggle { font-size: 13px; padding: 6px 12px; }
.status-pill {
  display: inline-block; font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: #e8f0fe; color: #1a73e8; margin: 0 0 8px;
}
.status-pill.private { background: #f1f3f4; color: #5f6368; }
.status-pill.beta { background: #fef7e0; color: #b06000; }
.status-pill.failed { background: #fce8e6; color: #c5221f; }
.status-pill.sim { background: #e6f4ea; color: #137333; }
.ugc-badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 6px; border-radius: 4px; background: #feefc3; color: #5f4b00; margin-left: 6px; vertical-align: middle;
}

/* UGC editor */
.ugc-view, .settings-view {
  position: fixed; inset: 0; z-index: 58; background: #fff; display: flex; flex-direction: column;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  padding: 0 var(--safe-right) 0 var(--safe-left);
}
.ugc-view.open, .settings-view.open { opacity: 1; transform: none; pointer-events: auto; }
.ugc-bar, .settings-bar {
  display: flex; align-items: center; gap: 4px;
  padding: calc(6px + var(--safe-top)) calc(8px + var(--safe-right)) 4px calc(8px + var(--safe-left));
}
.ugc-bar h2, .settings-bar h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; }
.ugc-form, .settings-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px calc(16px + var(--safe-right)) calc(32px + var(--safe-bottom)) calc(16px + var(--safe-left));
  max-width: 720px; width: 100%; margin: 0 auto;
}
.ugc-form label { display: block; margin: 0 0 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ugc-form label > span { display: block; margin-bottom: 6px; }
.ugc-form input:not([type="radio"]):not([type="checkbox"]), .ugc-form textarea {
  width: 100%; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff;
  padding: 10px 12px; font: inherit; font-size: 16px; font-weight: 400; color: var(--text); outline: none;
}
.ugc-form textarea { resize: vertical; line-height: 1.45; }
.ugc-vis { border: 1px solid #e5e7eb; border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; }
.ugc-vis legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.ugc-vis .radio {
  display: flex; align-items: flex-start; gap: 10px; margin: 8px 0;
  font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.45;
}
.ugc-vis .radio input[type="radio"] {
  width: 18px; height: 18px; min-width: 18px; max-width: 18px; flex: 0 0 18px;
  margin: 2px 0 0; padding: 0; accent-color: #1f2328;
}
.ugc-vis .radio span { flex: 1; min-width: 0; }
.ugc-label-picks { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.ugc-lab-group { display: flex; flex-direction: column; gap: 6px; }
.ugc-lab-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ugc-lab-head .pill-toggle { flex: 0 1 auto; }
.ugc-expand {
  width: 36px; height: 36px; border: 1px solid #e5e7eb; border-radius: 10px;
  background: #f7f7f8; color: #5f6368; font-size: 14px; cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
}
.ugc-expand.open { background: #1f2328; color: #fff; border-color: #1f2328; }
.ugc-expand svg { transition: transform .2s var(--ease); width: 16px; height: 16px; }
.ugc-expand.open svg { transform: rotate(90deg); }
.ugc-lab-kids {
  display: none; flex-wrap: wrap; gap: 8px;
  padding: 8px 4px 4px 12px; border-left: 2px solid #feefc3; margin-left: 4px;
}
.ugc-lab-kids.open { display: flex; }
.ugc-lab-kids .pill-toggle.child { font-size: 13px; font-weight: 500; }
.ugc-links { margin-bottom: 12px; }
.warn { font-size: 12px; line-height: 1.5; margin: 8px 0 0; }
.small { font-size: 12px; }

/* Settings / link review */
.settings-section { margin: 0 0 22px; }
.settings-section h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.settings-card {
  background: #f7f7f8; border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
}
.settings-card .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.link-url { font-size: 13px; word-break: break-all; color: #1a73e8; }
.btn-sm {
  border: 0; border-radius: 16px; padding: 7px 12px; font-size: 13px; font-weight: 600;
  background: #1f2328; color: #fff; cursor: pointer;
}
.btn-sm.ghost { background: #e8eaed; color: #3c4043; }
.btn-sm.danger { background: #c5221f; }
.btn-sm:active { opacity: .85; }

/* Community: remakes + issues */
.community-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.star-pick { display: flex; gap: 4px; margin: 8px 0; }
.star-pick button {
  width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent;
  color: #dadce0; font-size: 20px; cursor: pointer; line-height: 1;
}
.star-pick button.on { color: #f9ab00; }
.issue-item {
  background: #f7f7f8; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.issue-item.closed { opacity: .55; }
.issue-title { font-weight: 600; font-size: 15px; margin: 0 0 4px; }
.issue-body { margin: 0; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.issue-meta { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 10px; align-items: center; }
.ext-links a {
  display: inline-block; font-size: 13px; color: #1a73e8; margin: 0 10px 6px 0;
  text-decoration: none; border-bottom: 1px solid #dadce0;
}
.remake-item { font-size: 14px; padding: 8px 0; border-bottom: 1px solid #f1f1f3; }
.remake-item:last-child { border-bottom: 0; }

/* ---------- Tools (ABV / Auth) ---------- */
.tool-view {
  position: fixed; inset: 0; z-index: 90; background: #fff; display: flex; flex-direction: column;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  padding: 0 var(--safe-right) 0 var(--safe-left);
  height: 100dvh; max-height: 100dvh; width: 100%;
  overflow: hidden;
}
.tool-view.open { opacity: 1; transform: none; pointer-events: auto; }
html.layer-cover .bottom-nav,
html.layer-cover .memo-fab { visibility: hidden; pointer-events: none; }
.tool-bar {
  display: flex; align-items: center; gap: 4px;
  padding: calc(6px + var(--safe-top)) calc(8px + var(--safe-right)) 4px calc(8px + var(--safe-left));
}
.tool-bar h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; }
.tool-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px calc(16px + var(--safe-right)) calc(32px + var(--safe-bottom)) calc(16px + var(--safe-left));
  max-width: 720px; width: 100%; margin: 0 auto;
}

.abv-rows { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 14px; }
.abv-row {
  display: grid; grid-template-columns: 1.4fr 0.7fr 0.7fr auto;
  gap: 8px; align-items: center; background: #f7f7f8; border-radius: 12px; padding: 10px;
}
.abv-row input {
  width: 100%; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff;
  padding: 9px 10px; font: inherit; font-size: 16px; color: var(--text); outline: none;
}
.abv-row .abv-del {
  width: 36px; height: 36px; border: 0; border-radius: 50%; background: #e8eaed; color: #5f6368;
  font-size: 18px; cursor: pointer; line-height: 1;
}
.abv-result {
  margin-top: 20px; background: #f7f7f8; border-radius: 16px; padding: 18px 16px; text-align: center;
}
.abv-result-label { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.abv-result-val { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 4px; }
.abv-unit { font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 6px; }

.auth-card {
  background: #f7f7f8; border-radius: 14px; padding: 16px; margin-bottom: 14px;
}
.auth-card h3 { margin: 0 0 8px; font-size: 16px; }
.auth-card label { display: block; margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-card label > span { display: block; margin-bottom: 6px; }
.auth-card input {
  width: 100%; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff;
  padding: 10px 12px; font: inherit; font-size: 16px; font-weight: 400; color: var(--text); outline: none;
}
.auth-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.auth-note { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 10px 0 0; }

/* Featured comments */
.comment.featured { background: #fef7e0; border: 1px solid #f9e3a3; }
.comment-featured-badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 4px; background: #feefc3; color: #5f4b00; margin-right: 6px;
}
.comment-keywords { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.kw-chip {
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: #fff; color: #5f4b00; border: 1px solid #f0d78c;
}
.comment-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.comment-actions .btn-sm { padding: 5px 10px; font-size: 12px; }
.featured-kw-input {
  width: 100%; border: 1px solid #e5e7eb; border-radius: 10px; padding: 8px 10px;
  font: inherit; font-size: 14px; margin-top: 6px; outline: none;
}

/* Onboarding */
.onboard {
  position: fixed; inset: 0; z-index: 200; background: #fff;
  display: flex; flex-direction: column;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.onboard[hidden] { display: none !important; }
.onboard-track {
  flex: 1; display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scroll-behavior: smooth;
}
.onboard-track::-webkit-scrollbar { display: none; }
.onboard-page {
  flex: 0 0 100%; width: 100%; scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 28px 48px;
}
.onboard-inner { max-width: 420px; width: 100%; }
.onboard-kicker {
  font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--muted);
  text-transform: uppercase; margin: 0 0 16px;
}
.onboard-title {
  margin: 0; font-size: clamp(22px, 6.2vw, 26px); font-weight: 650;
  line-height: 1.45; letter-spacing: -0.01em;
  word-break: keep-all; overflow-wrap: break-word;
}
.nowrap { white-space: nowrap; }
.onboard-q { margin: 0 0 20px; font-size: 22px; font-weight: 650; line-height: 1.35; }
.onboard-tip { margin: 0 0 28px; font-size: 17px; line-height: 1.6; color: #3c4043; }
.onboard-choices { display: flex; flex-direction: column; gap: 10px; }
.onboard-choice {
  width: 100%; text-align: left; border: 1px solid #e5e7eb; background: #f7f7f8;
  border-radius: 14px; padding: 16px 18px; font-size: 16px; font-weight: 560; cursor: pointer;
}
.onboard-choice.on { background: #1f2328; color: #fff; border-color: #1f2328; }
.onboard-done {
  width: 100%; border: 0; border-radius: 28px; padding: 14px 18px;
  background: #1f2328; color: #fff; font-size: 16px; font-weight: 650; cursor: pointer;
}
.onboard-done:active { opacity: .88; }
.onboard-dots {
  display: flex; justify-content: center; gap: 8px;
  padding: 0 0 calc(18px + var(--safe-bottom));
}
.onboard-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: #dadce0;
  transition: background .2s, transform .2s;
}
.onboard-dots span.on { background: #1f2328; transform: scale(1.15); }


/* ===== Me home (calm Normar, not XHS red) ===== */
.me-home {
  display: flex; flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: #f4f4f5;
}
.me-top {
  flex-shrink: 0;
  position: relative; z-index: 12;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: linear-gradient(180deg, #2a2d32 0%, #1f2328 100%);
  color: #fff;
}
.me-top .round-btn { color: #fff; }
.me-edit-btn {
  border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.08);
  color: #fff; border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.me-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(88px + var(--safe-bottom));
}
.me-hero {
  background: #1f2328; color: #f5f5f6;
  padding: 8px 20px 22px;
  border-radius: 0 0 20px 20px;
}
.me-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: #feefc3; color: #1f2328;
  display: grid; place-items: center;
  font-size: 28px; font-weight: 700; margin-bottom: 12px;
  border: 2px solid rgba(255,255,255,.2);
}
.me-nick { margin: 0 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.me-meta { margin: 0 0 2px; font-size: 12px; color: rgba(255,255,255,.62); }
.me-stats {
  display: flex; gap: 22px; margin: 16px 0 12px;
}
.me-stat { display: flex; flex-direction: column; gap: 2px; }
.me-stat b { font-size: 18px; font-weight: 700; line-height: 1.2; }
.me-stat span { font-size: 12px; color: rgba(255,255,255,.55); }
.me-bio {
  margin: 0; font-size: 13px; line-height: 1.55;
  color: rgba(255,255,255,.82); white-space: pre-wrap; word-break: break-word;
}
.me-tabs {
  display: flex; gap: 4px; padding: 10px 12px 0;
  background: #fff; position: sticky; top: 0; z-index: 11;
  border-bottom: 1px solid #eee;
}
.me-tab {
  flex: 1; border: 0; background: transparent; padding: 12px 8px;
  font-size: 15px; font-weight: 600; color: #6b7280; cursor: pointer;
  position: relative;
}
.me-tab.on { color: #1f2328; }
.me-tab.on::after {
  content: ''; position: absolute; left: 28%; right: 28%; bottom: 0;
  height: 3px; border-radius: 2px; background: #1f2328;
}
.me-tab-body {
  background: #fff; min-height: 40vh;
  padding: 10px 8px calc(24px + var(--safe-bottom));
  max-width: 720px; margin: 0 auto;
}
.me-empty { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 14px; column-span: all; }
.me-comment-row {
  break-inside: avoid; margin: 0 0 8px;
  border: 1px solid var(--card-border); border-radius: 12px;
  padding: 12px 14px; background: #fff; text-align: left;
}
.me-comment-row .muted { font-size: 12px; margin: 0 0 4px; }
.me-comment-row p { margin: 0; font-size: 14px; line-height: 1.5; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; align-items: flex-end; justify-content: space-around;
  padding: 6px 24px calc(8px + var(--safe-bottom));
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border-top: 1px solid #eceef1;
}
.bnav {
  flex: 1; border: 0; background: transparent; color: #6b7280;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px; font-size: 11px; font-weight: 600; cursor: pointer;
}
.bnav.on { color: #1f2328; }
.bnav-plus { flex: 0 0 auto; margin: 0 18px; transform: translateY(-10px); }
.bnav-plus .plus-box {
  width: 48px; height: 48px; border-radius: 14px;
  background: #1f2328; color: #fff;
  display: grid; place-items: center; font-size: 28px; font-weight: 400; line-height: 1;
  box-shadow: 0 4px 14px rgba(31,35,40,.25);
}
.profile-form { padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.profile-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.profile-form input, .profile-form textarea {
  border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px 12px;
  font-size: 16px; color: var(--text); background: #fff;
}
.profile-stats-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile-sheet { z-index: 120; max-height: 86dvh; padding-bottom: calc(12px + var(--safe-bottom)); }
#profileScrim { z-index: 115; }
.bottom-nav { z-index: 25; }


/* Cloud Phase 1 — library sort + comment votes */
.sort-box { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; align-items: center; }
.sort-box .pill-toggle { font-size: 12px; padding: 4px 10px; }
.filter-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.vote-row { display: flex; gap: 8px; margin-top: 8px; }
.vote-btn.on { color: #1a73e8; font-weight: 600; }
.comment.cloud { border-left: 3px solid #81c995; }
.comment.local { opacity: .92; }
.detail-fav-count { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

.author-stats {
  display: flex; gap: 22px; margin: 10px 0 4px; justify-content: center;
}
.author-stats .me-stat b { color: var(--text, #1f2328); }
.author-stats .me-stat span { color: var(--muted); }
.author-normar-id { margin: 2px 0 0; font-size: 12px; }
.profile-form input[readonly] { opacity: .85; background: #f3f4f6; }


/* ---------- Memos (Keep-like drafts) ---------- */
.memo-fab {
  position: fixed;
  right: calc(16px + var(--safe-right));
  bottom: calc(72px + var(--safe-bottom));
  z-index: 28;
  width: 48px; height: 48px; border-radius: 16px; border: 0;
  background: #feefc3; color: #1f2328;
  display: grid; place-items: center;
  box-shadow: 0 4px 16px rgba(31,35,40,.18);
  cursor: pointer;
}
.memo-fab:active { transform: scale(.96); }
#app.mode-library .memo-fab { display: none !important; }

.abv-to-memo { margin-top: 14px; }

.memo-body { padding-top: 4px; }
.memo-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  padding-bottom: 24px;
}
@media (min-width: 560px) {
  .memo-list { grid-template-columns: 1fr 1fr 1fr; }
}
.memo-card {
  break-inside: avoid;
  text-align: left;
  border: 0; border-radius: 14px;
  padding: 12px 12px 10px;
  background: #fff8e1;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  cursor: pointer;
  min-height: 96px;
  display: flex; flex-direction: column; gap: 6px;
  color: inherit; font: inherit;
}
.memo-card.abv { background: #e8f0fe; }
.memo-card-title {
  font-size: 14px; font-weight: 700; line-height: 1.35;
  word-break: break-word;
}
.memo-card-preview {
  flex: 1; font-size: 12px; line-height: 1.45; color: #5f6368;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden; white-space: pre-wrap; word-break: break-word;
}
.memo-card-time { font-size: 11px; color: #80868b; margin-top: auto; }
.memo-empty {
  grid-column: 1 / -1;
  text-align: center; color: var(--muted);
  padding: 48px 12px; font-size: 14px;
}
.memo-edit-body { display: flex; flex-direction: column; gap: 12px; }
.memo-edit-body #memoTitle {
  width: 100%; border: 0; border-bottom: 1px solid #e5e7eb;
  padding: 10px 2px; font: inherit; font-size: 18px; font-weight: 650;
  outline: none; background: transparent; color: var(--text);
}
.memo-edit-body #memoBody {
  width: 100%; flex: 1; min-height: 280px;
  border: 1px solid #e5e7eb; border-radius: 14px;
  padding: 14px; font: inherit; font-size: 16px; line-height: 1.55;
  resize: vertical; outline: none; background: #fafafa; color: var(--text);
}
.memo-edited { margin: 0; }
.memo-edit-actions { display: flex; gap: 8px; }
.danger-text { color: #c5221f !important; }


/* Toast (replace alert for memo save etc.) */
.normar-toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  z-index: 200;
  max-width: min(90vw, 360px);
  padding: 10px 16px; border-radius: 999px;
  background: rgba(31,35,40,.92); color: #fff;
  font-size: 14px; font-weight: 600; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.normar-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
