/* Sumi 화면. 주묵(朱墨): 쓴 것은 먹, 표시한 것은 주묵.
   글씨 공부의 두 먹처럼 사용자가 쓴 글자는 모두 먹이고, 사용자가 남긴 표시(끝낸 일의 동그라미와 줄긋기, 캐럿,
   링크 밑줄, 고정, 지금 연 노트)만 주묵이다. 주묵은 앱 아이콘의 주홍이다. 삭제는 주묵과 다른 짙은 진홍.
   글꼴: 화면 글자와 본문은 Pretendard(한글)와 Pretendard JP(가나·한자), 노트 제목·소제목·목록의 보기 이름은
   본명조 한 집안(Noto Serif KR과 JP). 어느 것이든 fonts/의 글자 범위별 조각을 필요할 때만 받는다. */

:root {
  /* 바탕: 본문 칸이 가장 밝고, 목록과 사이드바가 한 단계씩 물러난다(아주 옅게 따뜻한 먹) */
  --bg-doc: #ffffff;
  --bg-list: #faf9f7;
  --bg-side: #f4f2ef;
  --bg-raised: #ffffff;
  --bg-hover: #eeebe7;
  --bg-side-sel: #e7e3de;
  --line: #eae6e1;
  --line-strong: #d6d0c9;

  /* 글자: 먹의 농도 */
  --ink-strong: #141312; /* 제목, 낱말 표시 */
  --ink: #1c1b1a;
  --text-2: #57524d;
  --text-3: #645e58;
  --quote: #34302d;
  --icon: #2c2926;
  --mk: #8a837c; /* 캐럿 줄의 마크다운 표지 */

  /* 주묵: 사용자가 남긴 표시에만(체크, 줄긋기, 캐럿, 링크 밑줄, 고정, 지금 연 노트) */
  --shu: #b5412a;
  --accent-tint: #f1eeea; /* 고른 노트: 먹을 옅게 푼 물 */
  --sel: #f6dcd3; /* 고른 글자: 주묵을 옅게 */

  /* 위험: 삭제에만. 주묵과 다른 짙은 진홍이고, 메뉴에서는 휴지통 아이콘과 이름으로도 갈린다 */
  --danger: #8e1f35;
  --on-danger: #ffffff;

  /* 먹색 단추 */
  --solid: #1c1b1a;
  --on-solid: #ffffff;
  --bubble-off: #cdc7c1;

  --check-border: #8a847e;
  --focus: rgba(28, 27, 26, 0.55);
  --menu-shadow: 0 1px 2px rgba(28, 24, 20, 0.06), 0 8px 24px rgba(28, 24, 20, 0.08);
  --scrim: rgba(28, 24, 20, 0.24);
  --tip-bg: #3b3835;
  --tip-text: #ffffff;
  --tip-key: #bdb6b0;
  --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b5412a' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");

  /* 글꼴. 한글은 Pretendard, 가나는 Pretendard JP(서로의 범위에 없는 글자는 다음 것으로 넘어간다).
     한자와 라틴은 둘 다 갖고 있어서, 일본어로 표시된 곳(lang="ja")만 JP 판을 먼저, 나머지는 KR 판을 먼저 쓴다.
     --ff-ko·--ff-ja는 그 자리의 글꼴 벌이고, 명조 자리(제목, 소제목, 보기 이름)는 둘을 명조로 바꾼다. */
  --sans-ko: 'Pretendard Variable', 'Pretendard JP Variable', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Hiragino Sans', system-ui, sans-serif;
  --sans-ja: 'Pretendard JP Variable', 'Pretendard Variable', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --serif-ko: 'Noto Serif KR', 'Noto Serif JP', 'Apple Myungjo', 'Batang', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --serif-ja: 'Noto Serif JP', 'Noto Serif KR', 'Hiragino Mincho ProN', 'Yu Mincho', 'Apple Myungjo', 'Batang', serif;
  --ff-ko: var(--sans-ko);
  --ff-ja: var(--sans-ja);
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* 끝낸 일: 주묵 줄긋기의 굵기(e2e/shots/identity-strike-*.png에서 비교해 골랐다) */
  --strike-w: 1px;

  --w-side: 248px;
  --w-list: 336px;
  --pad: 40px;
  --measure: 640px; /* 본문 16px × 전각 40자 */
  --task-indent: 30px;
  --kbar-space: 0px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* 어두운 화면은 반대로: 사이드바가 가장 어둡고 본문 칸이 한 단계 떠 있다. 주묵은 밝게 */
    --bg-doc: #1b1a19;
    --bg-list: #171615;
    --bg-side: #121110;
    --bg-raised: #242220;
    --bg-hover: #2b2926;
    --bg-side-sel: #2a2724;
    --line: #2a2725;
    --line-strong: #3b3734;

    --ink-strong: #f3efea;
    --ink: #e8e3dd;
    --text-2: #ada69f;
    --text-3: #9b948d;
    --quote: #ccc5be;
    --icon: #d6d0c9;
    --mk: #7d766f;

    --shu: #ee8468;
    --accent-tint: #26231f;
    --sel: #4a2a22;

    --danger: #ff9aae;
    --on-danger: #1b1a19;

    --solid: #e8e3dd;
    --on-solid: #1b1a19;
    --bubble-off: #57524d;

    --check-border: #8b847d;
    --focus: rgba(232, 227, 221, 0.6);
    --menu-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.32);
    --scrim: rgba(0, 0, 0, 0.45);
    --tip-bg: #3b3835;
    --tip-text: #f3efea;
    --tip-key: #bdb6b0;
    --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ee8468' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg-doc);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

html {
  font-family: var(--ff-ko);
}

/* 글자의 언어를 아는 곳(lang 속성)마다 그 언어의 판을 먼저 쓴다. 화면 언어가 일본어이면 <html lang="ja">라 JP 판이 먼저,
   그 안에서도 한글이 든 줄(편집기가 lang="ko"를 붙임)과 한국어 제목은 KR 판이 먼저다. */
[lang] {
  font-family: var(--ff-ko);
}

[lang]:lang(ja) {
  font-family: var(--ff-ja);
}

/* 명조 자리: 노트 제목(편집 칸과 목록), 소제목(제목 1~3), 목록의 보기 이름, 낱말 표시(윤곽 SVG).
   본문, 목록의 미리보기와 날짜, 인용, 번호, 노트북 첫 글자, 화면 글자는 모두 고딕이다 */
#title,
#view-title,
.item-title-text,
.prose h1,
.prose h2,
.prose h3 {
  --ff-ko: var(--serif-ko);
  --ff-ja: var(--serif-ja);
  font-family: var(--ff-ko);
}

