/* 웹판 추가 스타일: 로그인 화면, 휴대폰 화면, PC 전용 메뉴 숨김 */
#btnRestore, #btnOpenBackup, #btnOpenData { display: none; }
#btnSide, #sideShade, .sheet-head, .mnav, .fab { display: none; }
.path { cursor: default; }

.login {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-box {
  width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px 24px; display: grid; gap: 12px; box-shadow: 0 10px 30px rgba(20, 30, 50, .08);
}
.login-box h1 { margin: 0; color: var(--accent-text); font-size: 1.4em; }
.login-box p { margin: 0; }
.login-err { color: var(--danger); font-size: .9em; min-height: 1.2em; }

/* 보내기 창 */
.share-box { width: min(680px, 94vw); height: min(720px, 90vh); }
.share-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px 18px 6px; }
#shText { flex: 1; min-height: 200px; resize: none; line-height: 1.55; font-size: .95em; }
.share-body .sub { margin: 0; }
.share-foot { flex-wrap: wrap; }
.share-foot button { flex: 1 1 auto; }
.seg button:disabled { opacity: .4; }

/* ================= 휴대폰 ================= */
@media (max-width: 820px) {
  :root { --nav-h: 60px; --safe-b: env(safe-area-inset-bottom, 0px); }
  body { --fs: 16px; -webkit-tap-highlight-color: transparent; }
  button { touch-action: manipulation; }

  /* 위쪽 바: 이름 + 붙여넣기 + 메뉴 두 개(아이콘) */
  .topbar { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top, 0px)); gap: 6px; flex-wrap: nowrap; }
  .brand { margin: 0; font-size: 1.15em; }
  #btnNew, .zoom { display: none; }
  .topbar button { padding: 6px 12px; }
  #btnPaste { font-size: 0; }
  #btnPaste::after { content: "붙여넣기"; font-size: 15px; }
  .menu > button { font-size: 0; width: 40px; padding: 6px 0; }
  .menu > button[data-menu="io"]::after { content: "⇅"; font-size: 18px; }
  .menu > button[data-menu="bk"]::after { content: "⋯"; font-size: 20px; line-height: 1; }
  .menu-pop { left: auto; right: 0; min-width: 0; width: min(300px, 90vw); }
  .menu-pop button { padding: 12px 14px; }

  /* 가운데 */
  .center-head { padding: 10px 14px 8px; align-items: center; gap: 8px; }
  .center-head { flex-wrap: wrap; }
  .center-head h1 { font-size: 1.15em; white-space: nowrap; }
  #filterChip { font-size: 0; }
  #filterChip::after { content: "검색 중 ✕"; font-size: 12px; }
  .center-head .sub { font-size: .8em; }
  .head-tools { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .head-tools button { padding: 4px 10px; font-size: .85em; }
  .chip { font-size: .78em; }
  .content { padding: 10px 10px calc(var(--nav-h) + var(--safe-b) + 90px); }
  .feed { gap: 10px; }
  .day-sep { font-size: .85em; margin-top: 8px; }
  .card { padding: 12px 12px; border-radius: 12px; }
  .meta { gap: 6px; font-size: .82em; }
  .card .actions { opacity: 1; }
  .card .actions button { padding: 3px 10px; }
  #edSave { font-size: 0; }
  #edSave::after { content: "저장"; font-size: 16px; }
  .card h2 { font-size: 1.05em; }
  .easy { padding: 10px 12px; }
  .clamp { max-height: 240px; }
  .pbox { padding: 10px 12px; }
  .rbtns button { flex: 1 1 auto; padding: 6px 8px; }
  .stats { gap: 6px; }
  .stats .stat { min-width: 0; flex: 1 1 30%; padding: 6px 10px; }
  .stats .stat b { font-size: 1.2em; }

  /* 아래 탭 바 */
  .mnav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 47;
    height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(20, 30, 50, .05);
  }
  .mnav button {
    border: 0; border-radius: 0; background: transparent; color: var(--faint);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; padding: 0;
  }
  .mnav button:hover { background: transparent; }
  .mnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mnav button.on { color: var(--accent); font-weight: 700; }

  /* 새 기록 버튼 */
  .fab {
    display: block; position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 46;
    width: 58px; height: 58px; border-radius: 50%; border: 0; padding: 0;
    background: var(--accent); color: #fff; font-size: 30px; line-height: 58px; text-align: center;
    box-shadow: 0 6px 18px rgba(37, 99, 217, .35);
  }
  .fab:hover { background: var(--accent); }
  body.side-open .fab { display: none; }

  /* 주제·검색 시트 (왼쪽 메뉴를 전체 화면으로) */
  .sidebar {
    position: fixed; left: 0; right: 0; top: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 45;
    width: auto; border: 0; padding: 0 14px 14px; overflow-y: auto; gap: 14px;
    transform: translateY(102%); transition: transform .22s ease; visibility: hidden;
  }
  body.side-open .sidebar { transform: none; visibility: visible; }
  .sheet-head {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 2;
    background: var(--panel); padding: 14px 0 10px; padding-top: max(14px, env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--line); margin-bottom: 2px;
  }
  .sheet-head b { font-size: 1.1em; }
  .sidebar .views { display: none; }
  .side-sec.grow { flex: none; display: block; }
  .side-sec.grow .side-list, #pendingList { max-height: none; overflow: visible; }
  .side-item { padding: 11px 12px; border-bottom: 1px solid var(--panel2); border-radius: 6px; }
  body[data-sheet="search"] .side-sec, body[data-sheet="search"] .side-foot { display: none; }
  body[data-sheet="search"] .sheet-head b::after { content: " · Enter로 결과 보기"; font-size: .7em; color: var(--faint); font-weight: 400; }
  body[data-sheet="topics"] .search, body[data-sheet="topics"] #filters { display: none; }
  .search input { font-size: 16px; padding: 10px 12px; }
  .filters input, .filters select { font-size: 16px; padding: 8px; }

  /* 편집기: 전체 화면 */
  .editor { position: fixed; inset: 0; z-index: 50; width: 100%; border: 0; }
  .ed-head { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top, 0px)); }
  .ed-body { padding: 12px 14px; }
  .ed-foot { padding: 10px 14px calc(10px + var(--safe-b)); }
  .ed-foot button { padding: 10px 16px; }
  .field input, .field textarea, .field select { font-size: 16px; }
  #eBody { min-height: 220px; }
  .easy-input { min-height: 120px; }
  .seg button { padding: 7px 14px; }
  body:has(.editor:not(.hidden)) .fab, body:has(.editor:not(.hidden)) .mnav { display: none; }

  /* 붙여넣기 창: 전체 화면, 위아래로 */
  .modal { z-index: 55; }
  .modal-box { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .paste-grid { grid-template-columns: 1fr; grid-template-rows: 38% 1fr; padding: 10px 12px; }
  #pasteText { font-size: 14px; }
  .hint { margin: 8px 12px 0; font-size: .82em; }

  /* 달력 */
  .cal-head { flex-wrap: wrap; justify-content: center; gap: 6px; }
  .cal-head h2 { min-width: 0; width: 100%; order: -1; font-size: 1.05em; }
  .cal-head button { padding: 6px 12px; font-size: .88em; }
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 56px; padding: 4px; border-radius: 8px; gap: 2px; }
  .cal-day .dn { font-size: .8em; }
  .cal-day .cn { font-size: .7em; }
  .cal-day .due { font-size: .66em; }
  .dot { width: 7px; height: 7px; }

  .toast { bottom: calc(var(--nav-h) + var(--safe-b) + 86px); max-width: 90vw; text-align: center; }
}
