:root {
  --bg-0: #0b0a1f;
  --bg-1: #15123a;
  --bg-2: #241a52;
  --ink: #2b2540;
  --soft: rgba(255, 255, 255, 0.72);
  --softer: rgba(255, 255, 255, 0.45);
  --glass: rgba(20, 16, 48, 0.72);
  --accent: #ffd66b;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg-2) 0%, var(--bg-1) 38%, var(--bg-0) 100%);
  font-family: "Nunito", "Noto Sans SC", "Noto Sans JP", system-ui, sans-serif;
  color: var(--soft); -webkit-font-smoothing: antialiased; user-select: none; touch-action: none;
}

/* starfield */
#space { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
#space .star { position: absolute; border-radius: 50%; background: #fff; opacity: .7; animation: twinkle var(--tw,4s) ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .15; } to { opacity: .9; } }

/* the floating field */
#field { position: fixed; inset: 0; z-index: 1; }

/* a capsule */
.cap {
  position: absolute;
  top: 0; left: 0;
  display: flex; align-items: center; gap: 8px;
  max-width: 230px;
  padding: 11px 16px;
  border-radius: 999px;
  background: hsl(var(--h,265) 70% 90%);
  border: 1px solid hsl(var(--h,265) 70% 82%);
  color: var(--ink);
  font-size: 14px; font-weight: 700; line-height: 1.2;
  white-space: nowrap; overflow: hidden;
  box-shadow: 0 10px 26px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.6);
  cursor: pointer;
  will-change: transform;
  transition: box-shadow .2s ease;
}
.cap .emoji { font-size: 16px; flex: none; }
.cap .t { overflow: hidden; text-overflow: ellipsis; }
.cap:hover { box-shadow: 0 14px 32px rgba(0,0,0,.4), 0 0 0 2px rgba(255,255,255,.5) inset; }
.cap.mine { box-shadow: 0 0 0 2px var(--accent), 0 14px 34px rgba(255,214,107,.4); }