:is(#title, #view-title, .item-title-text, .prose h1, .prose h2, .prose h3):lang(ja) {
  font-family: var(--ff-ja);
}

/* 코드 안의 일본어 구간도 고정폭 글꼴 벌을 따른다 */
.prose code,
.prose pre {
  --ff-ko: var(--mono);
  --ff-ja: var(--mono);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

::selection {
  background: var(--sel);
}

/* 아이콘: 모두 Lucide, 18px에서 선 굵기 1.5px */
.i {
  width: 18px;
  height: 18px;
  flex: none;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  flex: none;
}

.icon-btn:hover:not(:disabled),
.icon-btn.on,
.icon-btn[aria-expanded='true'] {
  background: var(--bg-hover);
  color: var(--ink);
}

.icon-btn.small {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.icon-btn.solid {
  background: var(--solid);
  color: var(--on-solid);
  border-radius: 8px;
  margin-left: 4px;
}

.icon-btn.solid:hover:not(:disabled) {
  background: var(--solid);
  color: var(--on-solid);
  opacity: 0.88;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 550;
}

.text-btn .i {
  width: 16px;
  height: 16px;
}

.text-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--ink);
}

.text-btn.danger,
.text-btn.danger:hover:not(:disabled) {
  color: var(--danger);
}

.solid-btn {
  background: var(--solid);
  color: var(--on-solid);
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13.5px;
}

.solid-btn.danger {
  background: var(--danger);
  color: var(--on-danger);
}

/* 낱말 표시 「sumi」: 명조 윤곽(SVG)에 i의 점이 주묵 네모(src/renderer/wordmark.js). 높이로 크기를 정한다 */
.wordmark {
  display: inline-block;
  height: 21px;
  line-height: 0;
}

.wordmark svg {
  display: block;
  height: 100%;
  width: auto;
}

.wordmark .wm-ink {
  fill: var(--ink-strong);
}

.wordmark .wm-dot {
  fill: var(--shu);
}

/* ---------- 배치: 세 칸 ---------- */

#app {
  display: grid;
  grid-template-columns: var(--w-side) var(--w-list) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

@media (max-width: 1199px) {
  :root {
    --w-side: 224px;
    --w-list: 300px;
    --pad: 28px;
  }
}

/* ---------- 사이드바 ---------- */

#sidebar {
  background: var(--bg-side);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 10px 0;
  font-size: 14px;
}

.brand {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 8px 0 10px;
  margin-bottom: 10px;
  flex: none;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  margin: 0 0 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-3);
  cursor: text;
}

@media (prefers-color-scheme: dark) {
  .search {
    background: var(--bg-doc);
  }
}

.search:focus-within {
  border-color: var(--line-strong);
}

#search {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  padding: 0;
  color: var(--ink);
}

#search::placeholder {
  color: var(--text-3);
}

#search::-webkit-search-cancel-button {
  filter: grayscale(1);
}

#nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -10px;
  padding: 0 10px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--ink);
  font-weight: 500;
  text-align: left;
}

.nav-item > .i {
  color: var(--text-2);
}

.nav-item .label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item .count {
  font-size: 12px;
  color: var(--text-3);
  font-feature-settings: 'tnum';
  font-weight: 500;
}

.nav-item:hover {
  background: var(--bg-hover);
}

@media (prefers-color-scheme: dark) {
  .nav-item:hover {
    background: var(--bg-raised);
  }
}

.nav-item.active {
  background: var(--bg-side-sel);
  font-weight: 650;
}

.nav-item.active > .i {
  color: var(--ink);
}

.nav-item.active .count {
  color: var(--text-2);
}

.nav-item.drop {
  box-shadow: inset 0 0 0 2px var(--line-strong);
}

.nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  padding: 14px 6px 4px 10px;
  height: 44px;
}

.nav-head .icon-btn {
  color: var(--text-3);
}

.nav-gap {
  height: 10px;
}

/* 노트북: 이름의 첫 글자를 작은 판에 */
.mono {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1;
  color: var(--text-2);
  box-shadow: inset 0 0 0 1.25px var(--line-strong);
  background: var(--bg-raised);
}

@media (prefers-color-scheme: dark) {
  .mono {
    background: var(--bg-doc);
  }
}

/* 태그: 「#」을 아이콘 자리에 */
.hash {
  width: 18px;
  flex: none;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-3);
}

.side-foot {
  flex: none;
  border-top: 1px solid var(--line);
  margin: 0 -10px;
  padding: 8px 8px 10px;
}

.account-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px 6px 10px;
  border-radius: 8px;
  text-align: left;
  color: var(--ink);
}

.account-btn:hover {
  background: var(--bg-hover);
}

@media (prefers-color-scheme: dark) {
  .account-btn:hover {
    background: var(--bg-raised);
  }
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--solid);
  color: var(--on-solid);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 650;
  flex: none;
}

.acc-who {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.acc-line {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-email {
  font-size: 13px;
  font-weight: 500;
}

.acc-plan,
.acc-status {
  font-size: 12px;
  color: var(--text-3);
}

.acc-plan.pro {
  color: var(--text-2);
  font-weight: 600;
}

.acc-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--danger);
}

.acc-status .i {
  width: 13px;
  height: 13px;
}

.acc-gear {
  color: var(--text-2);
}

/* ---------- 노트 목록 ---------- */

#list-pane {
  background: var(--bg-list);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  box-shadow: inset 1px 0 0 var(--line);
  position: relative;
}

.list-bar {
  display: none;
}

.list-head {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 64px;
  padding: 0 14px 0 22px;
  flex: none;
}

#open-nav {
  display: none;
  margin-left: -8px;
  margin-right: 4px;
}

#view-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-strong);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-count {
  flex: 1;
  font-size: 13px;
  color: var(--text-3);
  margin-left: 8px;
  font-feature-settings: 'tnum';
  font-weight: 500;
}

.search-slot:empty {
  display: none;
}

#search-slot-list {
  padding: 0 14px 8px;
}

#search-slot-list .search {
  margin: 0;
}

.trash-tools {
  padding: 0 14px 8px 12px;
}

#note-list {
  list-style: none;
  margin: 0;
  padding: 0 10px 12px;
  overflow-y: auto;
  flex: 1;
  outline: none;
}

.note-item {
  padding: 12px 12px 13px;
  border-radius: 9px;
  position: relative;
  cursor: default;
}

.note-item + .note-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 1px;
  background: var(--line);
}

.note-item:hover {
  background: var(--bg-hover);
}

.note-item:hover::before,
.note-item:hover + .note-item::before,
.note-item.selected::before,
.note-item.selected + .note-item::before {
  display: none;
}

