:root {
  --jubilee: #026881;
  --mine: #2792C3;
  --mine-bubble: #DDECF0;
  --theirs: #EBEBEB;
  --paper: #F4F4F4;
  --ink: #1d1d1f;
  --stamp: rgba(0,0,0,.5);
  --bg: #fff;
  --W: 100%;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #f2f2f2; overflow: hidden; }
body {
  font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  color: var(--ink); touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
#frame {
  position: relative; margin: 0 auto; width: 100%; max-width: 440px; height: 100dvh;
  background: var(--bg); overflow: hidden;
}
/* パソコンでは iPhone の形の丸長四角に収める。カメラや釦は描かない */
@media (min-width: 600px) and (min-height: 640px) {
  body { display: grid; place-items: center; background: #ececef; }
  #frame {
    width: 393px; max-width: none; height: min(852px, calc(100dvh - 64px)); border-radius: 54px;
    box-shadow: 0 0 0 10px #f9f9fa, 0 0 0 11px rgba(0,0,0,.14), 0 24px 60px rgba(0,0,0,.14);
  }
  #track { top: 24px; }
  .sheet.full { top: 36px; }
  #dock { bottom: 18px; }
}

/* 4つの画面を横に並べ、はらうと動かす */
#track { position: absolute; inset: 0; display: flex; width: 400%; will-change: transform; }
.pane { position: relative; width: 25%; height: 100%; display: flex; flex-direction: column; }
.bar { flex: none; height: 48px; padding: 0 14px; padding-top: env(safe-area-inset-top); display: flex; align-items: center; position: relative; }
.bar .title { position: absolute; left: 50%; transform: translateX(-50%); font-size: 15px; color: rgba(0,0,0,.35); white-space: nowrap; }
.bar .left { display: flex; gap: 6px; align-items: center; }
.bar .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: 4px 8px 120px; }
.ibtn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: none; padding: 0; color: rgba(0,0,0,.4); }
.ibtn svg { width: 20px; height: 20px; }