/* top bar */
#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; pointer-events: none; }
#topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 9px; background: none; border: 0; padding: 0; cursor: pointer; transition: transform .12s ease; }
.brand-logo { height: 28px; display: block; }
.brand:active { transform: scale(.94); }
.lang-switch { position: relative; }
.lang-toggle {
  display: flex; align-items: center; gap: 7px;
  background: var(--glass); border: 1px solid rgba(255,255,255,.12); border-radius: 999px;
  padding: 7px 13px 7px 11px; cursor: pointer; backdrop-filter: blur(10px);
  color: #fff; font: inherit; font-weight: 800; font-size: 13px;
  transition: background .2s ease, transform .2s ease;
}
.lang-toggle:hover { background: rgba(255,255,255,.16); }
.lang-toggle .globe { font-size: 16px; display: inline-block; transition: transform .5s ease; }
.lang-toggle:hover .globe, .lang-switch.open .globe { animation: spin 3.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.lang-code { letter-spacing: .3px; }

.lang-menu {
  position: absolute; top: calc(100% + 10px); right: 0;
  min-width: 168px; max-height: 60vh; overflow-y: auto;
  background: rgba(24, 19, 56, .92); border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px; padding: 7px; backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
  opacity: 0; transform: translateY(-8px) scale(.96); transform-origin: top right;
  pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.lang-switch.open .lang-menu { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.lang-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; border: 0; background: transparent; color: var(--soft);
  font: inherit; font-weight: 700; font-size: 14px; text-align: left;
  padding: 9px 12px; border-radius: 11px; cursor: pointer; transition: background .15s ease, color .15s ease;
  opacity: 0; transform: translateX(6px);
}
.lang-switch.open .lang-item { animation: itemIn .26s ease forwards; }
@keyframes itemIn { to { opacity: 1; transform: translateX(0); } }
.lang-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.lang-item.sel { color: var(--accent); }
.lang-item .tick { opacity: 0; font-size: 13px; }
.lang-item.sel .tick { opacity: 1; }

/* start screen */
#start { position: fixed; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; transition: opacity .5s ease; }
#start.gone { opacity: 0; pointer-events: none; }
#popStart {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 168px; height: 168px; border-radius: 50%; border: 0;
  background: radial-gradient(circle at 38% 32%, #fff3cf, var(--accent) 60%, #eaa63c);
  color: #4a330a; font: inherit; font-weight: 900; font-size: 26px; letter-spacing: .5px;
  cursor: pointer; box-shadow: 0 18px 50px rgba(255,214,107,.45);
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
#popStart:active { transform: scale(.94); }
.ps-emoji { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); font-size: 38px; }
.start-tag { font-size: 15px; color: var(--softer); }

/* bottom controls */
#hint { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 9; font-size: 12.5px; color: var(--softer); white-space: nowrap; pointer-events: none; transition: opacity .6s ease; }
#controls { position: fixed; left: 0; right: 0; bottom: 22px; height: 46px; z-index: 10; }
#controls[hidden] { display: none; }
.nav-group { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 8px; }
.nav { width: 48px; height: 48px; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 26px; font-weight: 700; line-height: 1; cursor: pointer; backdrop-filter: blur(8px); transition: background .18s ease, transform .18s ease, opacity .18s ease; }
.nav:hover:not(:disabled) { background: rgba(255,255,255,.28); transform: translateY(-2px); }
.nav:active:not(:disabled) { transform: scale(.92); }
.nav:disabled { opacity: .28; cursor: default; }
#moreBtn, #postBtn { width: 48px; height: 48px; border: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.14); color: #fff; font-size: 21px; line-height: 1; cursor: pointer; backdrop-filter: blur(8px); padding: 0; transition: background .18s ease, transform .18s ease; }
#moreBtn:hover, #postBtn:hover { background: rgba(255,255,255,.28); transform: translateY(-2px); }
#moreBtn:active, #postBtn:active { transform: scale(.92); }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(8,6,22,.55); backdrop-filter: blur(7px); animation: fade .28s ease; }
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.close-x { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(0,0,0,.06); color: var(--ink); font-size: 14px; cursor: pointer; transition: background .2s ease; }
.close-x:hover { background: rgba(0,0,0,.12); }

.reader-card, .compose-card { position: relative; width: min(440px, 92vw); max-height: 86vh; overflow-y: auto; background: #fffdf7; color: var(--ink); border-radius: 26px; padding: 30px 28px 24px; box-shadow: 0 30px 80px rgba(0,0,0,.5); animation: pop .42s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.88); } to { opacity: 1; transform: translateY(0) scale(1); } }
.reader-card { display: flex; flex-direction: column; height: min(78vh, 600px); max-height: 86vh; overflow: hidden; padding: 26px 26px 16px; }
.reader-head { flex: none; }
.reader-mood { font-size: 32px; margin-bottom: 4px; }
.reader-actions { display: flex; gap: 10px; margin-top: 14px; }
.act-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid rgba(43,37,64,.14); background: #fff; color: var(--ink); font: inherit; font-weight: 800; font-size: 14px; padding: 9px 14px; border-radius: 999px; cursor: pointer; transition: all .15s ease; }
.act-btn:hover { background: #f6f3ff; }
.act-btn:active { transform: scale(.95); }
.act-btn.on { background: #fff0f3; border-color: #ffb3c1; color: #e0455f; }
#saveBtn.on { background: #fff7e6; border-color: #ffd98a; color: #b8810f; }
.act-btn .ai { font-size: 16px; }
.reader-text { font-size: 21px; line-height: 1.5; font-weight: 700; margin: 4px 0 16px; color: #1f1a30; }
.reader-meta { font-size: 13px; color: rgba(43,37,64,.55); font-weight: 700; }
.dot-sep { margin: 0 6px; }
.reader-comments { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 16px; border-top: 1px dashed rgba(43,37,64,.18); padding-top: 14px; }
.comments-head { flex: none; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: rgba(43,37,64,.5); font-weight: 800; margin-bottom: 12px; }
.comments-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 11px; padding-right: 2px; }
.comments-list::-webkit-scrollbar { width: 0; height: 0; }
.comments-list { scrollbar-width: none; -ms-overflow-style: none; }
.comment { background: #f4f0ff; border-radius: 14px; padding: 9px 13px; font-size: 14px; line-height: 1.4; animation: pop .3s ease; }
.comment .ca { font-weight: 800; color: #6b54c9; margin-right: 6px; }
.comment.empty { background: transparent; color: rgba(43,37,64,.4); font-style: italic; padding-left: 2px; }
.comment-form { display: flex; gap: 8px; position: relative; flex: none; margin-top: 12px; }
.comment .ca { cursor: pointer; }
.mention { color: #6b54c9; font-weight: 800; }
.mention-box { position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; background: #fff; border: 1px solid rgba(43,37,64,.1); border-radius: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.18); padding: 5px; max-height: 168px; overflow-y: auto; z-index: 6; }
.mention-box[hidden] { display: none; }
.mention-item { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: transparent; font: inherit; font-weight: 700; font-size: 14px; color: var(--ink); padding: 8px 10px; border-radius: 10px; cursor: pointer; text-align: left; }
.mention-item:hover, .mention-item.active { background: #f0ebff; }
.mention-item .mava { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, #ffe7a8, #ffc9de); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: #7a5a2a; flex: none; }
.me-tabs { display: flex; gap: 6px; margin: 18px 0 12px; background: #f1edfb; padding: 4px; border-radius: 13px; }
.me-tab { flex: 1; border: 0; background: transparent; font: inherit; font-weight: 800; font-size: 13px; color: rgba(43,37,64,.55); padding: 8px 6px; border-radius: 10px; cursor: pointer; transition: all .15s ease; }
.me-tab.active { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.my-note { cursor: pointer; transition: background .15s ease; }
.my-note:hover { background: #ece4ff; }
.comment-form input { flex: 1; border: 1px solid rgba(43,37,64,.16); border-radius: 12px; padding: 11px 13px; font: inherit; font-size: 14px; font-weight: 600; background: #fff; color: var(--ink); }
.comment-form input:focus { outline: 2px solid #c9b8ff; }
.comment-form > button, .send-btn { border: 0; border-radius: 12px; background: linear-gradient(135deg, #b79cff, #8e6dff); color: #fff; font: inherit; font-weight: 800; font-size: 14px; padding: 11px 16px; cursor: pointer; transition: transform .15s ease; }
.comment-form > button:active, .send-btn:active { transform: scale(.96); }
.compose-title { font-size: 22px; font-weight: 800; margin-bottom: 14px; color: #1f1a30; }
#composeText { width: 100%; min-height: 110px; resize: none; border: 1px solid rgba(43,37,64,.16); border-radius: 16px; padding: 14px; font: inherit; font-size: 16px; font-weight: 600; line-height: 1.5; background: #fff; color: var(--ink); }
#composeText:focus { outline: 2px solid #c9b8ff; }
.mood-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: rgba(43,37,64,.5); font-weight: 800; margin: 18px 0 10px; }
.mood-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.mood-chip { border: 1px solid transparent; border-radius: 999px; padding: 8px 13px; font-size: 18px; cursor: pointer; background: hsl(var(--h) 60% 93%); transition: transform .15s ease, box-shadow .15s ease; }
.mood-chip:hover { transform: translateY(-2px); }
.mood-chip.sel { box-shadow: 0 0 0 2px #8e6dff; transform: translateY(-2px); }
.send-btn { width: 100%; padding: 14px; font-size: 16px; background: linear-gradient(135deg, #ffe08a, var(--accent)); color: #4a330a; }

/* account cluster (bottom-right) */
.acct { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 9px; }
.icon-btn { position: relative; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 21px; line-height: 1; cursor: pointer; backdrop-filter: blur(8px); transition: background .18s ease, transform .18s ease; }
.icon-btn:hover { background: rgba(255,255,255,.26); transform: translateY(-2px); }
.icon-btn:active { transform: scale(.92); }
.badge { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: #ff5d6c; color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--bg-0); }
.badge[hidden] { display: none; }

/* shared sheet (inbox / me / settings / doc) */
.sheet { position: relative; width: min(440px, 92vw); max-height: 86vh; overflow-y: auto; background: #fffdf7; color: var(--ink); border-radius: 26px; padding: 28px 26px 22px; box-shadow: 0 30px 80px rgba(0,0,0,.5); animation: pop .42s cubic-bezier(.34,1.56,.64,1); }
.sheet-title { font-size: 22px; font-weight: 800; color: #1f1a30; margin-bottom: 18px; }
.sheet-section { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: rgba(43,37,64,.5); font-weight: 800; margin: 22px 0 12px; }

/* inbox */
.inbox-list { display: flex; flex-direction: column; gap: 10px; }
.inbox-item { display: flex; gap: 12px; align-items: flex-start; background: #f6f3ff; border-radius: 16px; padding: 13px 14px; }
.inbox-item.unread { background: #fff3da; }
.inbox-ava { width: 34px; height: 34px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.inbox-main { flex: 1; min-width: 0; }
.inbox-top { font-size: 14px; font-weight: 700; }
.inbox-top .who { color: #6b54c9; font-weight: 800; }
.inbox-top .when { color: rgba(43,37,64,.45); font-weight: 700; margin-left: 6px; }
.inbox-reply { font-size: 14px; margin-top: 3px; }
.inbox-quote { font-size: 12.5px; color: rgba(43,37,64,.5); margin-top: 5px; border-left: 2px solid rgba(43,37,64,.15); padding-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { color: rgba(43,37,64,.45); font-style: italic; font-size: 14px; padding: 8px 2px; }

/* me / profile */
.profile { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 18px; }
.avatar { width: 76px; height: 76px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 38px; background: linear-gradient(135deg, #ffe7a8, #ffc9de); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.profile-name { font-size: 20px; font-weight: 800; color: #1f1a30; margin-top: 8px; }
.profile-sub { font-size: 13px; color: rgba(43,37,64,.5); font-weight: 700; }
.ghost-btn { width: 100%; border: 1px dashed rgba(43,37,64,.25); background: transparent; color: rgba(43,37,64,.6); font: inherit; font-weight: 700; font-size: 13.5px; padding: 12px; border-radius: 14px; cursor: pointer; }
.my-notes { display: flex; flex-direction: column; gap: 9px; }
.my-note { background: #f4f0ff; border-radius: 14px; padding: 11px 13px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.my-note .mn-emoji { margin-right: 6px; }

/* settings */
.set-group { background: #f6f3ff; border-radius: 16px; overflow: hidden; margin-bottom: 16px; }
.set-row { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 12px; padding: 14px 15px; font: inherit; font-size: 15px; font-weight: 700; color: var(--ink); border: 0; background: transparent; border-bottom: 1px solid rgba(43,37,64,.07); text-align: left; }
.set-group .set-row:last-child { border-bottom: 0; }
.set-row.link { cursor: pointer; }
.set-row.link:hover { background: rgba(110,84,200,.08); }
.set-row.disabled { color: rgba(43,37,64,.5); }
.set-hint { font-size: 12px; font-weight: 700; color: rgba(43,37,64,.4); }
.chev { color: rgba(43,37,64,.35); font-size: 20px; }
.toggle { width: 40px; height: 23px; border-radius: 999px; background: #8e6dff; position: relative; flex: none; cursor: pointer; }
.toggle::after { content: ""; position: absolute; top: 2px; right: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: all .2s ease; }
.toggle.off { background: rgba(43,37,64,.2); }
.toggle.off::after { right: auto; left: 2px; }
.set-footer { text-align: center; font-size: 12px; color: rgba(43,37,64,.4); font-weight: 700; margin-top: 6px; }
.doc-body { font-size: 15px; line-height: 1.6; color: #3a3450; font-weight: 600; }

@media (max-width: 640px) {
  .cap { max-width: 200px; font-size: 13px; }
  .acct { right: 12px; gap: 7px; }
  .icon-btn { width: 40px; height: 40px; font-size: 17px; }
  #moreBtn span:not(.b-emoji), #postBtn span:not(.plus) { font-size: 13.5px; }
  .reader-text { font-size: 19px; }
  #hint { font-size: 11.5px; }
}