/* 지금 연 노트: 옅은 먹 바탕과 제목 앞의 주묵 네모(낱말 표시의 점과 같은 꼴) */
.note-item.selected {
  background: var(--accent-tint);
}

.note-item.selected .item-title::before {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  margin-right: 1px;
  background: var(--shu);
}

.item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink-strong);
}

.item-title-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 고정은 사용자가 남긴 표시라 주묵 */
.item-pin {
  color: var(--shu);
  display: flex;
}

.item-pin .i {
  width: 15px;
  height: 15px;
  stroke-width: 2.4;
}

.item-snippet {
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 1.55em;
  /* 한국어는 어절, 일본어는 글자(금칙), 영어는 낱말 단위로 줄을 바꾼다 */
  word-break: keep-all;
  overflow-wrap: break-word;
  line-break: strict;
}

.item-snippet [lang='ja'],
.item-title [lang='ja'] {
  word-break: normal;
}

.item-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}

.item-nb {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

li.empty {
  color: var(--text-3);
  padding: 28px 12px;
  list-style: none;
}

mark {
  background: var(--bg-side-sel);
  color: inherit;
  font-weight: 700;
  border-radius: 2px;
}

.new-note-fab {
  display: none;
}

/* ---------- 편집 칸 ---------- */

#editor-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-doc);
  box-shadow: inset 1px 0 0 var(--line);
  position: relative;
}

#note-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.ebar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px 0 var(--pad);
  position: relative;
}

/* 서식 아이콘 줄: 한 줄, 넘치면 「더 보기」로 접는다(왼쪽 끝·폭은 format-ui.js가 본문 칸에 맞춘다) */
.fmt-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pad);
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
  overflow: hidden;
}

.fmt-bar .tb {
  width: 34px;
  color: var(--icon);
}

.fmt-bar .tgap {
  width: 1px;
  height: 18px;
  margin: 0 9px;
  flex: none;
  background: var(--line-strong);
}

.bar-gap {
  flex: 1;
}

.back-btn {
  display: none;
  align-items: center;
  gap: 2px;
  height: 44px;
  padding-right: 8px;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
}

.back-btn .i {
  width: 22px;
  height: 22px;
  stroke-width: 1.636;
}

.back-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-actions,
.trash-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

#pin-btn[aria-pressed='true'],
#pin-btn[aria-pressed='true']:hover:not(:disabled) {
  color: var(--shu);
}

.editor-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 var(--pad) calc(80px + var(--kbar-space));
  position: relative;
}

.doc {
  width: min(var(--measure), 100%);
  margin: 0 auto;
  padding: 36px 0 0;
  display: flex;
  flex-direction: column;
}

#title {
  display: block;
  width: 100%;
  border: 0;
  outline: none;
  background: none;
  resize: none;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.34;
  color: var(--ink-strong);
  padding: 0;
  margin: 0;
  overflow: hidden;
  caret-color: var(--shu);
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* 일본어 제목(가나가 든 제목)은 글자 단위로 줄을 바꾼다 */
#title:lang(ja) {
  word-break: normal;
  line-break: strict;
}

#title::placeholder {
  color: var(--text-3);
  opacity: 0.7;
}

.meta-nb {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-weight: 550;
  padding: 2px 6px;
  margin-left: -6px;
  border-radius: 6px;
  max-width: 220px;
}

.meta-nb:hover:not(:disabled) {
  background: var(--bg-hover);
}

.meta-nb:disabled {
  opacity: 1;
}

.nb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-name.none {
  color: var(--text-3);
  font-weight: 500;
}

.tag-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  flex: 1;
  min-width: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  color: var(--text-2);
  white-space: nowrap;
  position: relative;
}

/* 태그 빼기: 태그에 마우스를 올리면 오른쪽에 겹쳐 보인다(자리를 차지하지 않는다) */
.chip-x {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: 1px;
  border-radius: 4px;
  color: var(--text-3);
  opacity: 0;
}

.chip-x .i {
  width: 12px;
  height: 12px;
}

.chip:hover .chip-x,
.chip-x:focus-visible {
  opacity: 1;
}

.chip-x:hover {
  color: var(--ink);
  background: var(--bg-hover);
}

/* 노트 정보 줄은 없다(⋮ → 정보): 제목 바로 아래 본문 */
.doc-body-wrap {
  position: relative;
  margin-top: 14px;
}

/* ---------- 본문 ---------- */

.prose {
  min-height: 50vh;
  outline: none;
  font-size: 16px;
  line-height: 1.7;
  caret-color: var(--shu);
  /* 한국어: 어절 단위, 영어: 낱말 단위(넘치는 긴 낱말만 자름), 한중일 문장부호 금칙 */
  word-break: keep-all;
  overflow-wrap: break-word;
  line-break: strict;
  font-feature-settings: 'palt' 0;
}

/* 일본어 구간(편집기가 lang="ja"로 감싼다): 글자 단위 + 금칙 */
.prose [lang='ja'] {
  word-break: normal;
  line-break: strict;
}

.prose > :first-child {
  margin-top: 0;
}

/* Enter는 새 줄: 문단 사이에 여백을 두지 않는다. 비워 둔 줄은 빈 문단 하나(한 줄 높이). */
.prose p {
  margin: 0;
}

.prose h1,
.prose h2,
.prose h3 {
  line-height: 1.45;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--ink-strong);
  /* 줄 사이는 빈 줄로 띄운다(Enter = 새 줄). 제목에는 아주 조금만 */
  margin: 0.3em 0 0.05em;
}

.prose h1 {
  font-size: 24px;
}

.prose h2 {
  font-size: 20px;
}

.prose h3 {
  font-size: 17px;
}

.prose strong {
  font-weight: 700;
}

.prose ul,
.prose ol {
  padding-left: 1.5em;
  margin: 0.15em 0 0.25em;
}

.prose li > ul,
.prose li > ol,
.prose li > div > ul,
.prose li > div > ol {
  margin: 0;
}

.prose li > p,
.prose li > div > p {
  margin: 0;
}

.prose li::marker {
  color: var(--text-2);
}

.prose ul[data-type='taskList'] {
  list-style: none;
  padding-left: 0;
}

.prose ul[data-type='taskList'] li {
  display: flex;
  align-items: flex-start;
  position: relative;
}

.prose ul[data-type='taskList'] li > label {
  flex: none;
  width: var(--task-indent);
  height: 1.7em;
  display: flex;
  align-items: center;
  user-select: none;
}

.prose ul[data-type='taskList'] li > div {
  flex: 1;
  min-width: 0;
}

.prose ul[data-type='taskList'] input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  margin: 0;
  border-radius: 50%;
  border: 1.5px solid var(--check-border);
  background: transparent center / 0 0 no-repeat;
  cursor: pointer;
  transition: background-size 0.24s ease-out;
}