/* 読み直しの時計 */
.clock { display: flex; align-items: center; gap: 6px; color: var(--jubilee); font-size: 14px; font-weight: 500; opacity: 0; transition: opacity .3s; }
.clock.on { opacity: 1; }
.clock .face { width: 22px; height: 22px; border-radius: 50%; background: #e8e8e8; }

/* 話の流れ */
.flow { padding: 16px 0; }
.row { display: flex; align-items: flex-end; gap: 0; position: relative; }
.row.right { flex-direction: row-reverse; }
.avcol { flex: none; width: 46px; display: flex; justify-content: center; position: relative; z-index: 1; }
.av { width: 34px; height: 34px; border-radius: 50%; display: block; object-fit: cover; }
.body { display: flex; flex-direction: column; min-width: 0; max-width: calc(100% - 46px - 40px); }
.row.right .body { align-items: flex-end; }
.row.left .body { align-items: flex-start; }
.row + .row { margin-top: 4px; }
.row.turn { margin-top: 18px; }

.bubble {
  position: relative; padding: 10px 15px; border-radius: 18px; background: var(--theirs);
  font-size: 16px; line-height: 1.6; letter-spacing: .2px; white-space: pre-wrap; word-break: break-word; max-width: 19.6em;
}
.bubble.me { background: var(--mine-bubble); }
.bubble.tail.right::before, .bubble.tail.left::before {
  content: ""; position: absolute; bottom: 0; width: 20px; height: 20px; background: inherit;
}
.bubble.tail.right::before { right: -7px; border-bottom-left-radius: 16px 14px; }
.bubble.tail.left::before { left: -7px; border-bottom-right-radius: 16px 14px; }
.bubble.tail.right::after, .bubble.tail.left::after {
  content: ""; position: absolute; bottom: 0; width: 26px; height: 20px; background: var(--bg);
}
.bubble.tail.right::after { right: -26px; border-bottom-left-radius: 10px; }
.bubble.tail.left::after { left: -26px; border-bottom-right-radius: 10px; }
.bubble.press { filter: brightness(.94); }

.toLabel { font-size: 12.5px; color: rgba(0,0,0,.3); margin: 0 0 4px; padding: 0 6px; }
.row.right .toLabel { align-self: flex-end; }

/* 名前とブルードットの行 */
.end { display: flex; align-items: center; height: 30px; position: relative; }
.end.right { flex-direction: row-reverse; }
.end .dotcol { flex: none; width: 46px; display: flex; justify-content: center; }
.end .name { font-size: 12px; font-weight: 500; color: rgba(0,0,0,.72); padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.end.right .name { padding-right: 18px; }
.end.left .name { padding-left: 18px; }

.dot { position: relative; width: 16px; height: 16px; border-radius: 4px; border: 1.3px solid rgba(2,104,129,.35); background: #fff; padding: 0; }
.dot i { position: absolute; inset: -1.3px; border-radius: 4px; background: var(--jubilee); opacity: 0; transition: opacity .2s; }
.dot.l1 i { opacity: .16; } .dot.l2 i { opacity: .35; } .dot.l3 i { opacity: .6; } .dot.l4 i { opacity: .82; } .dot.on i { opacity: 1; }
.dot.flash::after { content: ""; position: absolute; inset: -2px; border-radius: 6px; background: #39a7c9; animation: flash .5s ease-out forwards; pointer-events: none; }
@keyframes flash { from { transform: scale(1); opacity: .9; } to { transform: scale(2.6); opacity: 0; } }
.dot.fresh { animation: breath 2.6s ease-in-out infinite; }
@keyframes breath { 0%,100% { box-shadow: 0 0 0 0 rgba(57,140,255,.0); } 50% { box-shadow: 0 0 0 3px rgba(57,140,255,.55), 0 0 10px rgba(57,140,255,.6); } }
.hit { position: relative; }
.hit::before { content: ""; position: absolute; inset: -12px; }

/* 操作のカプセル */
.cap {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; display: none; align-items: center; gap: 2px;
  height: 34px; padding: 0 8px; border-radius: 17px; background: #f2f2f2; white-space: nowrap; box-shadow: 0 1px 0 rgba(0,0,0,.03);
}
.cap.on { display: flex; }
.cap button { border: 0; background: none; height: 34px; min-width: 34px; padding: 0 6px; color: rgba(0,0,0,.5); display: grid; place-items: center; font: inherit; }
.cap button svg { width: 19px; height: 19px; }
.cap .time { font-size: 13px; color: rgba(0,0,0,.35); padding: 0 6px; }
.cap .detail { font-size: 12.5px; color: rgba(0,0,0,.55); padding: 0 8px; }
.cap button.on { color: var(--jubilee); }

/* 写真・紙・切り抜き */
.photo { display: block; width: 240px; max-width: 100%; aspect-ratio: 4/3; border-radius: 16px; object-fit: cover; margin-bottom: 4px; background: #ddd; }
.paper {
  position: relative; background: var(--paper); border-radius: 16px; padding: 12px 15px; font-size: 14px; line-height: 1.55;
  max-width: 19.6em; white-space: pre-wrap; word-break: break-word;
}
.paper.closed .ptext { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.paper.closed::after { content: "⋯"; position: absolute; right: 12px; bottom: 9px; font-size: 19px; color: rgba(0,0,0,.6); line-height: 1; background: var(--paper); padding-left: 6px; }
.paper.open { font-size: 16px; line-height: 1.6; }

.clip {
  position: relative; background: #fff; border-radius: 3px; padding: 12px 14px 12px; margin-bottom: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.13), 0 0 0 .5px rgba(0,0,0,.06); font-size: 14px; line-height: 1.55; width: 100%; max-width: 21em;
}
.clip .who { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: rgba(0,0,0,.6); margin-bottom: 5px; }
.clip .who img { width: 18px; height: 18px; border-radius: 50%; }
.clip .pin { position: absolute; right: 16px; top: -7px; width: 9px; height: 22px; border: 2px solid #9aa3a8; border-radius: 5px; background: transparent; }
.clip .site { font-size: 11px; color: rgba(0,0,0,.45); }
.clip .ttl { font-weight: 600; }
.clip .desc { font-size: 12.5px; color: rgba(0,0,0,.55); }
.from { font-size: 11.5px; color: var(--stamp); text-align: right; margin-top: 3px; }
.quote { border-radius: 12px; box-shadow: none; background: var(--paper); }

/* ドック */
#dock {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 2px; padding: 6px 10px; border-radius: 40px;
  background: rgba(255,255,255,.82); -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: 0 0 0 .7px rgba(0,0,0,.18), 0 6px 24px rgba(0,0,0,.08); z-index: 20;
}
#dock button { position: relative; width: 56px; height: 44px; border: 0; background: none; border-radius: 22px; display: grid; place-items: center; color: #3a3a3c; padding: 0; }
#dock button.sel { background: #d6e9f7; color: #0a84ff; }
#dock button svg { width: 26px; height: 26px; }
#dock .sep { width: 1px; height: 26px; background: rgba(0,0,0,.1); margin: 0 4px; }
#dock .me img { width: 32px; height: 32px; border-radius: 50%; display: block; }
#dock .me.glow img { box-shadow: 0 0 0 2.5px #fff, 0 0 0 5px #3d8bff; animation: ring 3.2s ease-in-out infinite; }
@keyframes ring { 0%,100% { box-shadow: 0 0 0 2.5px #fff, 0 0 0 5px rgba(61,139,255,.45), 0 0 6px rgba(61,139,255,.2); } 50% { box-shadow: 0 0 0 2.5px #fff, 0 0 0 5px #3d8bff, 0 0 16px rgba(61,139,255,.75); } }

/* 自分のプロフィール */
.card { margin: 4px 8px 6px; padding: 16px; border-radius: 22px; box-shadow: 0 0 0 1px rgba(0,0,0,.13); position: relative; }
.card .head { display: flex; gap: 12px; align-items: center; }
.card .head img { width: 40px; height: 40px; border-radius: 50%; }
.card .nm { font-size: 15px; font-weight: 600; }
.card .hd { font-size: 11px; color: rgba(0,0,0,.45); }
.card .bio { font-size: 11.5px; line-height: 1.7; margin-top: 10px; white-space: pre-wrap; }
.card .gear { position: absolute; right: 8px; top: 8px; }

/* 検索 */
.sfield { flex: none; margin: 10px 12px 4px; padding-top: env(safe-area-inset-top); display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 20px; background: #efefef; }
.sfield svg { width: 18px; height: 18px; color: rgba(0,0,0,.4); flex: none; }
.sfield input { flex: 1; border: 0; background: none; font: inherit; font-size: 16px; outline: none; min-width: 0; }
.hist { padding: 6px 4px; }
.hist .h { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; font-size: 15px; }
.hist .h svg { width: 16px; height: 16px; color: rgba(0,0,0,.35); flex: none; }
.hist .h span { flex: 1; }
.empty { text-align: center; color: rgba(0,0,0,.35); font-size: 13px; padding: 40px 0; }

/* シート */
#layer { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.dim { position: absolute; inset: 0; background: rgba(0,0,0,.18); pointer-events: auto; opacity: 0; transition: opacity .25s; }
.dim.on { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 16px 16px 0 0; pointer-events: auto;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column;
  box-shadow: 0 -2px 20px rgba(0,0,0,.08);
}
.sheet.on { transform: translateY(0); }
.sheet.drag { transition: none; }
.grab { flex: none; height: 22px; display: grid; place-items: center; touch-action: none; }
.grab i { width: 36px; height: 5px; border-radius: 3px; background: #d4d4d4; }
.sheet.full { top: 12px; }
.sheet.half { height: 56%; }

.list { overflow-y: auto; padding: 0 8px 30px; }
.list .sec { height: 1px; background: rgba(0,0,0,.08); margin: 6px 12px; }
.list .it { display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 14px; font-size: 16px; position: relative; }
.list .it svg { width: 22px; height: 22px; color: rgba(0,0,0,.55); }
.list .it.cur::after { content: ""; position: absolute; right: 18px; width: 7px; height: 7px; border-radius: 50%; background: var(--jubilee); }
.list .it.dimmed { color: rgba(0,0,0,.4); }

/* 書く画面 */
.compose { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; touch-action: none; }
.compose .stack { overflow-y: auto; padding: 8px 8px 0; touch-action: pan-y; }
.compose .stack .bubble { cursor: pointer; }
.compose .stack .bubble.editing { outline: 2px solid #9cc8d6; }
.fieldrow { display: flex; align-items: flex-end; padding: 8px 8px 4px; }
.fieldrow .avcol { padding-bottom: 2px; }
.field { position: relative; flex: 1; margin-left: 4px; margin-right: 40px; background: var(--mine-bubble); border-radius: 18px; padding: 9px 50px 9px 15px; }
.field textarea { display: block; width: 100%; border: 0; background: none; resize: none; font: inherit; font-size: 16px; line-height: 1.6; outline: none; height: 51px; max-height: 260px; padding: 0; -webkit-user-select: text; user-select: text; }
.send { position: absolute; right: 6px; bottom: 6px; width: 34px; height: 34px; border: 0; padding: 0; background: none; }
.send svg { width: 34px; height: 34px; }
.send.off { opacity: .35; }
.left20 { position: absolute; right: 46px; bottom: 13px; font-size: 12px; color: rgba(0,0,0,.45); }
.tools { flex: none; display: flex; gap: 6px; padding: 4px 16px calc(14px + env(safe-area-inset-bottom)); }
.tools .ibtn svg { width: 22px; height: 22px; }
.tools .ibtn { color: rgba(0,0,0,.5); }

/* 写真の拡大表示 */
.viewer { position: absolute; inset: 0; background: rgba(0,0,0,.92); display: grid; place-items: center; pointer-events: auto; }
.viewer img { max-width: 100%; max-height: 100%; }

/* 記録のお知らせ */
.consent { position: absolute; inset: 0; background: #fff; pointer-events: auto; display: flex; flex-direction: column; justify-content: center; padding: 32px 28px; }
.consent img { width: 64px; height: 64px; margin-bottom: 18px; }
.consent h1 { font-size: 22px; margin: 0 0 12px; }
.consent p { font-size: 14.5px; line-height: 1.8; margin: 0 0 12px; }
.consent .small { font-size: 12.5px; color: rgba(0,0,0,.55); line-height: 1.7; }
.consent .btns { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.consent button { height: 48px; border-radius: 24px; font: inherit; font-size: 15.5px; border: 0; }
.consent .yes { background: var(--jubilee); color: #fff; }
.consent .no { background: #f0f0f0; color: rgba(0,0,0,.7); }

.settings { padding: 8px 20px 30px; }
.settings h2 { font-size: 15px; margin: 6px 0 10px; }
.settings p { font-size: 13px; line-height: 1.7; color: rgba(0,0,0,.6); margin: 0 0 12px; }
.settings button { height: 44px; padding: 0 18px; border-radius: 22px; border: 0; background: #f0f0f0; font: inherit; }
.settings button.on { background: var(--jubilee); color: #fff; }

#toast { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(30,30,30,.86); color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 18px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 40; white-space: nowrap; }
#toast.on { opacity: 1; }
.scroll, .list, .compose .stack { scrollbar-width: none; }
.scroll::-webkit-scrollbar, .list::-webkit-scrollbar, .compose .stack::-webkit-scrollbar { display: none; }
