:root {
  --desk: #008080;
  --face: #c0c0c0;
  --light: #dfdfdf;
  --hi: #ffffff;
  --shadow: #808080;
  --dark: #0a0a0a;
  --title1: #000080;
  --title2: #1084d0;
  --sel: #000080;
  --font: 'Galmuri11', 'Gulim', '굴림', 'Apple SD Gothic Neo', sans-serif;

  --raised: inset -1px -1px var(--dark), inset 1px 1px var(--hi), inset -2px -2px var(--shadow), inset 2px 2px var(--light);
  --sunken: inset -1px -1px var(--hi), inset 1px 1px var(--shadow), inset -2px -2px var(--light), inset 2px 2px var(--dark);
  --pressed: inset -1px -1px var(--hi), inset 1px 1px var(--dark), inset -2px -2px var(--light), inset 2px 2px var(--shadow);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: #000;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
body.locked { overflow: hidden; }
button, a.btn { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
p { margin: 0; }
h2 { margin: 0; font-size: inherit; }
[hidden] { display: none !important; }

.pix { display: inline-block; flex: none; image-rendering: pixelated; vertical-align: middle; }
.pix img { display: block; image-rendering: auto; }
.sunken { box-shadow: var(--sunken); }

/* ───── 부팅 ───── */
#boot {
  position: fixed; inset: 0; z-index: 100;
  background: #000;
}
#boot.done { opacity: 0; transition: opacity .35s; pointer-events: none; }
.bios {
  padding: 18px 16px;
  color: #c0c0c0;
  font-family: 'GalmuriMono11', monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.splash {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(#2b6cd4 0%, #5d9bf0 45%, #a8cdf7 100%);
  overflow: hidden;
}
.splash.on { display: flex; }
.clouds {
  position: absolute; inset: -20% -40%;
  background:
    radial-gradient(closest-side, rgba(255,255,255,.85), transparent) 8% 18% / 46% 14% no-repeat,
    radial-gradient(closest-side, rgba(255,255,255,.7), transparent) 70% 10% / 38% 11% no-repeat,
    radial-gradient(closest-side, rgba(255,255,255,.8), transparent) 34% 72% / 52% 15% no-repeat,
    radial-gradient(closest-side, rgba(255,255,255,.65), transparent) 86% 60% / 40% 12% no-repeat,
    radial-gradient(closest-side, rgba(255,255,255,.75), transparent) 20% 92% / 44% 12% no-repeat;
  animation: drift 9s linear infinite alternate;
}
@keyframes drift { to { transform: translateX(8%); } }
.splash-logo { position: relative; text-align: center; color: #fff; text-shadow: 2px 2px 0 rgba(0,0,64,.45); }
.splash-icon { filter: drop-shadow(3px 3px 0 rgba(0,0,64,.35)); }
.splash-names { margin-top: 14px; font-size: 15px; }
.splash-title {
  font-family: 'Galmuri14', var(--font);
  font-size: 40px; font-weight: bold; font-style: italic;
  letter-spacing: -1px; line-height: 1.1;
}
.splash-title span { color: #ffe066; margin-left: 4px; }
.splash-sub { font-size: 12px; opacity: .9; }
.splash-bar {
  position: absolute; left: 0; right: 0; bottom: 64px; height: 10px;
  background: #000; overflow: hidden;
}
.splash-bar i {
  position: absolute; inset: 0; width: 200%;
  background: repeating-linear-gradient(90deg, #000 0, #1a3cff 12%, #4fd6ff 25%, #1a3cff 38%, #000 50%);
  animation: bar 1.3s linear infinite;
}
@keyframes bar { from { transform: translateX(-50%); } to { transform: translateX(0); } }
.splash-tap { position: absolute; bottom: 28px; font-size: 12px; color: #fff; opacity: .85; }

/* ───── 바탕화면 ───── */
.desktop {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 10px calc(64px + env(safe-area-inset-bottom));
}

.icons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 4px;
  margin-bottom: 18px;
}
.dicon {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 2px; border: 0; background: none; cursor: pointer;
  color: #fff;
}
.dicon b {
  font-weight: normal; font-size: 12px; line-height: 1.3;
  padding: 1px 3px; text-align: center;
}
.dicon:focus-visible b, .dicon.sel b { background: var(--sel); outline: 1px dotted #ff0; }
.dicon.sel .pix { filter: brightness(.6) sepia(1) hue-rotate(190deg) saturate(4); }

/* ───── 창 ───── */
.win {
  background: var(--face);
  padding: 3px;
  box-shadow: var(--raised);
  margin-bottom: 18px;
  scroll-margin-top: 12px;
}
.titlebar {
  display: flex; align-items: center; gap: 5px;
  min-height: 24px; padding: 2px 3px 2px 4px;
  background: linear-gradient(90deg, #808080, #b5b5b5);
  color: #d4d0c8;
  font-weight: bold;
  transition: background .2s;
}
.win.active .titlebar { background: linear-gradient(90deg, var(--title1), var(--title2)); color: #fff; }
.titlebar h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.win.flash .titlebar { animation: flash .18s steps(1) 4; }
@keyframes flash { 50% { background: linear-gradient(90deg, #808080, #b5b5b5); color: #d4d0c8; } }

.tb-btns { display: flex; gap: 2px; }
.tb {
  width: 20px; height: 18px; padding: 0;
  border: 0; background: var(--face) center no-repeat;
  box-shadow: var(--raised); cursor: pointer;
}
.tb:active { box-shadow: var(--pressed); background-position: calc(50% + 1px) calc(50% + 1px); }
.tb.close { margin-left: 2px; }
.tb.min   { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='7' shape-rendering='crispEdges'%3E%3Crect x='0' y='5' width='6' height='2'/%3E%3C/svg%3E"); }
.tb.max   { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h9v9H0z M1 2v6h7V2z' fill-rule='evenodd'/%3E%3C/svg%3E"); }
.tb.close { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='7' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h2v1h1v1h2V1h1V0h2v1H7v1H6v1H5v1h1v1h1v1h1v1H6V6H5V5H3v1H2v1H0V6h1V5h1V4h1V3H2V2H1V1H0z'/%3E%3C/svg%3E"); }

.win.min .win-body, .win.min .menubar, .win.min .addr, .win.min .statusbar, .win.min .dialog-btns { display: none; }

.win-body { padding: 8px; }
.menubar { display: flex; gap: 2px; padding: 2px 2px 3px; font-size: 12px; border-bottom: 1px solid var(--shadow); box-shadow: 0 1px 0 var(--hi); }
.menubar span { padding: 1px 6px; }
.addr { display: flex; align-items: center; gap: 6px; padding: 4px 6px; font-size: 12px; border-bottom: 1px solid var(--shadow); box-shadow: 0 1px 0 var(--hi); }
.addr .field { flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.statusbar { display: flex; gap: 2px; margin-top: 2px; font-size: 12px; }
.statusbar span { padding: 2px 6px; }
.statusbar span:first-child { flex: 1; }

.field { display: inline-block; background: #fff; padding: 3px 6px; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 84px; min-height: 30px; padding: 4px 12px;
  border: 0; background: var(--face);
  box-shadow: var(--raised);
  text-decoration: none; cursor: pointer;
}
.btn:active { box-shadow: var(--pressed); padding: 5px 11px 3px 13px; }
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }

.dialog-btns { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 4px 8px 8px; flex-wrap: wrap; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.btn-row .btn { flex: 1 1 0; min-width: 0; padding-left: 4px; padding-right: 4px; }

fieldset {
  margin: 4px 0 12px; padding: 10px 8px 8px;
  border: 1px solid var(--shadow);
  box-shadow: 1px 1px 0 var(--hi), inset 1px 1px 0 var(--hi);
}
legend { padding: 0 4px; }

/* ───── 메인 ───── */
.photo-frame { padding: 2px; background: #000; }
.photo-frame img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.marquee { margin: 8px 0; padding: 3px 0; background: #000; color: #0f0; overflow: hidden; white-space: nowrap; font-size: 12px; }
.marquee span { display: inline-block; padding-left: 100%; animation: marquee 16s linear infinite; }
@keyframes marquee { to { transform: translateX(-100%); } }
.hero { text-align: center; padding: 10px 4px 6px; }
.hero-names { font-family: 'Galmuri14', var(--font); font-size: 22px; font-weight: bold; }
.hero-names i { font-style: normal; color: #d0003a; margin: 0 10px; }
.hero-date { margin-top: 8px; font-size: 14px; }
.hero-venue { margin-top: 2px; color: #333; }

/* ───── 메모장 ───── */
.notepad { background: #fff; padding: 16px 14px; font-size: 14px; line-height: 1.9; }
.greeting { white-space: pre-line; text-align: center; }
.parents { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--shadow); text-align: center; }
.parents p + p { margin-top: 4px; }
.parents small { font-size: 12px; color: #555; margin: 0 8px 0 6px; }
.parents b { font-size: 15px; }
.caret { display: block; width: 8px; height: 16px; margin: 10px auto 0; background: #000; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ───── 날짜 ───── */
.tabs { display: flex; position: relative; z-index: 1; }
.tab {
  padding: 4px 10px 3px; margin-right: -1px;
  background: var(--face);
  box-shadow: inset 1px 1px 0 var(--hi), inset -1px 0 0 var(--dark), inset -2px 0 0 var(--shadow);
  font-size: 12px; margin-top: 3px;
}
.tab.on { margin-top: 0; padding-bottom: 6px; margin-bottom: -2px; }
.tab-panel { padding: 10px 8px 8px; box-shadow: var(--raised); }

.cal-head { display: flex; gap: 6px; margin-bottom: 6px; }
.cal-head .field:first-child { flex: 1; }
.cal-head .spin { width: 80px; text-align: right; }
.cal { background: #fff; padding: 4px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; font-size: 13px; }
.cal .dow { background: var(--shadow); color: #fff; padding: 2px 0; font-size: 12px; }
.cal .d { padding: 6px 0; }
.cal .d.sun { color: #c00000; }
.cal .d.on { background: var(--sel); color: #fff; position: relative; }
.cal .d.on::after { content: '♥'; position: absolute; top: -3px; right: 1px; font-size: 9px; color: #ff6b9a; }

.time-row { display: flex; align-items: center; gap: 14px; }
.clock { width: 112px; height: 112px; flex: none; }
.time-info { display: flex; flex-direction: column; gap: 8px; }
.time-info .field { font-size: 14px; }

.dday { margin-top: 4px; background: #000; color: #0f0; padding: 10px; text-align: center; font-family: 'GalmuriMono11', var(--font); }
.dday-label { font-size: 13px; margin-bottom: 8px; color: #fff; }
.dday-units { display: flex; justify-content: center; gap: 6px; }
.dday-units div { min-width: 54px; }
.dday-units b { display: block; font-size: 22px; line-height: 1.2; }
.dday-units small { font-size: 11px; color: #8f8; }

/* ───── 갤러리 ───── */
.gallery { background: #fff; padding: 10px 6px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 6px; }
.thumb { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer; font-size: 11px; }
.thumb img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border: 1px solid #000; background: var(--light); }
.thumb span { padding: 0 2px; }
.thumb:focus-visible span, .thumb:active span { background: var(--sel); color: #fff; outline: 1px dotted #ff0; }
.thumb:active img { opacity: .7; }

/* ───── 지도 ───── */
.addr-url { color: #000; }
.map-frame { padding: 2px; background: #fff; }
.map-frame iframe { display: block; width: 100%; aspect-ratio: 4 / 3; border: 0; background: var(--light); }
.venue { text-align: center; padding: 12px 0 2px; }
.venue-name { font-size: 15px; font-weight: bold; margin-bottom: 2px; }
.venue a { color: #0000c0; }
.transport { margin-top: 12px; }
.transport p { white-space: pre-line; }

/* ───── 계좌 (트리) ───── */
.note { font-size: 12px; text-align: center; margin: 4px 0 10px; color: #222; }
.tree { background: #fff; padding: 8px 6px; }
.tree details + details { margin-top: 8px; }
.tree summary {
  list-style: none; display: flex; align-items: center; gap: 6px;
  padding: 4px 2px; cursor: pointer; font-weight: bold;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before {
  content: '+'; display: inline-flex; align-items: center; justify-content: center;
  width: 11px; height: 11px; border: 1px solid var(--shadow); background: #fff;
  font: 11px/1 monospace; color: #000;
}
.tree details[open] > summary::before { content: '−'; }
.acct { display: flex; align-items: center; gap: 8px; margin-left: 9px; padding: 8px 0 8px 14px; border-left: 1px dotted var(--shadow); }
.acct + .acct { border-top: 0; }
.acct-info { flex: 1; min-width: 0; font-size: 12px; line-height: 1.6; }
.acct-info b { font-size: 13px; }
.acct-info small { color: #555; margin-left: 4px; }
.acct .btn { min-width: 56px; min-height: 28px; padding: 2px 8px; font-size: 12px; }
.acct .btn:active { padding: 3px 7px 1px 9px; }

/* ───── 연락처 (리스트뷰) ───── */
.listview { background: #fff; padding: 2px; }
.lv-head, .lv-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; }
.lv-head span { background: var(--face); box-shadow: var(--raised); padding: 3px 6px; font-size: 12px; }
.lv-row { padding: 4px 4px; border-bottom: 1px dotted var(--light); }
.lv-row > span { padding: 2px 4px; font-size: 13px; }
.lv-row small { color: #555; font-size: 12px; }
.lv-acts { display: flex; gap: 4px; }
.lv-acts .btn { min-width: 0; min-height: 28px; padding: 2px 8px; font-size: 12px; }
.lv-acts .btn:active { padding: 3px 7px 1px 9px; }
.lv-group { padding: 6px 6px 2px; font-size: 12px; color: var(--sel); font-weight: bold; }

/* ───── 메시지 ───── */
.msg { display: flex; gap: 14px; align-items: flex-start; padding: 16px 14px 10px; }
.msg p { padding-top: 6px; }

/* ───── 시작 메뉴 / 작업표시줄 ───── */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: 4px;
  height: calc(38px + env(safe-area-inset-bottom));
  padding: 3px 3px calc(3px + env(safe-area-inset-bottom));
  background: var(--face);
  box-shadow: inset 0 1px 0 var(--light), inset 0 2px 0 var(--hi);
}
.start {
  display: flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 8px 0 5px;
  border: 0; background: var(--face); box-shadow: var(--raised);
  font-weight: bold; cursor: pointer;
}
.start[aria-expanded="true"] { box-shadow: var(--pressed); }
.task {
  flex: 1; min-width: 0; height: 30px;
  display: flex; align-items: center; gap: 4px; padding: 0 6px;
  box-shadow: var(--pressed);
  background: repeating-conic-gradient(#fff 0 25%, var(--face) 0 50%) 0 0 / 2px 2px;
  font-weight: bold; font-size: 12px;
}
.task #task-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray { height: 30px; display: flex; align-items: center; padding: 0 10px; font-size: 12px; }

.startmenu {
  position: fixed; z-index: 45;
  left: 3px; bottom: calc(36px + env(safe-area-inset-bottom));
  display: flex; width: 232px;
  background: var(--face); padding: 3px;
  box-shadow: var(--raised);
}
.sm-banner {
  width: 26px; flex: none;
  background: linear-gradient(0deg, var(--title1), var(--title2));
  color: #c0c0c0; font-size: 17px;
  writing-mode: vertical-rl; transform: rotate(180deg);
  padding: 8px 0; font-family: 'Galmuri14', var(--font);
}
.sm-banner b { color: #fff; }
.startmenu ul { list-style: none; margin: 0; padding: 0; flex: 1; }
.startmenu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 8px; border: 0; background: none; text-align: left; cursor: pointer; font-size: 13px;
}
.startmenu button:hover, .startmenu button:focus-visible { background: var(--sel); color: #fff; outline: none; }
.startmenu .sep { height: 2px; margin: 3px 2px; border-top: 1px solid var(--shadow); border-bottom: 1px solid var(--hi); }

/* ───── 오버레이 ───── */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(0, 32, 32, .55);
}
.overlay .win { margin: 0; width: 100%; max-width: 440px; }
.msg-win { max-width: 320px !important; }
.viewer-img { background: #000; padding: 2px; }
.viewer-img img { width: 100%; max-height: 62vh; object-fit: contain; margin: 0 auto; }
.viewer-win .dialog-btns { justify-content: space-between; padding-top: 2px; }
#viewer-count { min-width: 64px; text-align: center; }

#shutdown {
  position: fixed; inset: 0; z-index: 120;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  background: #000; color: #ff9933; text-align: center;
  font-family: 'Galmuri14', var(--font); font-size: 20px; line-height: 1.6;
  cursor: pointer;
}
#shutdown small { font-size: 12px; color: #886633; font-family: var(--font); }

@media (prefers-reduced-motion: reduce) {
  .clouds, .splash-bar i, .marquee span, .caret { animation: none; }
  .marquee span { padding-left: 8px; }
}

/* 사진 길게 누르기 저장 / 드래그 방지 */
.photo-frame img, .thumb img, .viewer-img img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* ───── 입력칸 ───── */
.input {
  display: block; width: 100%; margin-top: 3px;
  padding: 6px; border: 0; border-radius: 0;
  background: #fff; box-shadow: var(--sunken);
  font: inherit; font-size: 16px; color: #000;
  -webkit-appearance: none; appearance: none;
}
.input:focus { outline: 1px dotted #000; outline-offset: -4px; }
textarea.input { resize: vertical; min-height: 76px; line-height: 1.5; }
.input::placeholder { color: #808080; }

/* ───── 비밀번호 입력창 ───── */
#prompt .input { margin-top: 10px; }
#prompt .win-body { padding: 14px 14px 6px; }
#prompt-text { white-space: pre-line; }

/* ───── 버디버디 공통 : 윈도우 98 기본 컨트롤 ───── */
.w98-input {
  display: block; width: 100%; min-width: 0; height: 24px;
  padding: 2px 5px; border: 0; border-radius: 0;
  background: #fff; box-shadow: var(--sunken);
  font: inherit; font-size: 16px; color: #000;
  -webkit-appearance: none; appearance: none;
}
.w98-input:focus { outline: 0; }
.w98-input::placeholder { color: #a0a0a0; font-size: 11px; }
.w98-drop { position: absolute; top: 2px; right: 2px; bottom: 2px; width: 16px; background: var(--face); box-shadow: var(--raised); }
.w98-drop::after {
  content: ''; position: absolute; left: 4px; top: 50%; margin-top: -2px;
  border-top: 4px solid #000; border-left: 4px solid transparent; border-right: 4px solid transparent;
}
.w98-check {
  -webkit-appearance: none; appearance: none; flex: none;
  width: 13px; height: 13px; margin: 0;
  background: #fff center no-repeat; box-shadow: var(--sunken);
}
.w98-check:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='7' shape-rendering='crispEdges'%3E%3Cpath d='M6 0h1v2H6v1H5v1H4v1H3v1H2V5H1V4H0V2h1v1h1v1h1V3h1V2h1V1h1z'/%3E%3C/svg%3E"); }
.w98-check:disabled { background-color: var(--face); }
.w98-check:disabled:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='7' shape-rendering='crispEdges'%3E%3Cpath fill='%23808080' d='M6 0h1v2H6v1H5v1H4v1H3v1H2V5H1V4H0V2h1v1h1v1h1V3h1V2h1V1h1z'/%3E%3C/svg%3E"); }

/* ───── 로그인 창 (버디버디 5.9) ───── */
.bb5 {
  position: relative; margin-top: 2px; padding: 6px 6px 0;
  border: 1px solid #8db8c5; border-radius: 7px;
  background: linear-gradient(#c3e3ec, #e2f2f6 22%, #f1f9fb);
  box-shadow: inset 0 0 0 1px #e9f8fc;
}
.bb5-tab {
  position: absolute; z-index: 2; left: 50%; top: 6px; transform: translateX(-50%);
  padding: 1px 18px 2px; white-space: nowrap;
  border: 1px solid #a2c6da; border-top: 0; border-radius: 0 0 12px 12px;
  background: linear-gradient(#f6fcfe, #d7eef7);
  color: #6994ac; font: bold 10px/1.35 Arial, sans-serif;
}
.bb5-sky {
  position: relative; aspect-ratio: 338 / 210; overflow: hidden;
  border: 1px solid #8fbcd0; border-radius: 6px;
  background: linear-gradient(#3a77a8 0%, #4e98c8 17%, #70c6e5 40%, #95dfee 57%, #cdeef5 79%, #eff9fb 100%);
}
.bb5-clouds { position: absolute; inset: 0; width: 100%; height: 100%; }
.bb5-shoe { position: absolute; left: 15%; top: 24%; width: 29%; filter: drop-shadow(1px 2px 1px rgba(25, 75, 115, .25)); }
.bb5-word { position: absolute; left: 40%; top: 34%; width: 45%; }
.bb5-ver { position: absolute; right: 17%; top: 64%; color: #1f385a; font: bold 9px Arial, sans-serif; letter-spacing: .2px; }

.bb5-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 8px; align-items: center; padding: 14px 4px 6px; }
.bb5-rows { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bb5-row { display: flex; align-items: center; gap: 5px; font-size: 12px; color: #333; }
.bb5-label { width: 56px; flex: none; white-space: nowrap; }
.bb5-row > .w98-input, .bb5-combo { flex: 1; min-width: 0; }
.bb5-combo { position: relative; display: block; }
.bb5-combo .w98-input { padding-right: 20px; }
.bb5-dot {
  position: relative; flex: none; width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fbfff0, #d3eaa8 55%, #a3cc72);
  box-shadow: 0 0 0 1px #8db27d;
}
.bb5-dot::after {
  content: ''; position: absolute; left: 5px; top: 3px;
  border-left: 4px solid #4b8c28; border-top: 3.5px solid transparent; border-bottom: 3.5px solid transparent;
}
.bb5-login {
  align-self: stretch; width: 84px;
  display: flex; align-items: center; justify-content: center; gap: 3px;
  border: 1px solid #a5b1b7; border-radius: 5px;
  background: linear-gradient(#ffffff, #f5f7f8 50%, #e2e7ea);
  box-shadow: inset 0 0 0 1px #fff, 1px 1px 1px rgba(0, 0, 0, .12);
  color: #2a2a2a; font: inherit; font-size: 13px; font-weight: bold; cursor: pointer;
}
.bb5-login:active { background: linear-gradient(#e2e7ea, #fafbfc); }
.bb5-checks { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; font-size: 12px; color: #222; }
.bb5-checks label { display: flex; align-items: center; gap: 4px; }
.bb5-checks .off { color: #9a9a9a; text-shadow: 1px 1px 0 #fff; }
.bb5-foot {
  display: flex; justify-content: center; gap: 16px;
  margin: 4px -6px 0; padding: 7px 0 8px;
  border-top: 1px solid #bad5dc; border-radius: 0 0 6px 6px;
  background: linear-gradient(#e8f4f7, #d3e8ee);
  box-shadow: inset 0 1px 0 #fff;
  font-size: 12px; color: #2b3d44;
}
.bb5-foot > *::before { content: '▸ '; font-size: 9px; }
.bb5-foot button { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }

/* ───── 메인 창 : 버디 목록 ───── */
.bbl { margin-top: 1px; padding: 2px; background: #f3f5f3; box-shadow: var(--sunken); }
.bbl-profile {
  position: relative; display: flex; align-items: center; gap: 9px;
  min-height: 60px; padding: 7px 82px 7px 9px;
  border: 1px solid #c5ced1; border-radius: 6px 6px 0 0;
  background: #fff;
}
.bbl-face {
  flex: none; width: 42px; height: 42px; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px #ccd5d8, 1px 2px 5px 3px rgba(0, 0, 0, .14);
}
.bbl-face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; }
.bbl-me { min-width: 0; padding-left: 9px; border-left: 1px dotted #b5b5b5; }
.bbl-me p { display: flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; overflow: hidden; }
.bbl-me b { font-weight: normal; color: #000; }
.bbl-say { display: block !important; margin-top: 4px; color: #222; text-overflow: ellipsis; }
.bbl-topbtns { position: absolute; top: 0; right: 0; width: 80px; }
.bbl-tabs {
  display: flex; gap: 3px; padding: 3px 4px;
  border-top: 2px solid #5e8c90; border-bottom: 1px solid #5b8a90;
  background: linear-gradient(#c4e5eb, #a6d3dd);
}
.bbl-tabs button {
  display: flex; align-items: center; gap: 2px; padding: 2px 7px;
  border: 1px solid #6c9fa7; border-radius: 3px;
  background: linear-gradient(#f3fbfc, #c3e3e9);
  box-shadow: inset 0 0 0 1px #fff;
  color: #1e3a40; font: inherit; font-size: 12px; cursor: pointer;
}
.bbl-tabs button:active { background: linear-gradient(#c3e3e9, #f3fbfc); }
.bbl-body { display: flex; min-height: 230px; background: #fff; }
.bbl-side { flex: none; width: 31px; background: linear-gradient(90deg, #64a2a2, #4f8b8c); }
.bbl-side img { display: block; width: 31px; height: auto; }
.bbl-list { flex: 1; min-width: 0; max-height: 320px; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 3px 2px 6px; background: #fff; }
.bbl-group { display: flex; align-items: center; gap: 5px; padding: 3px 4px; font-size: 12px; color: #000; }
.bbl-fold { position: relative; flex: none; width: 9px; height: 9px; border: 1px solid #808080; background: #fff; }
.bbl-fold::after { content: ''; position: absolute; left: 1px; top: 3px; width: 5px; height: 1px; background: #000; }
.bbl-row {
  display: flex; align-items: center; gap: 4px; width: 100%; min-height: 24px;
  padding: 1px 4px 1px 18px; border: 0; background: none;
  font: inherit; font-size: 12px; text-align: left; white-space: nowrap; cursor: pointer;
}
.bbl-row .pix { flex: none; }
.bbl-name { flex: none; max-width: 48%; overflow: hidden; text-overflow: ellipsis; padding: 1px 2px; color: #000; }
.bbl-msg { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: #4a4a4a; }
.bbl-row.sel .bbl-name { background: var(--sel); color: #fff; }
.bbl-empty { padding: 18px 8px; color: #555; font-size: 12px; white-space: pre-line; text-align: center; }
.bbl-hint { padding: 12px 8px 2px; color: #8a8a8a; font-size: 11px; text-align: center; }
.bbl-more { display: block; margin: 8px auto 2px; }
.bbl-bottom {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px;
  border-top: 1px solid #c7c8c3; border-bottom: 4px solid #5f9aa3;
  background: linear-gradient(#fdfdfb, #e5e7e1);
  font-size: 12px;
}
.bbl-bottom button { display: flex; align-items: center; gap: 2px; padding: 2px 0; border: 0; background: none; font: inherit; color: #111; cursor: pointer; }
.bbl-bottom i { width: 1px; height: 12px; background: #b9b9b9; }
.bbl-status { margin-left: auto; color: #6b6b6b; font-size: 11px; white-space: nowrap; }

/* ───── 받은쪽지 / 쪽지 보내기 창 ───── */
.bbr { padding: 0 5px 5px; background: linear-gradient(#5aa0ab, #4c92a0 60%, #488e9a); }
.bbr-tabs { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; padding-top: 5px; }
.bbr-tab {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 6px;
  margin-bottom: -1px; padding: 2px 18px 3px 7px;
  border: 1px solid #6fa7b0; border-bottom: 0; border-radius: 8px 14px 0 0;
  background: linear-gradient(#ffffff, #f3fafb);
  color: #1a2e36; font-size: 12px; font-weight: bold;
}
.bbr-tools { display: flex; gap: 2px; padding-bottom: 4px; }
.bbr-tools span {
  padding: 1px 6px; font-size: 11px; color: #eef9f9;
  border: 1px solid #3c7d84; border-radius: 2px;
  background: linear-gradient(#80b9bb, #5c9da1);
  box-shadow: inset 0 0 0 1px #a9d7d7;
}
.bbr-main { display: flex; gap: 5px; padding: 5px; border: 1px solid #6fa7b0; border-radius: 0 6px 6px 6px; background: #f3fafb; }
.bbr-left { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; border: 1px solid #9cc9d1; border-radius: 5px; background: #e7f5f6; }
.bbr-head {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 4px 7px; border-bottom: 1px solid #a8d0d7;
  background: linear-gradient(#e7f6f8, #bcdfe4);
  color: #1d2f36; font-size: 12px; white-space: nowrap;
}
.bbr-head > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bbr-time { flex: none; font-size: 11px; }
.bbr-text {
  flex: 1; display: block; width: 100%; min-height: 124px; margin: 0; padding: 8px;
  border: 0; border-radius: 0; background: #e7f5f6;
  color: #000; font: inherit; font-size: 12px; line-height: 1.65; text-align: left;
  white-space: pre-wrap; word-break: break-all;
}
.bbr-read { max-height: 200px; overflow-y: auto; }
textarea.bbr-text { resize: none; min-height: 176px; font-size: 16px; line-height: 1.5; -webkit-appearance: none; appearance: none; }
textarea.bbr-text:focus { outline: 0; }
textarea.bbr-text::placeholder { color: #8fa9af; font-size: 12px; }
.bbr-foot {
  display: flex; align-items: center; gap: 3px; padding: 4px;
  border-top: 1px solid #a8d0d7; background: linear-gradient(#d5edf1, #bfe0e8);
}
.bbr-foot .sp { flex: 1; }
.bbr-btn {
  flex: none; min-height: 22px; padding: 2px 5px;
  border: 1px solid #7aa4ad; border-radius: 4px;
  background: linear-gradient(#ffffff, #e9f4f6);
  box-shadow: inset 0 0 0 1px #fff;
  color: #22343b; font: inherit; font-size: 12px; cursor: pointer;
}
.bbr-btn:active { background: linear-gradient(#dbeaee, #f7fbfc); }
.bbr-btn:disabled { color: #9aabaf; cursor: default; }
.bbr-chip { padding: 0 5px; border: 1px solid #7aa4ad; border-radius: 3px; background: linear-gradient(#fff, #e3f0f3); }
.bbr-emo { display: flex; padding: 1px; border: 1px solid transparent; border-radius: 3px; background: none; cursor: pointer; }
.bbr-emo:active { border-color: #7aa4ad; background: #fff; }
.bbr-count { flex: 1 0 auto; min-width: 0; margin-right: 2px; overflow: hidden; white-space: nowrap; text-align: right; color: #4d6a72; font-size: 10px; }
.bbr-avatar { flex: none; width: 92px; padding: 3px; border: 1px solid #a9c9cf; border-radius: 6px; background: #fff; }
.bbr-avatar > div { height: 100%; display: flex; align-items: center; justify-content: center; padding: 6px 2px; border: 3px double #b8bead; background: #fff; }
.bbr-avatar img { width: 60px; height: auto; }

#bb-compose, #bb-note { background: rgba(0, 32, 32, .45); }
.overlay .bbr-win { max-width: 400px; }

/* 쪽지 도착 팝업 */
.buddy-toasts {
  position: fixed; z-index: 50;
  right: 8px; bottom: calc(46px + env(safe-area-inset-bottom));
  width: min(350px, calc(100vw - 16px));
  pointer-events: none;
}
.buddy-toasts .bbr-win { margin: 0; pointer-events: auto; animation: bbr-in .35s ease-out; }
.buddy-toasts .bbr-win.out { animation: bbr-out .3s ease-in forwards; }
@keyframes bbr-in { from { transform: translateY(110%); opacity: 0; } }
@keyframes bbr-out { to { transform: translateY(110%); opacity: 0; } }
.buddy-toasts .bbr-text { min-height: 104px; }
.buddy-toasts .bbr-read {
  max-height: 104px; overflow: hidden; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
}
.buddy-toasts .bbr-avatar { width: 82px; }
.buddy-toasts .bbr-avatar img { width: 52px; }

/* ───── 친구 정보 보기 ───── */
.overlay .bbi-win { max-width: 380px; }
.bbi { padding: 6px; background: linear-gradient(#e0f2f5, #c8e5eb); }
.bbi-head {
  display: flex; align-items: center; gap: 5px;
  margin-bottom: 6px; padding: 3px 4px 6px;
  border-bottom: 1px solid #9cc9d1;
  color: #1c3a42; font-size: 13px; font-weight: bold;
}
.bbi-main { display: flex; gap: 6px; }
.bbi-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
.bbi-fields p { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.bbi-fields i { flex: none; width: 6px; height: 6px; border: 1px solid #4d8f9a; border-radius: 50%; background: #fff; }
.bbi-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; padding: 2px 5px; border: 1px solid #9cbfc6; border-radius: 3px; background: #fff; }
.bbi-box {
  flex: 1; min-height: 96px; max-height: 170px; overflow-y: auto;
  padding: 5px 6px; border: 1px solid #9cbfc6; border-radius: 3px; background: #fff;
  line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}
.bbi-foot { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 8px; }
.bbi-foot .sp { flex: 1; }

@media (prefers-reduced-motion: reduce) {
  .buddy-toasts .bbr-win, .buddy-toasts .bbr-win.out { animation: none; }
}
.bbr-compose .bbr-avatar { width: 80px; }
.bbr-compose .bbr-avatar img { width: 54px; }
.overlay .bbr-avatar { width: 84px; }
.overlay .bbr-avatar img { width: 56px; }

/* ───── 아바타 선택 ───── */
.overlay .bba-win { max-width: 330px; }
.bba-main { flex-direction: column; gap: 10px; padding: 12px 10px; }
.bba-text { color: #1d2f36; font-size: 12px; text-align: center; }
.bba-pick { display: flex; justify-content: center; gap: 14px; }
.bba-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 0; border: 0; background: none;
  color: #1d2f36; font: inherit; cursor: pointer;
}
.bba-opt .bbr-avatar { display: block; width: 100px; height: 176px; }
.bba-opt .bbr-avatar img { width: 62px; }
.bba-opt b { padding: 1px 10px; font-size: 12px; font-weight: normal; }
.bba-opt.on .bbr-avatar { border-color: var(--sel); box-shadow: 0 0 0 1px var(--sel); }
.bba-opt.on b, .bba-opt:focus-visible b { background: var(--sel); color: #fff; }
.bba-opt:active .bbr-avatar > div { background: #e7f5f6; }
button.bbr-avatar { position: relative; display: block; color: inherit; font: inherit; cursor: pointer; }
.bba-change { position: absolute; left: 6px; right: 6px; bottom: 9px; color: #5b7680; font-size: 10px; text-align: center; }