/* 끝낸 일: 주묵으로 동그라미를 치고(한국과 일본의 시험지에서 「맞음」) 글에 주묵 줄을 긋는다. 글자는 옅은 먹으로 읽힌다.
   체크하는 순간에만 체크가 동그라미 가운데에서 번져 나오고(0.24초) 이어서 줄이 짙어진다(0.2초). 노트를 열 때는 움직이지 않는다 */
.prose ul[data-type='taskList'] input[type='checkbox']:checked {
  border-color: var(--shu);
  border-width: 1.75px;
  background-image: var(--check-mark);
  background-size: 11px 11px;
}

.prose ul[data-type='taskList'] li > div {
  text-decoration: line-through transparent;
  text-decoration-thickness: var(--strike-w);
  text-decoration-skip-ink: none;
  transition: text-decoration-color 0.2s ease-out 0.12s;
}

.prose ul[data-type='taskList'] li[data-checked='true'] > div {
  color: var(--text-2);
  text-decoration-color: var(--shu);
}

@media (prefers-reduced-motion: reduce) {
  .prose ul[data-type='taskList'] input[type='checkbox'],
  .prose ul[data-type='taskList'] li > div {
    transition: none;
  }
}

.prose blockquote {
  margin: 0.3em 0 0.4em;
  padding: 0 0 0 15px;
  box-shadow: inset 2px 0 0 var(--line-strong);
  color: var(--quote);
}

.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-hover);
  border-radius: 4px;
  padding: 1px 4px;
}

.prose pre {
  background: var(--bg-list);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0.5em 0 0.6em;
  overflow-x: auto;
  line-height: 1.55;
  word-break: normal;
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: 13.5px;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line-strong);
  margin: 1.2em 0;
}

/* 링크: 먹 글자에 주묵 밑줄 */
.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  text-decoration-color: var(--shu);
  cursor: text;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
  margin: 0.4em 0 0.8em;
}

.prose img.ProseMirror-selectednode {
  outline: 2px solid var(--sel);
}

.prose table {
  border-collapse: collapse;
  margin: 0.6em 0 0.8em;
  width: 100%;
  table-layout: fixed;
}

.prose th,
.prose td {
  border: 1px solid var(--line-strong);
  padding: 5px 9px;
  vertical-align: top;
  text-align: left;
}

.prose th {
  background: var(--bg-list);
  font-weight: 650;
}

.prose td > p,
.prose th > p {
  margin: 0;
}

.prose .selectedCell {
  background: var(--sel);
}

.prose s {
  color: var(--text-2);
}

/* 캐럿 줄의 마크다운 표지: 본문과 같은 서체, 더 가벼운 무게, 흐린 먹색(바탕 대비 3:1 이상) */
.prose .mk {
  color: var(--mk);
  font-weight: 400;
  font-style: normal;
  text-decoration: none;
  white-space: pre;
  user-select: none;
}

.prose h1 .mk,
.prose h2 .mk,
.prose h3 .mk {
  font-weight: 500;
}

.prose .mk.url {
  /* 주소는 한 덩어리로 줄을 바꾸고, 한 줄보다 길 때만 자른다 */
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}

/* 체크리스트 줄: 「- [ ] 」를 체크 상자 자리(같은 폭)에 둔다. 글자가 움직이지 않는다.
   진짜 체크 상자는 투명하게 그 위에 남아 그 자리를 누르면 그대로 체크된다. 키보드로 초점이 가면 상자가 보인다 */
.prose ul[data-type='taskList'] li.mk-task > label {
  opacity: 0;
  position: relative;
  z-index: 1;
}

.prose ul[data-type='taskList'] li.mk-task > label:focus-within {
  opacity: 1;
}

.prose ul[data-type='taskList'] li.mk-task:has(> label:focus-within)::before {
  visibility: hidden;
}

.prose ul[data-type='taskList'] li.mk-task::before {
  content: attr(data-mk);
  position: absolute;
  left: 0;
  top: 0;
  width: var(--task-indent);
  line-height: 1.7;
  white-space: pre;
  overflow: hidden;
  color: var(--mk);
  letter-spacing: -0.02em;
  text-decoration: none;
  pointer-events: none;
}

/* 목록 줄: 글머리 자리에 「- 」「1. 」(글머리는 글자 칸 밖이라 글자가 움직이지 않는다) */
.prose li.mk-li::marker {
  color: var(--mk);
  font-weight: 400;
}

/* 인용 줄: 왼쪽 막대 자리에 「>」 */
.prose blockquote:has(> .mk-quote) {
  box-shadow: none;
}

.prose blockquote > p.mk-quote {
  position: relative;
}

.prose blockquote > p.mk-quote::before {
  content: '>';
  position: absolute;
  left: -15px;
  color: var(--mk);
  font-weight: 400;
}

.prose p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: var(--text-3);
  pointer-events: none;
  height: 0;
}

/* ---------- 떠 있는 것: 메뉴, 툴팁, 고른 글자 막대 ---------- */

.menu {
  position: fixed;
  z-index: 50;
  min-width: 212px;
  max-width: calc(100vw - 16px);
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--menu-shadow);
  padding: 5px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

.menu-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  scrollbar-width: thin;
}

.menu .mi {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 34px;
  padding: 0 10px 0 9px;
  border-radius: 6px;
  white-space: nowrap;
  color: var(--ink);
  text-align: left;
  outline: none;
}

.menu .mi .i {
  color: var(--text-2);
}

.menu .mi .lbl {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu .mi .key {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.04em;
  font-feature-settings: 'tnum';
}

.menu .mi .key.md {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  min-width: 26px;
  text-align: right;
  font-family: var(--mono);
}

.menu .mi.on,
.menu .mi:focus-visible {
  background: var(--bg-hover);
}

.menu .mi .tick {
  color: var(--ink);
}

.menu .mi.danger,
.menu .mi.danger .i {
  color: var(--danger);
}

.menu .mi:disabled {
  opacity: 0.45;
}

.menu .sep {
  height: 1px;
  background: var(--line);
  margin: 5px 4px;
  flex: none;
}

.menu-empty {
  padding: 8px 10px;
  color: var(--text-3);
}

.ctx-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.ctx-menu {
  min-width: 180px;
}

.tip {
  position: fixed;
  z-index: 60;
  background: var(--tip-bg);
  color: var(--tip-text);
  font-size: 12px;
  line-height: 1;
  font-weight: 500;
  padding: 7px 9px;
  border-radius: 6px;
  white-space: nowrap;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.tip .key {
  color: var(--tip-key);
  letter-spacing: 0.05em;
}

.bubble {
  position: fixed;
  z-index: 55;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--solid);
  color: var(--on-solid);
  border-radius: 9px;
  box-shadow: 0 1px 2px rgba(20, 20, 25, 0.12), 0 6px 18px rgba(20, 20, 25, 0.14);
}

.bubble .b {
  width: 32px;
  height: 30px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--bubble-off);
}

.bubble .b:hover {
  color: var(--on-solid);
  background: color-mix(in srgb, var(--on-solid) 9%, transparent);
}

.bubble .b.on {
  color: var(--on-solid);
  background: color-mix(in srgb, var(--on-solid) 16%, transparent);
}

.bubble .gap {
  width: 1px;
  margin: 7px 3px;
  background: color-mix(in srgb, var(--on-solid) 22%, transparent);
}

/* 휴대폰: 키보드 바로 위의 서식 막대(위치는 visualViewport를 보고 format-ui.js가 정한다) */
.kbar {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 40;
  height: 46px;
  display: flex;
  align-items: center;
  padding: 0 calc(env(safe-area-inset-right) + 6px) 0 calc(env(safe-area-inset-left) + 6px);
  background: var(--bg-doc);
  box-shadow: inset 0 0.5px 0 var(--line-strong);
}

.kbar .k {
  flex: 1;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--icon);
  border-radius: 9px;
}

.kbar .k .i {
  width: 22px;
  height: 22px;
  stroke-width: 1.636;
}

.kbar .k.on {
  background: var(--bg-hover);
  color: var(--ink);
}

/* 글자를 골랐거나 캐럿이 링크 안이면 막대가 글자 꾸밈(굵게, 기울임, 취소선, 코드, 링크, 서식 지우기)으로 바뀐다 */
.kbar[data-mode='block'] .k[data-set='inline'],
.kbar[data-mode='inline'] .k[data-set='block'] {
  display: none;
}

.kdiv {
  width: 1px;
  height: 22px;
  background: var(--line-strong);
}

/* ---------- 창 ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18vh;
  z-index: 70;
}

.modal-box {
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 18px;
  width: 360px;
  box-shadow: var(--menu-shadow);
}

.modal-box label {
  display: block;
  font-weight: 650;
  margin-bottom: 10px;
}

#modal-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg-doc);
  padding: 8px 10px;
  outline: none;
}

#modal-input:focus {
  border-color: var(--text-3);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 14px;
}

.modal.confirm-layer {
  z-index: 80;
}

.confirm-box .confirm-msg {
  margin: 0;
  font-weight: 650;
  line-height: 1.5;
}

.confirm-box .confirm-detail {
  margin: 8px 0 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  max-width: min(520px, calc(100vw - 32px));
  background: var(--solid);
  color: var(--on-solid);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  z-index: 75;
  box-shadow: var(--menu-shadow);
}

/* 오래 걸리는 일(내보내기)의 진행: 왼쪽 아래, 편집을 막지 않는다 */
.task {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 74;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(440px, calc(100vw - 36px));
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--menu-shadow);
  padding: 8px 8px 8px 14px;
  font-size: 13px;
  color: var(--text-2);
  font-feature-settings: 'tnum';
}

.task-text {
  flex: 1;
  min-width: 0;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 5px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- 시트(계정·Sumi Plus·기기·버전 기록) ---------- */

.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: var(--scrim);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 16px;
}

.sheet {
  width: 520px;
  max-width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--menu-shadow);
}

.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 10px 10px 12px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.sheet-head > :first-child {
  justify-self: start;
}

.sheet-head > :last-child {
  justify-self: end;
}

.sheet-body {
  overflow-y: auto;
  padding: 18px 20px 22px;
}

.muted {
  color: var(--text-3);
}

.acc-who-email {
  font-size: 16px;
  font-weight: 650;
  word-break: break-all;
}

.acc-who-name {
  color: var(--text-2);
  margin-top: 2px;
}

.acc-sync {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--danger);
}

.acc-sync.muted {
  color: var(--text-3);
}

.menu-list {
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.menu-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border-bottom: 1px solid var(--line);
  padding: 12px 4px;
  text-align: left;
  font-size: 14.5px;
}

.menu-row:hover:not(:disabled) {
  background: var(--bg-hover);
}

.menu-row.danger {
  color: var(--danger);
}

.menu-side {
  color: var(--text-3);
  font-size: 13px;
}

/* 시트 위에서 연 메뉴(정보 시트의 노트북 옮기기)는 시트 위에 */
.sheet-layer ~ .menu {
  z-index: 66;
}

/* 노트 정보(⋮ → 정보): 이름과 값 두 칸의 줄 */
.info-sheet {
  width: 440px;
}

.info-sheet .sheet-body {
  padding-top: 0;
}

.info-list {
  margin: 0;
}

.info-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  min-height: 48px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}

.info-row dt {
  font-size: 13px;
  color: var(--text-3);
}

.info-row dd {
  margin: 0;
  min-width: 0;
  font-size: 14.5px;
  color: var(--ink);
  font-feature-settings: 'tnum';
}

.info-nb {
  max-width: 100%;
  font-size: 14.5px;
}

.tag-box.info-tags {
  column-gap: 14px;
  row-gap: 8px;
}

/* 칩들이 태그 줄(flex)의 항목이 되게: 칩 사이·줄 사이 간격이 적용된다 */
.info-chips {
  display: contents;
}

.info-tags .chip {
  margin-right: 0;
  gap: 2px;
}

/* 시트 안의 태그 빼기는 늘 보이고 자리를 차지한다 */
.info-tags .chip-x {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  width: 22px;
  height: 22px;
  margin-left: 0;
  opacity: 1;
}

.info-tags .chip-x::after {
  content: '';
  position: absolute;
  inset: -11px -8px;
}

/* 손가락: 태그 빼기의 누르는 자리를 44x44로. 태그 글자를 덮지 않게 오른쪽 빈 곳으로 넓히고,
   그만큼 다음 태그와 띄우고, 여러 줄로 넘어가도 위아래 누르는 자리가 겹치지 않게 줄 사이를 둔다 */
@media (pointer: coarse) {
  .tag-box.info-tags {
    column-gap: 20px;
    row-gap: 24px;
  }

  .info-tags .chip-x {
    margin-left: 6px;
  }

  .info-tags .chip-x::after {
    inset: -11px -16px -11px -6px;
  }
}

.info-tag-input {
  border: 0;
  background: none;
  outline: none;
  flex: 1 1 80px;
  min-width: 80px;
  font-size: 14.5px;
  color: var(--ink);
  padding: 4px 0;
}

.info-tag-input::placeholder {
  color: var(--text-3);
}

.plan-now-label {
  font-size: 12px;
  color: var(--text-3);
}

.plan-now-name {
  font-size: 22px;
  font-weight: 750;
  margin-top: 2px;
}

.plan-now-sub {
  color: var(--text-2);
  margin-top: 2px;
}

.plan-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.plan-table th,
.plan-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: right;
  white-space: nowrap;
}

.plan-table th[scope='row'],
.plan-table thead th:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--text-2);
  white-space: normal;
}

.plan-table thead th {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
}

.plan-table .current {
  color: var(--ink);
  font-weight: 650;
}

.plan-table thead th.current {
  box-shadow: inset 0 -2px 0 var(--ink);
}

.buy {
  margin-top: 20px;
}

.products {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
}

.product:hover:not(:disabled) {
  background: var(--bg-hover);
}

.product-title,
.product-price {
  font-weight: 650;
}

.buy-actions {
  display: flex;
  gap: 4px;
  margin: 10px -9px 4px;
}

.fine {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-3);
}

.fine a,
.login-legal a {
  color: var(--text-2);
}

.buy-note {
  margin: 18px 0 0;
  color: var(--text-2);
}

.device-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.device {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.device-info {
  flex: 1;
  min-width: 0;
}

.device-name {
  font-weight: 650;
}

.device-sub {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 1px;
}

.badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-left: 4px;
}

.history-layer {
  padding-top: 6vh;
}

.history-sheet {
  width: 980px;
  height: 84vh;
  max-height: 84vh;
}

.history-back {
  visibility: hidden;
}

.history-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 220px 1fr;
}

.history-list {
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg-list);
  padding: 6px 6px 16px;
  border-bottom-left-radius: 12px;
}

.history-empty {
  padding: 18px 10px;
}

.history-day {
  padding: 14px 10px 5px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-3);
}

.history-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--text-2);
}

.history-item:hover {
  background: var(--bg-hover);
}

.history-item[aria-selected='true'] {
  background: var(--accent-tint);
  color: var(--ink);
}

.history-time {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.history-item-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--text-3);
}

.history-view {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.history-view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}

.history-when {
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.history-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 26px 32px 40px;
}

.history-title {
  max-width: var(--measure);
  margin: 0 auto 14px;
  font-size: 26px;
  font-weight: 720;
  line-height: 1.36;
}

.history-preview .prose {
  max-width: var(--measure);
  margin: 0 auto;
  min-height: 0;
}

/* ---------- 로그인 ---------- */

.login {
  position: fixed;
  inset: 0;
  z-index: 12;
  background: var(--bg-doc);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}

body.signed-out #app {
  visibility: hidden;
}

.login-box {
  width: 320px;
  max-width: 100%;
  text-align: center;
}

.login-mark {
  margin: 0 0 36px;
}

.login-mark .wordmark {
  height: 44px;
}

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 46px;
  border-radius: 10px;
  font-size: 15.5px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  color: var(--ink);
}

.login-btn.google:hover:not(:disabled),
.login-btn.github:hover:not(:disabled) {
  background: var(--bg-hover);
}

.login-btn.apple {
  background: #000000;
  border-color: #000000;
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .login-btn.apple {
    background: #ffffff;
    border-color: #ffffff;
    color: #000000;
  }
}

.apple-logo {
  font-size: 18px;
  margin-top: -3px;
}

.g-logo,
.gh-logo {
  width: 18px;
  height: 18px;
}

.login-note {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-3);
}

.login-legal {
  margin: 22px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
}

body.no-drag .note-item {
  -webkit-user-drag: none;
}

/* ---------- 손가락으로 노트를 노트북에 끌기 ---------- */

/* 길게 눌러 든 노트, 끌고 있는 동안 제자리에 남은 노트 */
.note-item.lifted {
  background: var(--bg-hover);
}

.note-item.drag-source {
  opacity: 0.35;
}

/* 손가락을 따라오는 노트 */
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 90;
  pointer-events: none;
  will-change: transform;
}

.drag-ghost .note-item {
  list-style: none;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(20, 20, 25, 0.08), 0 12px 32px rgba(20, 20, 25, 0.16);
  padding: 10px 14px 11px;
  transition: scale 0.14s ease;
}

.drag-ghost.up .note-item {
  scale: 1.03;
}

.drag-ghost .note-item::before {
  display: none;
}

/* 놓을 자리: 손가락에 가려도 보이게 먹색으로 채운다 */
body.touch-dragging .nav-item.drop,
.drop-row.drop {
  background: var(--solid);
  color: var(--on-solid);
  box-shadow: none;
}

body.touch-dragging .nav-item.drop .i,
body.touch-dragging .nav-item.drop .count,
.drop-row.drop .i {
  color: var(--on-solid);
}

body.touch-dragging .nav-item.drop .mono,
.drop-row.drop .mono {
  background: transparent;
  color: var(--on-solid);
  box-shadow: inset 0 0 0 1.25px var(--on-solid);
}

/* 사이드바가 없는 화면(휴대폰, 중간 폭)에서 끌기를 시작하면 뜨는 놓을 자리 판 */
.drop-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 85;
  display: flex;
  flex-direction: column;
  max-height: 58vh;
  background: var(--bg-raised);
  border-top: 1px solid var(--line-strong);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -8px 28px rgba(20, 20, 25, 0.12);
  padding: 6px calc(env(safe-area-inset-right) + 8px) calc(env(safe-area-inset-bottom) + 8px) calc(env(safe-area-inset-left) + 8px);
  transform: translateY(100%);
  transition: transform 0.18s ease;
}

.drop-panel.open {
  transform: none;
}

.drop-head {
  flex: none;
  padding: 10px 12px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
}

.drop-scroll {
  overflow-y: auto;
  min-height: 0;
}

.drop-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 16px;
  color: var(--ink);
}

.drop-row .mono {
  width: 22px;
  height: 22px;
  font-size: 13px;
  border-radius: 6px;
}

.drop-row > .i {
  width: 22px;
  height: 22px;
  color: var(--icon);
}

.drop-row .label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drop-row .tick {
  width: 18px;
  height: 18px;
  color: var(--text-2);
}

.drop-row.current .label {
  color: var(--text-2);
}

@media (min-width: 701px) {
  .drop-panel {
    left: 16px;
    right: auto;
    bottom: calc(env(safe-area-inset-bottom) + 16px);
    width: 300px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    box-shadow: var(--menu-shadow);
    padding-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .drop-panel,
  .drag-ghost .note-item {
    transition: none;
  }
}

/* 낮은 창: 사이드바 줄을 조금 좁혀 휴지통과 계정이 함께 보이게 */
@media (max-height: 700px) and (min-width: 701px) {
  .nav-item {
    height: 29px;
  }

  .nav-head {
    height: 34px;
    padding-top: 10px;
  }

  .search {
    margin-bottom: 10px;
  }

  .nav-gap {
    height: 4px;
  }
}

/* ---------- 중간 폭(701~959px): 목록과 편집 두 칸, 노트북 칸은 왼쪽에서 연다 ---------- */

@media (min-width: 701px) and (max-width: 959px) {
  #app {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  :root {
    --pad: 28px;
  }

  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 45;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.16s ease, visibility 0s linear 0.16s;
    box-shadow: var(--menu-shadow);
  }

  body.nav-open #sidebar {
    transform: none;
    visibility: visible;
    transition: transform 0.16s ease;
  }

  #open-nav {
    display: grid;
  }

  .list-head {
    padding-left: 18px;
  }
}

/* ---------- 태블릿(701px 이상, iPad 앱): 상태 표시줄·홈 표시 자리와 누르는 자리 ---------- */

/* 칸 바탕은 화면 끝까지 두고 안의 것만 안전 영역만큼 물린다. 안전 영역이 없는 화면(브라우저)에서는 0이라 그대로다. */
@media (min-width: 701px) {
  #sidebar {
    padding-top: calc(env(safe-area-inset-top) + 16px);
  }

  #list-pane,
  #editor-pane {
    padding-top: env(safe-area-inset-top);
  }

  .side-foot {
    padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
  }

  #note-list {
    padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
  }

  .toast,
  .task {
    bottom: calc(env(safe-area-inset-bottom) + 18px);
  }
}

/* 손가락으로 누르는 넓은 화면: 누르는 자리를 가로·세로 44px 이상으로(Apple HIG). 붙어 있는 단추 줄은 단추 자체를 44px로 넓혀
   이웃과 겹치지 않게 하고(서식 줄은 넘치면 「더 보기」로 접힌다), 떨어져 있는 단추는 모양은 두고 둘레만 넓힌다 */
@media (min-width: 701px) and (pointer: coarse) {
  .ebar .icon-btn,
  .fmt-bar .tb {
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }

  /* 둘레를 넓힐 단추의 기준(태그 빼기는 원래 겹쳐 띄운 것이라 그대로 둔다) */
  .list-head .icon-btn,
  .nav-head .icon-btn,
  .sheet-head .icon-btn,
  .meta-nb {
    position: relative;
  }

  .list-head .icon-btn::after,
  .nav-head .icon-btn::after,
  .sheet-head .icon-btn::after,
  .meta-nb::after,
  .chip-x::after {
    content: '';
    position: absolute;
  }

  .list-head .icon-btn::after,
  .sheet-head .icon-btn::after {
    inset: -6px;
  }

  /* 정렬과 새 노트 단추의 둘레가 겹치지 않게 */
  .list-head .icon-btn.solid {
    margin-left: 12px;
  }

  .nav-head .icon-btn::after {
    inset: -9px;
  }

  /* 노트북 고르기: 글자 높이(약 22px)에서 위아래로 */
  .meta-nb::after {
    inset: -12px -6px;
  }

  .nav-item {
    height: 44px;
  }

  .nav-item,
  .note-item {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .menu .mi,
  .ctx-menu .mi {
    height: 44px;
  }

}

/* ---------- 휴대폰 폭: 한 번에 한 칸 ---------- */

@media (max-width: 700px) {
  html,
  body {
    font-size: 15px;
  }

  /* 가로로 밀어 브라우저 기록을 넘기는 몸짓은 끈다(노트 화면의 밀어서 뒤로 가기는 왼쪽 가장자리에서만) */
  html {
    overscroll-behavior-x: none;
  }

  :root {
    --pad: 20px;
    --task-indent: 32px;
  }

  #app {
    display: block;
    position: relative;
  }

  #sidebar,
  #list-pane,
  #editor-pane {
    position: absolute;
    inset: 0;
    display: none;
    box-shadow: none;
  }

  body[data-pane='nav'] #sidebar,
  body[data-pane='list'] #list-pane,
  body[data-pane='editor'] #editor-pane,
  body:not([data-pane]) #list-pane {
    display: flex;
  }

  /* iOS가 입력란을 확대하지 않게 16px 이상 */
  input,
  select,
  textarea,
  #search,
  #modal-input {
    font-size: 16px;
  }

  .i {
    width: 22px;
    height: 22px;
    stroke-width: 1.636;
  }

  #sidebar {
    background: var(--bg-doc);
    padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 12px) 0 calc(env(safe-area-inset-left) + 12px);
    font-size: 16px;
  }

  .brand {
    height: 44px;
    margin-bottom: 4px;
  }

  .wordmark {
    height: 25px;
  }

  .nav-item {
    height: 46px;
    font-size: 16px;
    gap: 12px;
  }

  .nav-item .count {
    font-size: 14px;
  }

  .nav-item > .i {
    width: 22px;
    height: 22px;
  }

  .mono {
    width: 22px;
    height: 22px;
    font-size: 13px;
    border-radius: 6px;
  }

  .hash {
    width: 22px;
    font-size: 17px;
  }

  .nav-head {
    font-size: 13px;
    height: 48px;
  }

  .side-foot {
    padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
  }

  .nav-item,
  .note-item {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  #list-pane {
    flex-direction: column;
    background: var(--bg-doc);
  }

  .list-bar {
    display: flex;
    align-items: center;
    height: 44px;
    flex: none;
    margin-top: env(safe-area-inset-top);
    padding: 0 calc(env(safe-area-inset-right) + 6px) 0 calc(env(safe-area-inset-left) + 8px);
  }

  .back-btn {
    display: flex;
  }

  .list-bar .icon-btn,
  .ebar .icon-btn {
    width: 44px;
    height: 44px;
    color: var(--icon);
    border-radius: 10px;
  }

  .list-head {
    height: auto;
    align-items: baseline;
    padding: 2px calc(env(safe-area-inset-right) + 20px) 12px calc(env(safe-area-inset-left) + 20px);
    gap: 10px;
  }

  .list-head .icon-btn {
    display: none;
  }

  #view-title {
    font-size: 31px;
    font-weight: 600;
    line-height: 1.25;
  }

  .view-count {
    font-size: 15px;
    margin-left: 0;
  }

  #search-slot-list {
    padding: 0 calc(env(safe-area-inset-right) + 16px) 8px calc(env(safe-area-inset-left) + 16px);
  }

  .search {
    height: 38px;
    border-radius: 10px;
    background: var(--bg-hover);
    border-color: transparent;
    font-size: 16px;
  }

  .search .i {
    width: 18px;
    height: 18px;
    stroke-width: 2;
  }

  .trash-tools {
    padding: 0 calc(env(safe-area-inset-right) + 16px) 6px calc(env(safe-area-inset-left) + 10px);
  }

  #note-list {
    padding: 0 0 calc(env(safe-area-inset-bottom) + 104px);
  }

  .note-item {
    border-radius: 0;
    padding: 14px calc(env(safe-area-inset-right) + 20px) 15px calc(env(safe-area-inset-left) + 20px);
  }

  .note-item + .note-item::before {
    left: calc(env(safe-area-inset-left) + 20px);
    right: 0;
    height: 0.5px;
    background: var(--line-strong);
  }

  .note-item.selected {
    background: none;
  }

  /* 휴대폰 목록에는 연 노트가 없다(한 칸씩 보기) */
  .note-item.selected .item-title::before {
    content: none;
  }

  .note-item.selected::before,
  .note-item.selected + .note-item::before {
    display: block;
  }

  .note-item:hover {
    background: none;
  }

  .note-item:hover::before,
  .note-item:hover + .note-item::before {
    display: block;
  }

  .note-item:active {
    background: var(--bg-hover);
  }

  .item-title {
    font-size: 17px;
  }

  .item-pin .i {
    width: 16px;
    height: 16px;
    stroke-width: 2.25;
  }

  .item-snippet {
    font-size: 15px;
    line-height: 1.5;
  }

  .item-foot {
    justify-content: flex-start;
    gap: 14px;
    font-size: 13px;
  }

  .new-note-fab {
    display: grid;
    place-items: center;
    position: absolute;
    right: calc(env(safe-area-inset-right) + 20px);
    bottom: calc(env(safe-area-inset-bottom) + 28px);
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--solid);
    color: var(--on-solid);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 4px 14px rgba(0, 0, 0, 0.12);
  }

  .new-note-fab .i {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
  }

  #editor-pane {
    flex-direction: column;
  }

  /* 밀어서 뒤로 가기: 노트 화면이 손가락을 따라 밀려나고 밑에 목록이 어둠이 걷히며 따라 나온다 */
  body.swipe-back #list-pane {
    display: flex;
  }

  body.swipe-back #editor-pane {
    z-index: 2;
    box-shadow: -1px 0 0 var(--line), -10px 0 28px rgba(20, 20, 25, 0.12);
  }

  body.swipe-back #list-pane::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 5;
    background: var(--scrim);
    opacity: calc(1 - var(--swipe-p, 0));
    pointer-events: none;
  }

  body.swipe-settle #editor-pane,
  body.swipe-settle #list-pane {
    transition: transform 0.2s ease;
  }

  body.swipe-settle #list-pane::after {
    transition: opacity 0.2s ease;
  }

  .ebar {
    height: 44px;
    margin-top: env(safe-area-inset-top);
    padding: 0 calc(env(safe-area-inset-right) + 6px) 0 calc(env(safe-area-inset-left) + 8px);
  }

  #history-btn {
    display: none;
  }

  /* 휴대폰은 키보드 위 막대가 서식을 맡는다 */
  .fmt-bar {
    display: none;
  }

  .trash-actions .text-btn {
    font-size: 14px;
    padding: 8px 10px;
  }

  .editor-scroll {
    padding: 0 calc(env(safe-area-inset-right) + 20px) calc(env(safe-area-inset-bottom) + 120px + var(--kbar-space)) calc(env(safe-area-inset-left) + 20px);
  }

  .doc {
    padding-top: 2px;
  }

  #title {
    font-size: 25px;
    line-height: 1.3;
  }

  .doc-body-wrap {
    margin-top: 8px;
  }

  .prose {
    font-size: 17px;
    line-height: 1.68;
    min-height: 40vh;
  }

  .prose h1 {
    font-size: 23px;
  }

  .prose h2 {
    font-size: 20px;
    line-height: 1.43;
  }

  .prose ul[data-type='taskList'] li > label {
    height: 1.68em;
  }

  .prose ul[data-type='taskList'] input[type='checkbox'] {
    width: 19px;
    height: 19px;
  }

  .prose ul[data-type='taskList'] input[type='checkbox']:checked {
    background-size: 12px 12px;
  }

  .prose ul[data-type='taskList'] li.mk-task::before {
    line-height: 1.68;
  }

  .toast {
    bottom: calc(env(safe-area-inset-bottom) + 100px);
  }

  .task {
    left: 12px;
    right: 12px;
    max-width: none;
    bottom: calc(env(safe-area-inset-bottom) + 160px);
  }

  body.kbar-on .toast {
    bottom: calc(var(--kbar-space) + 12px);
  }

  .menu {
    font-size: 16px;
  }

  .menu .mi {
    height: 44px;
  }

  .menu .mi .i {
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
  }

  .modal {
    padding: 14vh 16px 16px;
  }

  .modal-box {
    width: 100%;
  }

  .sheet-layer {
    padding: 0;
  }

  .sheet {
    width: 100%;
    max-height: none;
    height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .sheet-head {
    padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 10px) 8px calc(env(safe-area-inset-left) + 10px);
  }

  .sheet-body {
    padding: 18px calc(env(safe-area-inset-right) + 18px) calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + 18px);
  }

  .menu-row {
    padding: 15px 4px;
    font-size: 16px;
  }

  .info-row {
    min-height: 54px;
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .info-row dt {
    font-size: 14px;
  }

  .info-row dd,
  .info-nb,
  .info-tag-input {
    font-size: 16px;
  }

  /* 좁은 폭의 요금제 표: 줄 이름은 한 줄로, 값은 필요하면 줄을 바꾼다 */
  .plan-table th[scope='row'] {
    white-space: nowrap;
  }

  .plan-table td {
    white-space: normal;
  }

  .history-sheet {
    height: 100%;
    max-height: none;
  }

  .history-body {
    grid-template-columns: 1fr;
  }

  .history-list {
    border-right: 0;
    background: var(--bg-doc);
  }

  .history-item {
    padding: 13px calc(env(safe-area-inset-left) + 12px);
    font-size: 16px;
  }

  .history-sheet[data-mode='list'] .history-view,
  .history-sheet[data-mode='view'] .history-list {
    display: none;
  }

  .history-sheet[data-mode='view'] .history-back {
    visibility: visible;
  }

  .history-view-head {
    padding: 10px calc(env(safe-area-inset-right) + 14px) 10px calc(env(safe-area-inset-left) + 18px);
  }

  .history-scroll {
    padding: 18px calc(env(safe-area-inset-right) + 18px) calc(env(safe-area-inset-bottom) + 40px) calc(env(safe-area-inset-left) + 18px);
  }

  .ctx-menu .mi {
    height: 44px;
  }
}
