:root {
  --bg: #faf6f0;
  --bg-card: #fffdf9;
  --text: #0a0a0a;
  --text-muted: #3a3a3a;
  --accent: #b8864a;
  --accent-hover: #9a6f38;
  --accent-soft: #e8d4b8;
  --border: #e8dfd0;
  --shadow: 0 2px 12px rgba(44, 36, 22, 0.06);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.03);
  --shadow-card-hover: 0 6px 28px rgba(0, 0, 0, 0.05);
  --input-border-focus: rgba(184, 134, 74, 0.32);
  --danger: #c45c4a;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 380px;
  --tab-active-bg: #e2d5c0;
  --tab-active-border: #c4b39a;
  --font-suite: "SUITE Variable", "SUITE", system-ui, -apple-system, sans-serif;
  --font-sans: var(--font-suite);
  --font-serif: var(--font-suite);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-suite);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 1rem env(safe-area-inset-bottom);
}

.header {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.header__brand-row {
  display: none;
}

.header__main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  flex-shrink: 0;
  padding-block: 0.2rem;
}

.header__end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex: 0 1 auto;
  min-width: 0;
}

.header__device-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--text-muted);
  background: rgba(255, 253, 249, 0.9);
  border: 1px solid rgba(232, 223, 208, 0.8);
  flex-shrink: 0;
}

.header__device-link:hover {
  color: var(--text);
  border-color: var(--accent-soft);
}

.header__device-link[hidden] {
  display: none !important;
}

.header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.header__badge {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 12rem;
  text-align: right;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header__badge--account {
  max-width: 6rem;
}

.header__row {
  display: none !important;
}

.header__brand {
  justify-self: start;
}

.header__tools {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  margin-top: 0;
  margin-left: 0;
  width: auto;
  flex-shrink: 0;
}

.section-actions {
  margin: 0 0 0.65rem;
}

.section-actions--media {
  margin-bottom: 0.45rem;
}

.section-actions__hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.header__brand:hover .header__logo {
  opacity: 0.88;
}

.header__brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.header__logo {
  display: block;
  width: auto;
  height: 2.15rem;
  max-width: 8.5rem;
  object-fit: contain;
  object-position: left center;
}

.header__icon {
  font-size: 1.5rem;
}

.header__title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
}

.header__status-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem 0.75rem;
  width: 100%;
  min-height: 1.35rem;
}

.header__status {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header__status-row .header__status {
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 42%;
}

.header__status-row .mobile-url-banner {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 0.15rem 0.45rem;
  font-size: 0.74rem;
  line-height: 1.3;
  flex-wrap: nowrap;
  overflow: hidden;
}

.header__status-row .mobile-url-banner__link {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header__status-row .header__tools {
  flex: 0 0 auto;
  width: auto;
  margin-left: auto;
}

.header__status.is-error {
  color: var(--danger);
}

.header__hint {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.header__hint code {
  font-size: 0.78rem;
}

.badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background: var(--border);
  border-radius: 999px;
  color: var(--text-muted);
}

.btn {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.btn:hover {
  border-color: var(--accent);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  color: var(--danger);
  border-color: #f0d0cc;
}

.btn--icon {
  min-width: 2.25rem;
  padding: 0.35rem 0.5rem;
  font-size: 1.25rem;
  line-height: 1;
}

.btn--block {
  width: 100%;
  margin-top: 0.5rem;
}

/* PC 2-column layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 1.25rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 0.5rem;
}

.sidebar__hint {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.calendar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: var(--shadow);
}

.calendar__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.calendar__nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.calendar__title {
  margin: 0;
  font-family: var(--font-suite);
  font-size: 1.05rem;
  font-weight: 600;
  min-width: 4.5rem;
  text-align: center;
  letter-spacing: -0.01em;
}

.btn--sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
}

/* 연간 달력 (12개월) */
.year-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem 0.5rem;
}

.mini-month {
  min-width: 0;
}

.mini-month__name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
  padding-left: 0.1rem;
}

.mini-month__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.mini-day {
  position: relative;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.58rem;
  line-height: 1.2;
  color: #6b6256;
  font-weight: 500;
  cursor: pointer;
  padding: 0.1rem 0;
  text-align: center;
  border-radius: 50%;
  aspect-ratio: 1;
  max-width: 1.35rem;
  margin: 0 auto;
}

.mini-day:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.mini-day--empty {
  pointer-events: none;
  visibility: hidden;
}

.mini-day--has {
  color: #1a140c;
  font-weight: 800;
  -webkit-font-smoothing: antialiased;
}

.mini-day--has:not(.mini-day--selected):not(.mini-day--today) {
  background: rgba(184, 134, 74, 0.18);
}

.mini-day--selected {
  background: var(--accent);
  color: #fff !important;
  font-weight: 700;
}

.mini-day--today {
  box-shadow: inset 0 0 0 1.5px #e74c3c;
  color: var(--text);
  font-weight: 700;
}

.mini-day--today.mini-day--has:not(.mini-day--selected) {
  background: rgba(184, 134, 74, 0.14);
}

.mini-day--sched {
  color: #2a5080;
  font-weight: 700;
}

.mini-day--sched:not(.mini-day--selected) {
  background: rgba(70, 120, 190, 0.2);
}

.mini-day--sched::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 5px;
  height: 3px;
  border-radius: 2px;
  background: #2f6db3;
  transform: translateX(-50%);
}

.mini-day--selected.mini-day--sched::after {
  background: #fff;
}

.mac-cal-panel {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f3f7fc;
}

.mac-cal-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.mac-cal-panel__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  color: #3d5a80;
}

.mac-cal-panel__count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mac-cal-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mac-cal-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.65rem;
  padding: 0.45rem 0;
  border-top: 1px solid rgba(61, 90, 128, 0.12);
}

.mac-cal-item:first-child {
  border-top: none;
  padding-top: 0;
}

.mac-cal-item__time {
  font-size: 0.78rem;
  font-weight: 600;
  color: #3d5a80;
  white-space: nowrap;
}

.mac-cal-item__title {
  font-size: 0.92rem;
  color: var(--text);
}

.mac-cal-item__cal,
.mac-cal-item__loc {
  grid-column: 2;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.mini-day--today.mini-day--selected {
  box-shadow: none;
}

.main {
  min-width: 0;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.search {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-family: inherit;
  font-size: 0.9rem;
}

.filter-label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.empty {
  display: none;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty.is-visible {
  display: block;
}

.empty__icon {
  font-size: 2.5rem;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding-bottom: 2rem;
}

.entry-card {
  background: var(--bg-card);
  border: none;
  border-radius: 12px;
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.entry-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}

.entry-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.entry-card__date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.entry-card__saved {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.entry-card__head-side {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.entry-card__date-col {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 0 0 auto;
  min-width: 6.1rem;
}

#section-investment .entry-card__saved {
  margin-left: 0;
  font-size: 0.68rem;
  line-height: 1.25;
}

.entry-card__title {
  margin: 0 0 0.35rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.entry-card__excerpt {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.entry-card__excerpt--search {
  color: var(--text);
}

.search-excerpt-para {
  margin: 0 0 0.75em;
}

.search-excerpt-para:last-child {
  margin-bottom: 0;
}

.search-hit {
  background: rgba(184, 134, 74, 0.3);
  color: var(--text);
  font-weight: 600;
  padding: 0.05em 0.15em;
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.entry-card__thumb {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.entry-card__thumb img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  background: #f3ebe0;
  border-radius: 4px;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-right: 0.25rem;
}

.signal-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.signal-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.38rem 0.8rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.signal-btn:hover {
  border-color: rgba(184, 134, 74, 0.45);
  color: var(--text);
}

.signal-btn.is-selected {
  background: rgba(184, 134, 74, 0.14);
  border-color: var(--accent);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(184, 134, 74, 0.18);
}

.tag--signal {
  font-weight: 700;
}

.tag--signal-good {
  background: #e8f6ea;
  color: #2f7a42;
}

.tag--signal-hold {
  background: #f4f0e6;
  color: #8a6a1f;
}

.tag--signal-bad {
  background: #fae8e8;
  color: #a04b4b;
}

/* Editor */
.screen-editor {
  display: block;
  min-height: calc(100dvh - 2rem);
}

.screen-editor[hidden] {
  display: none !important;
}

.editor-sticky-chrome {
  display: flex;
  align-items: center;
  gap: 0.35rem 0.5rem;
  flex-wrap: nowrap;
  min-height: 2.35rem;
  padding: 0.2rem 0;
  margin: 0 0 0.45rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 220;
}

.editor-sticky-chrome__nav {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem 0.4rem;
  flex: 0 1 auto;
  min-width: 0;
}

.editor-sticky-chrome__status {
  margin: 0;
  max-width: 10.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex: 0 1 auto;
}

.editor-sticky-chrome__nav h2 {
  margin: 0;
  flex: 0 1 auto;
  font-family: var(--font-suite);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.editor-sticky-chrome__tools {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.editor-sticky-chrome__tools .body-editor__toolbar,
.editor-sticky-chrome__tools .editor-memo-chrome__row--tools {
  margin: 0;
  padding: 0;
  border: none;
  flex-wrap: nowrap;
  gap: 0.2rem 0.3rem;
  min-height: 0;
}

.editor-sticky-chrome__actions {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex: 0 0 auto;
  margin-left: auto;
}

.editor-sticky-chrome .editor-header__memo-label {
  flex: 0 0 auto;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.editor-sticky-chrome .font-select-wrap--size .input--font-size,
.editor-sticky-chrome .input--font-size {
  width: 2.7rem !important;
  min-width: 2.7rem !important;
  max-width: 2.7rem !important;
  padding-left: 0.15rem !important;
  padding-right: 0.1rem !important;
}

.editor-sticky-chrome .input--font {
  width: 5.4rem !important;
  min-width: 5rem !important;
  max-width: 5.8rem !important;
}

.editor-sticky-chrome .btn--compact {
  min-width: 1.5rem;
  padding: 0.15rem 0.35rem;
}

.editor__header {
  display: none;
}

.editor__header h2 {
  margin: 0;
  flex: 0 1 auto;
  font-family: var(--font-serif);
  font-size: 1.1rem;
}

.editor-header__memo-label {
  flex: 0 1 auto;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.editor__header .editor-memo-chrome__actions {
  margin-left: auto;
}

#editor-heading,
#inv-editor-heading,
#reading-editor-heading {
  font-family: var(--font-suite);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.editor__actions {
  display: flex;
  gap: 0.35rem;
}

.editor__footer {
  display: none;
}

.editor-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  padding-bottom: 2rem;
}

/* 일기 본문: 작성 영역 왼쪽 · 날짜/제목/달력 오른쪽 · 중간 핸들로 폭 조절 */
#screen-editor .editor-layout {
  display: flex;
  gap: 0;
  align-items: stretch;
  grid-template-columns: none;
}

#screen-editor .editor-main {
  flex: 1 1 auto;
  min-width: 140px;
}

#screen-editor .editor-side {
  flex: 0 0 320px;
  width: 320px;
  min-width: 200px;
  max-width: none;
  padding-left: 0.85rem;
  box-sizing: border-box;
}

.editor-layout__resize {
  flex: 0 0 8px;
  align-self: stretch;
  cursor: ew-resize;
  position: relative;
  z-index: 5;
  touch-action: none;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  transition: background 0.15s;
}

.editor-layout__resize::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: var(--border);
  transition: background 0.15s, width 0.15s;
}

.editor-layout__resize::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 42px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.15s;
}

.editor-layout__resize:hover,
.editor-layout__resize.is-dragging,
body.is-editor-layout-resizing .editor-layout__resize {
  background: rgba(184, 134, 74, 0.12);
}

.editor-layout__resize:hover::before,
.editor-layout__resize.is-dragging::before,
body.is-editor-layout-resizing .editor-layout__resize::before {
  width: 2px;
  background: var(--accent);
}

.editor-layout__resize:hover::after,
.editor-layout__resize.is-dragging::after,
body.is-editor-layout-resizing .editor-layout__resize::after {
  background: var(--accent);
}

.editor-layout__resize.is-snap-default::after,
.editor-layout__resize.is-snap-reels::after {
  background: var(--accent);
  height: 52px;
}

.editor-layout__resize.is-snap-reels::before {
  background: var(--accent);
  width: 2px;
}

body.is-editor-layout-resizing {
  cursor: ew-resize;
  user-select: none;
}

body.is-editor-layout-resizing iframe {
  pointer-events: none;
}

/* 투자 본문: 일기와 동일하게 왼쪽 본문 · 오른쪽 메타 · 세로 핸들 */
#inv-screen-editor .editor-layout {
  display: flex;
  gap: 0;
  align-items: stretch;
  grid-template-columns: none;
}

#inv-screen-editor .editor-main {
  flex: 1 1 auto;
  min-width: 140px;
}

#inv-screen-editor .editor-side {
  flex: 0 0 320px;
  width: 320px;
  min-width: 200px;
  max-width: none;
  padding-left: 0.85rem;
  box-sizing: border-box;
}

/* display:none 이면 macOS Chrome 파일 선택창이 빈 채로 닫히는 경우가 있음 */
.file-input-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* 사진 버튼: file input을 버튼 위에 겹쳐 직접 클릭 (label+hidden 방식보다 안정적) */
.photo-add-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  vertical-align: middle;
}

.photo-add-wrap .photo-add {
  pointer-events: auto;
}

.photo-add-wrap .photo-add-file {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: 0;
}

.editor-side {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.editor-main {
  min-width: 0;
}

.editor-side-calendar {
  margin-top: 0.25rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.editor-side-calendar__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.calendar__weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  margin-bottom: 0.2rem;
  font-size: 0.72rem;
  text-align: center;
  color: var(--text-muted);
}

.calendar__weekdays span:first-child {
  color: #c45c4a;
}

.calendar__weekdays span:last-child {
  color: #5b7ec4;
}

.calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.editor-side-calendar .calendar__grid {
  gap: 2px;
}

.cal-day {
  border: none;
  background: transparent;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
  padding: 0.15rem 0;
  text-align: center;
  position: relative;
}

.cal-day:hover {
  background: var(--accent-soft);
}

.cal-day--empty {
  visibility: hidden;
  pointer-events: none;
}

.cal-day--has::after {
  content: "";
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.cal-day--selected {
  background: var(--accent);
  color: #fff;
}

.cal-day--selected.cal-day--has::after {
  background: #fff;
}

.cal-day--today {
  box-shadow: inset 0 0 0 1px #e74c3c;
}

.editor-side-calendar .cal-day {
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  min-height: 2rem;
}

.font-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
  white-space: nowrap;
  max-width: none;
}

.font-select-wrap .field__hint {
  display: none; /* 툴바에서 '폰트/크기' 라벨이 셀렉트에 끼어 보이던 문제 제거 */
}

.font-select-wrap--size .input--font-size,
.font-select-wrap .input--font-size {
  min-width: 3.6rem !important;
  max-width: 4.2rem !important;
  width: 4rem !important;
  flex: 0 0 auto !important;
}

.font-select-wrap .input--font,
.font-select-wrap .field__input--font {
  min-width: 6rem !important;
  max-width: 8.5rem !important;
  width: 7.5rem !important;
  flex: 0 0 auto !important;
}

.editor-memo-chrome__row--tools .input--compact:not([hidden]):not(.input--font):not(.input--font-size) {
  min-width: 7rem;
  max-width: 11rem;
}

.editor-memo-chrome__row--tools .input--font-size {
  min-width: 3.6rem !important;
  max-width: 4.2rem !important;
}

/* 데스크톱에서는 전체화면 버튼 숨김 — 폰트 선택과 겹침 방지 */
@media (hover: hover) and (pointer: fine) {
  .btn--fullscreen-mobile {
    display: none !important;
  }
}

#inv-btn-body-fullscreen {
  margin-left: 0.25rem;
  flex-shrink: 0;
}

#editor-font-search {
  max-width: 240px;
}

.input--compact {
  min-width: 120px;
  padding: 0.35rem 0.45rem;
  font-size: 0.86rem;
}

.input--font,
.field__input--font {
  min-width: 0;
  width: auto;
  max-width: 7.25rem;
  flex: 0 0 auto;
  padding-right: 1.4rem;
}

#btn-font-favorite,
#inv-btn-font-favorite,
#reading-btn-font-favorite,
#entry-summary-font-favorite,
#btn-font-add,
#inv-btn-font-add,
#reading-btn-font-add,
#entry-summary-font-add {
  white-space: nowrap;
  writing-mode: horizontal-tb;
  flex-shrink: 0;
}

input.input--compact[hidden],
input.field__input--compact[hidden] {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field__label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field__hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.optional {
  font-weight: 400;
  opacity: 0.85;
}

.input,
.textarea {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  width: 100%;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

/* 에디터 주요 입력 — 은은한 테두리·배경으로 작성 영역 구분 */
.editor-side .input,
.editor-main .textarea,
.editor-main .rich-editor {
  border: 1px solid rgba(210, 198, 178, 0.72);
  background: rgba(255, 253, 249, 0.88);
  box-shadow: inset 0 1px 2px rgba(44, 36, 22, 0.03);
}

.editor-side .input:hover,
.editor-main .textarea:hover,
.editor-main .rich-editor:hover {
  border-color: rgba(200, 186, 162, 0.9);
  background: var(--bg-card);
}

.editor-side .input:focus,
.editor-main .textarea:focus,
.editor-main .rich-editor:focus {
  outline: none;
  border-color: var(--input-border-focus);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(184, 134, 74, 0.09);
}

#editor-title {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  padding: 0.55rem 0.75rem;
  letter-spacing: 0;
  resize: none;
  overflow-y: auto;
  min-height: 2.75rem;
  max-height: 5rem;
  field-sizing: content;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

#editor-title[data-font="serif"] {
  font-family: var(--font-serif);
}

#editor-title[data-font="sans"] {
  font-family: var(--font-sans);
}

#editor-title[data-font="mono"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

#editor-title[data-font="hand"] {
  font-family: "Gaegu", var(--font-sans);
}

.editor-main .body-editor {
  border: 1px solid rgba(210, 198, 178, 0.72);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 249, 0.88);
  box-shadow: inset 0 1px 2px rgba(44, 36, 22, 0.03);
  padding: 0.55rem 0.65rem 0.65rem;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.editor-compose {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
  max-height: calc(100dvh - 9.25rem);
}

.field--grow.editor-compose {
  flex: 1 1 auto;
  min-height: 0;
}

.editor-compose:has(.body-editor--translate-open) {
  overflow: hidden;
}

.editor-compose:has(.body-editor--translate-open) .body-editor--resizable {
  flex: 1 1 0;
  min-height: 14rem;
}

.editor-memo-chrome {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 0.2rem 0 0.35rem;
  background: var(--bg);
  border-bottom: 1px solid rgba(232, 223, 208, 0.75);
}

.editor-memo-chrome__row--title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}

.editor-memo-chrome__row--title .field__label {
  margin: 0;
}

.editor-memo-chrome__actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.editor-memo-chrome .reading-editor-status {
  margin: 0;
}

.editor-memo-chrome .body-editor__toolbar {
  margin: 0;
  padding: 0.15rem 0 0;
  border-bottom: none;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  align-items: center;
}

.editor-memo-chrome__row--tools {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem 0.45rem;
}

.editor-memo-chrome__row--tools > * {
  flex-shrink: 0;
}

.editor-memo-chrome__row--tools .btn {
  white-space: nowrap;
}

/* 일기: 본문 폭이 좁아져도 번역 툴이 보이도록 줄바꿈 · 두 줄 높이는 Compact */
#screen-editor .editor-memo-chrome {
  padding: 0.08rem 0 0.2rem;
}

#screen-editor .editor-memo-chrome .body-editor__toolbar,
#screen-editor .editor-memo-chrome__row--tools {
  flex-wrap: wrap;
  overflow-x: visible;
  align-items: center;
  row-gap: 0.15rem;
  column-gap: 0.3rem;
  padding-top: 0.05rem;
}

#screen-editor .editor-memo-chrome__row--tools .btn--sm {
  padding: 0.22rem 0.42rem;
  font-size: 0.78rem;
  line-height: 1.15;
  min-height: 1.7rem;
}

#screen-editor .editor-memo-chrome__row--tools .btn--icon-only {
  padding: 0.22rem;
  min-height: 1.7rem;
  min-width: 1.7rem;
}

#screen-editor .editor-memo-chrome__row--tools .btn--icon-only svg {
  width: 1rem;
  height: 1rem;
}

#screen-editor .editor-memo-chrome__row--tools .align-toolbar {
  padding: 0.05rem;
  gap: 0.05rem;
}

#screen-editor .editor-memo-chrome__row--tools .font-select-wrap .input--font {
  min-width: 5.4rem !important;
  max-width: 7rem !important;
  width: 6.4rem !important;
  min-height: 1.7rem;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  font-size: 0.8rem;
}

#screen-editor .editor-memo-chrome__row--tools .font-select-wrap .input--font-size {
  min-width: 3.2rem !important;
  max-width: 3.8rem !important;
  width: 3.5rem !important;
  min-height: 1.7rem;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  font-size: 0.8rem;
}

#screen-editor .editor-memo-chrome__row--tools .translate-mode {
  gap: 0.12rem;
  flex: 1 1 auto;
  justify-content: flex-start;
  min-width: min(100%, 11rem);
}

#screen-editor .editor-memo-chrome__row--tools .translate-mode .btn {
  padding: 0.22rem 0.4rem;
  font-size: 0.78rem;
  min-height: 1.7rem;
}

.body-editor--scroll {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.body-editor--resizable {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0.15rem;
}

.body-editor--resizable > .body-editor__scroll {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.body-editor--scroll .rich-editor,
.body-editor--scroll .textarea--xl {
  flex: 1 1 auto;
  min-height: 42vh;
  max-height: none;
  overflow-y: auto;
}

.body-editor--resizable.body-editor--scroll .body-editor__scroll .rich-editor,
.body-editor--resizable.body-editor--scroll .body-editor__scroll .textarea--xl,
.body-editor--resizable.body-editor--scroll > .rich-editor,
.body-editor--resizable.body-editor--scroll > .textarea--xl {
  flex: 1 1 auto;
  min-height: 4.5rem;
  max-height: none;
  overflow-y: auto;
}

.body-editor--resizable.body-editor--translate-open,
.body-editor--resizable:has(.translate-panel:not([hidden])) {
  flex: 1 1 0;
  min-height: 0;
}

.body-editor--resizable.body-editor--translate-open > .body-editor__scroll,
.body-editor--resizable:has(.translate-panel:not([hidden])) > .body-editor__scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.body-editor--resizable.body-editor--translate-open .body-editor__scroll .rich-editor,
.body-editor--resizable:has(.translate-panel:not([hidden])) .body-editor__scroll .rich-editor {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.body-editor--resizable.body-editor--translate-open .body-editor__scroll .translate-panel,
.body-editor--resizable:has(.translate-panel:not([hidden])) .body-editor__scroll .translate-panel {
  flex: 0 0 auto;
  flex-shrink: 0;
  min-height: 10.5rem;
  height: clamp(10.5rem, 30vh, 240px);
  max-height: clamp(10.5rem, 30vh, 240px);
  overflow: hidden;
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  padding: 0.2rem 0.4rem 0.25rem;
}

.body-editor--resizable.body-editor--translate-open .translate-panel__body,
.body-editor--resizable:has(.translate-panel:not([hidden])) .translate-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
}

.body-editor--resizable.body-editor--translate-open .translate-panel__head,
.body-editor--resizable:has(.translate-panel:not([hidden])) .translate-panel__head {
  flex: 0 0 auto;
  margin-bottom: 0;
  padding-bottom: 0.08rem;
  border-bottom: 1px solid rgba(232, 223, 208, 0.65);
  background: rgba(255, 253, 249, 0.98);
  position: sticky;
  top: 0;
  z-index: 2;
}

.body-editor--resizable.body-editor--translate-open .translate-panel__out,
.body-editor--resizable:has(.translate-panel:not([hidden])) .translate-panel__out {
  min-height: 0;
  padding: 0 0.32rem 0.08rem;
}

.body-editor--resizable.body-editor--translate-open .translate-panel__text,
.body-editor--resizable:has(.translate-panel:not([hidden])) .translate-panel__text {
  margin: 0;
  padding: 0;
  line-height: 1.3;
}

.body-editor--resizable.body-editor--translate-open .translate-panel__pinyin,
.body-editor--resizable:has(.translate-panel:not([hidden])) .translate-panel__pinyin {
  margin: 0;
  padding: 0;
  line-height: 1.3;
}

.body-editor--resizable.body-editor--translate-open .translate-panel__hint,
.body-editor--resizable:has(.translate-panel:not([hidden])) .translate-panel__hint {
  display: none;
}

.body-editor--resizable .body-editor__resize {
  flex: 0 0 18px;
  height: 18px;
  margin-top: 0;
  cursor: ns-resize;
  touch-action: none;
  position: relative;
  z-index: 6;
  flex-shrink: 0;
  background: linear-gradient(to bottom, transparent, rgba(184, 134, 74, 0.06));
}

.body-editor--resizable .body-editor__resize::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 4px;
  left: auto;
  top: auto;
  width: 12px;
  height: 12px;
  margin: 0;
  border-radius: 2px;
  background:
    linear-gradient(135deg, transparent 42%, var(--border) 42%, var(--border) 48%, transparent 48%),
    linear-gradient(135deg, transparent 58%, var(--border) 58%, var(--border) 64%, transparent 64%);
}

.body-editor--resizable .body-editor__resize::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 7px;
  width: 36px;
  height: 3px;
  margin-left: -18px;
  border-radius: 999px;
  background: var(--border);
}

.body-editor--resizable .body-editor__resize:hover::after,
.body-editor--resizable .body-editor__resize:focus-visible::after {
  background:
    linear-gradient(135deg, transparent 42%, var(--accent) 42%, var(--accent) 48%, transparent 48%),
    linear-gradient(135deg, transparent 58%, var(--accent) 58%, var(--accent) 64%, transparent 64%);
}

.body-editor--resizable .body-editor__resize:hover::before,
.body-editor--resizable .body-editor__resize:focus-visible::before {
  background: var(--accent);
}

body.is-body-editor-resizing {
  cursor: ns-resize;
  user-select: none;
}

body.is-body-editor-resizing iframe {
  pointer-events: none;
}

.editor-main .body-editor:focus-within {
  border-color: var(--input-border-focus);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(184, 134, 74, 0.09);
}

.editor-main .textarea,
.editor-main .rich-editor {
  padding: 0.55rem 0.35rem 1.5rem;
  border: none;
  background: transparent;
  box-shadow: none;
}

.editor-main .textarea:hover,
.editor-main .rich-editor:hover,
.editor-main .textarea:focus,
.editor-main .rich-editor:focus {
  border: none;
  background: transparent;
  box-shadow: none;
}

.textarea {
  min-height: 200px;
  resize: vertical;
  line-height: 1.65;
  font-family: var(--font-serif);
}

.textarea--xl {
  min-height: 68vh;
  font-size: 1.08rem;
  line-height: 1.75;
}

.rich-editor.textarea--xl {
  line-height: 1.5;
}

.rich-editor {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-height: 68vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: 2em;
  padding-bottom: 1.5em;
}

.rich-editor p {
  margin: 0 0 0.35em;
}

.rich-editor p:last-child {
  margin-bottom: 0.65em;
}

.rich-editor p:empty {
  margin: 0 0 0.15em;
  min-height: 1.35em;
}

.rich-editor p[data-rich-blank="1"] {
  min-height: 1.5em;
}

/* br만 있는 빈 줄도 한 줄 높이 확보 */
.rich-editor p:has(> br:only-child) {
  min-height: 1.5em;
}

.rich-editor ul,
.rich-editor ol {
  margin: 0.25em 0 0.35em;
  padding-left: 1.45em;
}

.rich-editor blockquote {
  margin: 0.35em 0 0.35em;
  padding-left: 0.85em;
  border-left: 3px solid var(--border);
  color: #6b6256;
}

.rich-editor strong,
.rich-editor b {
  font-weight: 700;
}

.rich-editor em,
.rich-editor i {
  font-style: italic;
}

.rich-editor .reading-hl,
.rich-editor mark.reading-hl {
  color: inherit;
  border-radius: 3px;
  padding: 0.05em 0;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.rich-editor .reading-hl[data-hl="yellow"],
.rich-editor mark.reading-hl:not([data-hl]),
.rich-editor mark.reading-hl[data-hl="yellow"] {
  background: rgba(228, 180, 42, 0.52);
  box-shadow: inset 0 -1px 0 rgba(170, 120, 20, 0.2);
}

.rich-editor .reading-hl[data-hl="green"] {
  background: rgba(112, 186, 112, 0.42);
}

.rich-editor .reading-hl[data-hl="cyan"] {
  background: rgba(90, 190, 200, 0.4);
}

.rich-editor .reading-hl[data-hl="pink"] {
  background: rgba(230, 140, 175, 0.42);
}

.rich-editor .reading-hl[data-hl="blue"] {
  background: rgba(120, 165, 230, 0.4);
}

.rich-editor .reading-hl[data-hl="purple"] {
  background: rgba(175, 140, 220, 0.42);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #9b8f7f;
}

.rich-editor .inline-photo {
  position: relative;
  display: block;
  margin: 0.35rem 0;
  max-width: 100%;
  outline: none;
}

.rich-editor .inline-photo.is-photo-caret-after::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  bottom: 0.15rem;
  right: -3px;
  width: 2px;
  border-radius: 1px;
  background: #2f6fed;
  pointer-events: none;
  z-index: 2;
}

.rich-editor .inline-photo-row .inline-photo.is-photo-caret-after::after {
  right: -4px;
}

.rich-editor .inline-photo + .inline-photo,
.rich-editor .inline-photo-row + .inline-photo,
.rich-editor .inline-photo + .inline-photo-row {
  margin-top: 0.08rem;
}

.rich-editor .inline-photo:has(+ .inline-photo),
.rich-editor .inline-photo:has(+ .inline-photo-row),
.rich-editor .inline-photo-row:has(+ .inline-photo) {
  margin-bottom: 0.08rem;
}

.rich-editor .inline-photo + .inline-photo .inline-photo__gap--before,
.rich-editor .inline-photo:has(+ .inline-photo) .inline-photo__gap--after,
.rich-editor .inline-photo-row + .inline-photo .inline-photo__gap--before,
.rich-editor .inline-photo:has(+ .inline-photo-row) .inline-photo__gap--after {
  height: 0;
  margin: 0;
  min-height: 0;
  overflow: hidden;
  pointer-events: none;
}

.rich-editor .inline-photo + p:empty + .inline-photo {
  margin-top: 0.08rem;
}

.rich-editor p:empty:has(+ .inline-photo),
.rich-editor .inline-photo + p:empty {
  margin: 0;
  min-height: 0;
  line-height: 0;
}

.rich-editor .inline-photo-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.35rem 0;
  max-width: 100%;
  width: 100%;
  justify-content: flex-start;
  box-sizing: border-box;
}

.rich-editor .inline-photo-row[data-align="center"] {
  justify-content: center;
}

.rich-editor .inline-photo-row[data-align="right"] {
  justify-content: flex-end;
}

/* min-width:auto(이미지 원본폭) 때문에 세로로 밀려 보이던 문제 차단 */
.rich-editor .inline-photo-row .inline-photo {
  display: block !important;
  margin: 0 !important;
  flex: 1 1 0 !important;
  min-width: 0 !important;
  max-width: calc(50% - 0.25rem) !important;
  width: auto !important;
  box-sizing: border-box;
}

.rich-editor .inline-photo-row .inline-photo[data-width-pct] {
  max-width: calc(50% - 0.25rem) !important;
  width: auto !important;
}

.rich-editor .inline-photo-row .inline-photo__frame,
.rich-editor .inline-photo-row .inline-photo__frame img,
.rich-editor .inline-photo-row .inline-photo > img {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
}

.rich-editor .inline-photo-row .inline-photo__gap {
  display: none !important;
}

.rich-editor .inline-photo__gap {
  height: 6px;
  cursor: text;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.rich-editor .inline-photo__gap--before {
  margin-bottom: 0.08rem;
}

.rich-editor .inline-photo__gap--after {
  margin-top: 0.08rem;
}

.rich-editor .inline-photo:hover .inline-photo__gap,
.rich-editor .inline-photo.is-selected .inline-photo__gap {
  background: rgba(184, 134, 74, 0.12);
}

.rich-editor .inline-photo__gap:hover {
  background: rgba(184, 134, 74, 0.22);
}

.rich-editor .inline-photo[data-align="center"] {
  margin-left: auto;
  margin-right: auto;
}

.rich-editor .inline-photo[data-align="right"] {
  margin-left: auto;
  margin-right: 0;
}

.rich-editor .inline-photo.is-broken .inline-photo__frame::after {
  content: "사진 없음";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(255, 253, 249, 0.72);
  pointer-events: none;
}

.rich-editor .inline-photo.is-broken .inline-photo__frame img.inline-photo__img--broken {
  opacity: 0.2;
}

.photo-item img.inline-photo__img--broken {
  opacity: 0.25;
}

.rich-editor .inline-photo.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 10px;
}

.rich-editor .inline-photo.is-dragging {
  opacity: 0.45;
}

.rich-editor .inline-photo__frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  cursor: grab;
  touch-action: none;
}

.rich-editor .inline-photo.is-dragging .inline-photo__frame {
  cursor: grabbing;
}

.rich-editor .inline-photo__frame img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  pointer-events: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.rich-editor .inline-photo > img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  pointer-events: none;
  user-select: none;
}

.rich-editor .inline-photo[data-size="sm"]:not([data-width-pct]) {
  width: 33%;
}

.rich-editor .inline-photo[data-size="md"]:not([data-width-pct]) {
  width: 66%;
}

.rich-editor .inline-photo[data-size="full"]:not([data-width-pct]),
.rich-editor .inline-photo:not([data-size]):not([data-width-pct]) {
  width: 100%;
}

.rich-editor .inline-photo__resize {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
  cursor: nwse-resize;
  z-index: 4;
  touch-action: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.rich-editor .inline-photo.is-selected .inline-photo__resize {
  opacity: 1;
  pointer-events: auto;
}

.rich-editor .inline-photo__resize::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-right: 2px solid rgba(255, 255, 255, 0.9);
  border-bottom: 2px solid rgba(255, 255, 255, 0.9);
}

/* 터치 기기: 사진 위 스와이프는 본문 스크롤, 위치 이동 드래그는 비활성 */
@media (pointer: coarse) {
  .body-editor__scroll,
  .body-editor--scroll .rich-editor,
  .body-editor--resizable.body-editor--scroll .body-editor__scroll .rich-editor,
  .editor-main .rich-editor,
  #section-investment .rich-editor,
  #reading-body-rich {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .rich-editor .inline-photo__frame {
    touch-action: pan-y;
    cursor: default;
  }

  .rich-editor .inline-photo__frame img {
    pointer-events: none;
  }

  .rich-editor .inline-photo__resize {
    touch-action: none;
    pointer-events: auto;
  }

  body.markup-drawing-active #section-investment .rich-editor,
  body.markup-drawing-active #section-investment .inline-photo.is-markup-active .inline-photo__frame {
    touch-action: none;
  }
}

.photo-drop-line {
  position: fixed;
  z-index: 1000;
  display: none;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(184, 134, 74, 0.35);
  pointer-events: none;
}

.photo-drop-line--vertical {
  width: 4px;
  min-height: 3rem;
  height: auto;
}

body.is-photo-dragging {
  user-select: none;
  cursor: grabbing;
}

.photo-context-menu {
  position: fixed;
  z-index: 2000;
  min-width: 9.5rem;
  padding: 0.3rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
}

.photo-context-menu__item {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.45rem 0.85rem;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
}

.photo-context-menu__item:hover:not(:disabled) {
  background: var(--accent-soft);
}

.photo-context-menu__item:disabled {
  opacity: 0.4;
  cursor: default;
}

.photo-context-menu__item--danger {
  color: var(--danger);
  border-top: 1px solid var(--border);
  margin-top: 0.2rem;
}

.image-cropper {
  position: fixed;
  inset: 0;
  z-index: 3200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(28, 24, 20, 0.55);
}

.image-cropper__panel {
  width: min(92vw, 720px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem 0.95rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
}

.image-cropper__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.image-cropper__hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.image-cropper__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  max-height: 68vh;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #1c1814;
  touch-action: none;
  user-select: none;
}

.image-cropper__img {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  pointer-events: none;
}

.image-cropper__box {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  cursor: move;
  touch-action: none;
}

.image-cropper__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.align-toolbar .is-dimmed {
  opacity: 0.45;
}

.translate-mode {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  align-items: center;
}

.translate-mode .btn.is-active {
  background: rgba(184, 134, 74, 0.18);
  color: var(--text);
}

.translate-panel {
  margin-top: 0.35rem;
  padding: 0.2rem 0.4rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 249, 0.92);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  max-height: min(42vh, 320px);
}

.translate-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.45rem;
  margin-bottom: 0;
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255, 253, 249, 0.98);
  padding-bottom: 0.08rem;
  border-bottom: 1px solid rgba(232, 223, 208, 0.55);
}

.translate-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
}

.translate-panel__status {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex: 1 1 auto;
}

.translate-panel__status.is-error {
  color: var(--danger);
}

.translate-panel__actions {
  display: inline-flex;
  gap: 0.3rem;
  margin-left: auto;
}

.translate-panel__out {
  min-height: 0;
  padding: 0 0.32rem 0.08rem;
  border-radius: calc(var(--radius-sm) - 2px);
  background: rgba(28, 24, 20, 0.04);
  word-break: break-word;
}

.translate-panel__pinyin {
  margin: 0;
  padding: 0;
  color: #3b6ea5;
  font-size: var(--translate-font-size, 16px);
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.translate-panel__text {
  margin: 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: var(--translate-font-size, 16px);
  line-height: 1.3;
}

.translate-panel__actions .btn.is-active {
  background: rgba(59, 110, 165, 0.14);
  color: #2a4f78;
}

.translate-panel__gloss {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.translate-gloss__head {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.translate-gloss__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 1rem;
}

@media (max-width: 720px) {
  .translate-gloss__grid {
    grid-template-columns: 1fr;
  }
}

.translate-gloss__title {
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.translate-gloss__item {
  margin-bottom: 0.45rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(28, 24, 20, 0.06);
}

.translate-gloss__item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.translate-gloss__word {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
}

.translate-gloss__py {
  margin-left: 0.25rem;
  font-weight: 500;
  font-size: 0.82rem;
  color: #3b6ea5;
}

.translate-gloss__mean {
  margin-top: 0.12rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  white-space: pre-wrap;
}

.translate-gloss__note {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.translate-panel__hint {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

body.is-photo-dragging .rich-editor {
  scroll-behavior: auto;
}

.body-preview__content .inline-photo[data-size="sm"]:not([data-width-pct]) {
  width: 33%;
  display: inline-block;
}

.body-preview__content .inline-photo[data-size="md"]:not([data-width-pct]) {
  width: 66%;
  display: inline-block;
}

.body-preview__content .inline-photo img {
  width: 100%;
  max-width: 100%;
  height: auto;
}

.inline-link-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  max-width: 100%;
  min-height: 84px;
  padding: 0.28rem 0.5rem;
  margin: 0.3rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfaf6;
  text-decoration: none;
  color: inherit;
  vertical-align: middle;
  box-sizing: border-box;
}

.inline-link-card img {
  width: 150px;
  height: 84px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.inline-link-card__meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.28rem;
  flex: 1 1 auto;
  min-width: 0;
}

.inline-link-card__sub {
  display: flex;
  align-items: baseline;
  min-width: 0;
}

.inline-link-card__title {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(0.92rem * 1.3 * 2);
}

.inline-link-card__site {
  font-size: 0.78rem;
  color: #6f6253;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inline-link-card__published {
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.3;
  color: #6f6253;
  white-space: nowrap;
}

#section-investment .entry-card {
  padding: 0.9rem 1rem;
}

#section-investment .entry-card__head {
  align-items: flex-start;
  gap: 0.55rem;
  margin-bottom: 0.2rem;
}

#section-investment .entry-card__date {
  flex: 0 0 auto;
  min-width: 6.1rem;
  font-size: 0.76rem;
  line-height: 1.3;
}

#section-investment .entry-card__head-main {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
}

#section-investment .entry-card__title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.35;
}

#section-investment .entry-card__head-side {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.78rem;
}

#section-investment .entry-card__excerpt {
  margin: 0.12rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

#section-investment .entry-card__thumb {
  margin-top: 0.35rem;
}

#section-investment .entry-card__tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.18rem 0.24rem;
  margin-top: 0.25rem;
}

#section-investment .entry-card__tags .tag {
  margin-top: 0;
  margin-right: 0;
}

#editor-body-rich .inline-link-card,
.body-preview__content .inline-link-card {
  width: 100%;
  max-width: 100%;
}

.textarea[data-font="serif"],
.body-preview__content[data-font="serif"] {
  font-family: var(--font-serif);
}

.textarea[data-font="sans"],
.body-preview__content[data-font="sans"] {
  font-family: var(--font-sans);
}

.textarea[data-font="mono"],
.body-preview__content[data-font="mono"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.textarea[data-font="hand"],
.body-preview__content[data-font="hand"] {
  font-family: "Gaegu", var(--font-sans);
}

.mood-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.mood-btn {
  font-size: 1.2rem;
  width: 2.85rem;
  height: 2.85rem;
  border: 1px solid rgba(184, 134, 74, 0.14);
  border-radius: 50%;
  background: rgba(255, 253, 249, 0.75);
  cursor: pointer;
  padding: 0;
  opacity: 0.82;
  transition: opacity 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.mood-btn:hover {
  opacity: 1;
  border-color: rgba(184, 134, 74, 0.28);
  background: rgba(255, 248, 238, 0.95);
  transform: translateY(-1px);
}

.mood-btn.is-selected {
  opacity: 1;
  border-color: rgba(184, 134, 74, 0.45);
  background: rgba(232, 212, 184, 0.32);
  box-shadow: 0 0 0 3px rgba(184, 134, 74, 0.1);
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.photo-item {
  position: relative;
  width: 88px;
  height: 88px;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.photo-item__remove {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 2;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--danger);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.photo-add {
  display: inline-flex;
  cursor: pointer;
}

.body-editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(232, 223, 208, 0.65);
}

.align-toolbar {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.1rem;
  padding: 0.1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 249, 0.6);
  flex-shrink: 0;
}

.align-toolbar__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.align-toolbar--photo {
  background: rgba(232, 212, 184, 0.28);
}

.btn--icon-only {
  padding: 0.38rem;
  min-width: 2rem;
  min-height: 2rem;
  border: none;
  border-radius: 6px;
  color: #8a7b68;
  background: transparent;
}

.btn--icon-only:hover {
  border-color: transparent;
  color: var(--text);
  background: rgba(184, 134, 74, 0.1);
}

.btn--icon-only svg {
  display: block;
  width: 1.05rem;
  height: 1.05rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.align-toolbar .btn--icon-only.is-active {
  background: rgba(184, 134, 74, 0.16);
  color: var(--accent);
}

.photo-add.btn--icon-only {
  color: var(--text-muted);
}

.photo-add.btn--icon-only:hover {
  color: var(--accent);
}

.body-preview__content p {
  margin: 0 0 0.35em;
}

.body-preview__content p:last-child {
  margin-bottom: 0;
}

.body-preview {
  margin-top: 0.75rem;
  padding: 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.body-preview__label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.body-preview__content {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.55;
  word-break: break-word;
}

.body-preview__content .inline-photo {
  margin: 0.35rem 0;
  display: block;
  max-width: 100%;
}

.body-preview__content .inline-photo-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.35rem 0;
  max-width: 100%;
  width: 100%;
}

.body-preview__content .inline-photo-row .inline-photo {
  margin: 0 !important;
  flex: 1 1 0 !important;
  min-width: 0 !important;
  max-width: calc(50% - 0.25rem) !important;
  width: auto !important;
}

.body-preview__content .inline-photo[data-align="center"] {
  margin-left: auto;
  margin-right: auto;
}

.body-preview__content .inline-photo[data-align="right"] {
  margin-left: auto;
  margin-right: 0;
}

.body-preview__content .inline-photo img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.inline-link {
  color: #2f6db5;
  text-decoration: underline;
  word-break: break-all;
  cursor: pointer;
}

#reading-body-rich .reading-inline-link {
  pointer-events: auto;
}

.link-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0 0.55rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fcfaf6;
  text-decoration: none;
  color: inherit;
  max-width: 420px;
}

.link-card:hover {
  border-color: var(--accent);
}

.link-card__thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

.link-card__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.link-card__title {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-card__desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-card__site {
  font-size: 0.68rem;
  color: #857660;
}

.entry-card__photo-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.photo-item__insert {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 0.65rem;
  padding: 0.2rem;
  border: none;
  background: rgba(44, 36, 22, 0.75);
  color: #fff;
  cursor: pointer;
  border-radius: 0 0 8px 8px;
}

.photo-item--in-body::after {
  content: "본문에 있음";
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 0.6rem;
  background: var(--accent);
  color: #fff;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}

/* 로그인 화면과 계정 대화상자가 함께 쓴다. 앱 잠금은 제거됐지만 이 클래스는
   이름만 그 시절 것이고 여전히 쓰인다 */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(184, 134, 74, 0.12), transparent 60%);
}

.lock-screen[hidden] {
  display: none !important;
}

.lock-screen__panel {
  width: 100%;
  max-width: 360px;
  padding: 2rem 1.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.lock-screen__icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
}

.lock-screen__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
}

.lock-screen__msg {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.lock-screen__form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.lock-screen__input {
  width: 100%;
  text-align: center;
}

.lock-screen__error {
  margin: 0;
  min-height: 1.25rem;
  font-size: 0.85rem;
  color: var(--danger);
}

.lock-screen__submit {
  width: 100%;
  margin-top: 0.25rem;
  justify-content: center;
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .editor-layout {
    grid-template-columns: 1fr;
    padding-bottom: 0.5rem;
  }

  #screen-editor .editor-layout {
    display: flex;
    flex-direction: column;
  }

  #screen-editor .editor-main,
  #screen-editor .editor-side {
    flex: none;
    width: auto !important;
    max-width: none;
    min-width: 0;
    padding-left: 0;
  }

  .editor-layout__resize {
    display: none;
  }

  .textarea--xl {
    min-height: 42vh;
  }

  .editor__footer {
    display: block;
    position: sticky;
    bottom: 0;
    z-index: 60;
    margin: 0.75rem 0 0;
    padding: 0.65rem 0;
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, transparent, var(--bg) 18%, var(--bg));
    border-top: 1px solid var(--border);
  }

  .editor__footer .btn--block {
    width: 100%;
    justify-content: center;
    min-height: 2.75rem;
    font-weight: 600;
  }

  .header__logo {
    width: auto;
    max-width: 5.25rem;
    height: auto;
    max-height: 1.55rem;
  }

  .header__badge {
    font-size: 0.62rem;
    padding: 0.18rem 0.38rem;
    max-width: 62%;
    white-space: normal;
    text-align: right;
  }

  .header__tools {
    gap: 0.15rem;
  }

  .header__tools .btn--ghost {
    min-width: 1.85rem;
    padding: 0.28rem 0.4rem;
    font-size: 0.78rem;
  }

  #btn-tab-settings {
    font-size: 0.68rem;
    padding: 0.25rem 0.38rem;
  }

  /* 편집 화면: 상단 로고·헤더가 본문 도구栏과 겹치지 않게 */
  body.inv-editor-open .header__main,
  .app:has(#screen-editor:not([hidden])) .header__main,
  .app:has(#reading-screen-editor:not([hidden])) .header__main,
  .app:has(#inv-screen-editor:not([hidden])) .header__main {
    display: none !important;
  }

  body.inv-editor-open .header--global,
  .app:has(#screen-editor:not([hidden])) .header--global,
  .app:has(#reading-screen-editor:not([hidden])) .header--global,
  .app:has(#inv-screen-editor:not([hidden])) .header--global {
    position: relative;
    top: auto;
    z-index: 1;
    margin-bottom: 0.35rem;
    padding-top: 0.15rem;
  }

  body.markup-drawing-active .header--global {
    display: none !important;
  }

  body.markup-drawing-active {
    overflow: auto;
  }

  body.markup-drawing-active #inv-editor-body-rich,
  body.markup-drawing-active #section-investment .rich-editor {
    touch-action: pan-x pan-y pinch-zoom;
    overflow: auto;
    overscroll-behavior: contain;
  }

  body.markup-drawing-active #inv-markup-toolbar.markup-toolbar--floating {
    position: fixed;
    right: max(0.5rem, env(safe-area-inset-right));
    bottom: max(0.65rem, env(safe-area-inset-bottom));
    top: auto;
    left: auto;
    z-index: 6000;
    margin: 0;
    width: auto;
    max-width: min(22rem, calc(100vw - 1rem));
  }

  .screen-editor:not([hidden]) .editor-sticky-chrome {
    position: sticky;
    top: 0;
    z-index: 120;
    background: var(--bg);
  }

  .screen-editor:not([hidden]) .editor-sticky-chrome__tools .body-editor__toolbar {
    position: static;
    top: auto;
    z-index: auto;
    margin-top: 0;
    padding-top: 0.15rem;
    padding-left: 0;
    padding-right: 0;
    background: transparent;
    border-bottom: none;
  }

  #inv-screen-editor .editor-layout {
    display: flex;
    flex-direction: column;
  }

  #inv-screen-editor .editor-main,
  #inv-screen-editor .editor-side {
    flex: none;
    width: auto !important;
    max-width: none;
    min-width: 0;
    padding-left: 0;
  }
}

/* 통합 앱 탭 */
.header--global {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  position: sticky;
  top: 0;
  z-index: 200;
  margin-bottom: 0.5rem;
  background: var(--bg);
  padding-top: max(0.25rem, env(safe-area-inset-top));
}

/* 편집 중: 상태줄은 sticky 크롬에 합쳐지므로 숨김 */
body.diary-editor-open .header__status-row,
body.inv-editor-open .header__status-row,
.app:has(#screen-editor:not([hidden])) .header__status-row,
.app:has(#inv-screen-editor:not([hidden])) .header__status-row {
  display: none !important;
}

body.diary-editor-open .editor-sticky-chrome,
body.inv-editor-open .editor-sticky-chrome,
#screen-editor:not([hidden]) .editor-sticky-chrome,
#inv-screen-editor:not([hidden]) .editor-sticky-chrome {
  position: sticky;
  top: 3.15rem;
  z-index: 190;
  margin-top: 0;
  box-shadow: 0 1px 0 var(--border);
}

.server-offline-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  color: #991b1b;
  font-size: 0.875rem;
}

.server-offline-banner[hidden] {
  display: none !important;
}

.server-offline-banner code {
  font-size: 0.8125rem;
}

.mobile-url-banner {
  margin: 0;
  padding: 0.35rem 0.55rem;
  background: #f0f7ff;
  border: 1px solid #93c5fd;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.mobile-url-banner[hidden] {
  display: none !important;
}

.mobile-url-banner__label {
  color: #1e40af;
  flex: 0 0 auto;
}

.mobile-url-banner__link {
  display: inline;
  word-break: break-all;
  font-weight: 700;
  color: #1d4ed8;
  text-decoration: none;
}

.mobile-url-banner__link:hover {
  text-decoration: underline;
}

.app-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin-bottom: 1rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

.app-tabs.app-tabs--header {
  display: flex;
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  gap: 0.1rem;
  flex: 1 1 auto;
  justify-content: center;
  flex-wrap: nowrap;
}

.app-tabs--header .app-tabs__item {
  min-width: 0;
  width: auto;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.2;
  text-align: center;
  border-radius: 0;
  background: transparent;
  color: #9a8d7a;
  box-shadow: none;
}

.app-tabs__item {
  flex: 0 0 auto;
  min-width: 0;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.5rem 0.7rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  border-bottom: 2px solid transparent;
}

.app-tabs__item:hover:not(.app-tabs__item--active) {
  color: var(--text);
  background: transparent;
}

.app-tabs__item--active {
  background: transparent;
  color: var(--text);
  font-weight: 700;
  box-shadow: none;
  border-bottom-color: var(--accent);
}

.app-tabs--header .app-tabs__item--active {
  background: transparent;
  color: #1a1a1a;
  box-shadow: none;
  border-bottom: 2px solid #5c4030;
}

@media (max-width: 768px) {
  .header--global {
    gap: 0.2rem;
  }

  .header__main {
    flex-wrap: wrap;
  }

  .app-tabs.app-tabs--header {
    order: 3;
    flex: 1 1 100%;
    justify-content: space-between;
    padding: 0;
  }

  .app-tabs--header .app-tabs__item {
    font-size: 0.7rem;
    padding: 0.4rem 0.35rem;
    letter-spacing: 0.02em;
    flex: 1 1 0;
  }
}

.app-section[hidden] {
  display: none !important;
}

.app-section--media {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 8.5rem);
}

.app-section--media.app-section--active {
  display: flex !important;
}

.app-section--placeholder {
  min-height: calc(100dvh - 12rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.app-section--placeholder.app-section--active {
  display: flex !important;
}

.section-placeholder {
  max-width: 28rem;
  text-align: center;
  padding: 2.5rem 1.75rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.section-placeholder__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
}

.section-placeholder__lead {
  margin: 0 0 0.35rem;
  color: var(--text);
  font-size: 1rem;
}

.media-frame {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  min-height: 420px;
  height: calc(100dvh - 9.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.media-frame-hint {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.media-frame-hint--error {
  color: #b45309;
}

.app-section--embed {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 8.5rem);
}

.app-section--embed.app-section--active {
  display: flex !important;
}

.section-actions--embed {
  flex: 0 0 auto;
}

.embed-frame {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  min-height: 420px;
  height: calc(100dvh - 11rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.embed-frame[hidden] {
  display: none !important;
}

.embed-empty {
  flex: 1 1 auto;
  min-height: 16rem;
  margin: 0;
}

.drive-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0.5rem;
}

.drive-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.drive-toolbar__crumb {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-status {
  margin: 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.drive-status--error {
  color: #9a3412;
  border-color: #fdba74;
  background: #fff7ed;
}

.drive-grid {
  flex: 1 1 auto;
  min-height: 12rem;
  max-height: calc(100dvh - 12rem);
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  padding: 0.35rem 0.15rem 0.75rem;
  align-content: start;
}

.drive-grid__empty {
  grid-column: 1 / -1;
  margin: 2rem 0;
  text-align: center;
  color: var(--text-muted);
}

.drive-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.drive-card:hover {
  border-color: #c4a882;
  box-shadow: var(--shadow-card);
}

.drive-card__thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: calc(var(--radius) - 4px);
  background: #1a1a1a;
}

.drive-card__thumb--icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: #2a2a2a;
  color: #fff;
}

.drive-card__name {
  font-size: 0.78rem;
  line-height: 1.35;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.drive-preview {
  flex: 1 1 auto;
  min-height: 360px;
}

.drive-preview[hidden] {
  display: none !important;
}

.tab-settings-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: 30rem;
  width: calc(100% - 2rem);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.tab-settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.tab-settings-dialog__form {
  display: flex;
  flex-direction: column;
  max-height: min(85dvh, 36rem);
}

.tab-settings-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.tab-settings-dialog__title {
  margin: 0;
  font-size: 1.05rem;
}

.tab-settings-dialog__close {
  border: none;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

.tab-settings-dialog__body {
  padding: 1rem;
  overflow: auto;
}

.tab-settings-dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

/* 편집기 나가기 확인. 폭이 좁아 세 버튼이 겹치지 않게만 손본다 */
.editor-exit-dialog {
  max-width: 24rem;
}

.editor-exit-dialog__msg {
  margin: 0;
  line-height: 1.5;
}

.editor-exit-dialog__foot {
  flex-wrap: wrap;
}

/* 좁은 화면에서는 세로로. 「저장 안 함」을 잘못 누르는 일을 줄인다 */
@media (max-width: 380px) {
  .editor-exit-dialog__foot {
    flex-direction: column-reverse;
  }

  .editor-exit-dialog__foot .btn {
    width: 100%;
    justify-content: center;
  }
}

.tab-settings-row + .tab-settings-row {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.tab-settings-sync-status {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted, #6b5d4d);
}

.tab-settings-sync-status--ok {
  color: #2d6a4f;
}

.tab-settings-sync-status--warn {
  color: #b45309;
}

.tab-settings-sortable__hint {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.tab-settings-sortable {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tab-settings-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: var(--surface);
}

.tab-settings-row__order {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 0 0 auto;
  margin-top: 0.15rem;
}

.tab-settings-row__order-btn {
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tab-settings-row__order-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.tab-settings-row__order-btn:active:not(:disabled) {
  background: rgba(184, 134, 74, 0.12);
}

.tab-settings-row__order-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tab-settings-row__fields {
  flex: 1 1 auto;
  min-width: 0;
}

.tab-settings-row__label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
}

.tab-settings-row__sublabel {
  display: block;
  margin: 0.65rem 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.tab-settings-row__hint {
  margin: 0.4rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* 투자 탭 — 본문 인라인 필기 */
.editor-main--markup {
  position: relative;
}

#inv-markup-toolbar.markup-toolbar--floating {
  position: sticky;
  top: 0.35rem;
  z-index: 20;
  margin: 0 0 0.45rem;
  width: 100%;
}

.markup-toolbar__inner {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.85rem;
  background: rgba(28, 28, 30, 0.94);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-width: 100%;
}

.markup-toolbar__hint {
  margin: 0;
  font-size: 0.58rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.72);
}

.markup-toolbar__width-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  width: 100%;
}

.markup-toolbar__width-label {
  font-size: 0.58rem;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
}

.markup-toolbar__width {
  width: 100%;
  accent-color: #3498db;
}

.markup-toolbar__btn--done {
  width: 100%;
  height: auto;
  padding: 0.28rem 0.15rem;
  font-size: 0.62rem;
  background: rgba(46, 204, 113, 0.35);
}

.markup-toolbar__group,
.markup-toolbar__colors {
  display: flex;
  flex-direction: row;
  gap: 0.25rem;
}

.markup-toolbar__btn,
.markup-toolbar__color {
  width: 2.2rem;
  height: 2.2rem;
  border: none;
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.markup-toolbar__btn.is-active {
  background: rgba(52, 152, 219, 0.85);
}

.markup-toolbar__btn--clear {
  width: auto;
  height: auto;
  padding: 0.35rem 0.55rem;
  font-size: 0.58rem;
  line-height: 1.2;
}

#section-investment .rich-editor {
  touch-action: pan-y;
}

body.markup-drawing-active #section-investment .rich-editor {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  caret-color: transparent;
}

#section-investment .inline-photo__frame {
  position: relative;
}

#section-investment .inline-photo__markup-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
  z-index: 2;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#section-investment .inline-photo.is-markup-active .inline-photo__frame {
  touch-action: none;
  cursor: crosshair;
}

#section-investment .inline-photo.is-markup-active .inline-photo__markup-canvas,
#section-investment .inline-photo__markup-canvas.markup-canvas--active {
  pointer-events: auto;
  touch-action: none;
  z-index: 6;
  cursor: crosshair;
}

#section-investment .inline-photo.is-markup-active {
  outline: 2px solid rgba(184, 134, 74, 0.5);
  outline-offset: 2px;
  -webkit-user-select: none;
  user-select: none;
}

#section-investment .inline-photo.is-markup-active .inline-photo__resize {
  pointer-events: none;
  opacity: 0.35;
}

#section-investment .inline-markup__canvas {
  touch-action: none;
  display: block;
  width: 100%;
  min-height: 10rem;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}

#section-investment .inline-markup.is-active .inline-markup__canvas,
#section-investment .inline-markup__canvas.markup-canvas--active {
  touch-action: none;
  cursor: crosshair;
}

#section-investment .editor-compose.is-fullscreen,
#section-investment .body-editor.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  margin: 0;
  padding: max(0.65rem, env(safe-area-inset-top)) max(0.65rem, env(safe-area-inset-right))
    max(0.65rem, env(safe-area-inset-bottom)) max(0.65rem, env(safe-area-inset-left));
  background: var(--bg-elevated, #fffdf9);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: none;
}

body.inv-body-fullscreen-active .header--global {
  display: none !important;
}

#section-investment .editor-compose.is-fullscreen .editor-memo-chrome {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elevated, #fffdf9);
}

#section-investment .editor-compose.is-fullscreen .body-editor--scroll {
  flex: 1 1 auto;
  min-height: 0;
}

#section-investment .editor-compose.is-fullscreen #inv-editor-body-rich,
#section-investment .body-editor.is-fullscreen #inv-editor-body-rich {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

body.inv-body-fullscreen-active {
  overflow: hidden;
}

#section-investment #inv-btn-body-fullscreen.is-active {
  background: rgba(184, 134, 74, 0.18);
}

.markup-toolbar__color {
  padding: 0;
  background: var(--swatch, #fff);
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.markup-toolbar__color--picker {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}

.markup-toolbar__color-input {
  width: 140%;
  height: 140%;
  border: none;
  padding: 0;
  cursor: pointer;
}

.inline-markup {
  display: block;
  width: 100%;
  margin: 0.35rem 0;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: #fff;
  overflow: hidden;
}

.inline-markup.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(184, 134, 74, 0.2);
}

.inline-markup.is-active .inline-markup__canvas-wrap,
.inline-markup.is-resizing .inline-markup__canvas-wrap {
  box-shadow: inset 0 0 0 3px rgba(59, 130, 246, 0.45);
}

.inline-markup__gap {
  min-height: 0.65rem;
  cursor: text;
}

.inline-markup__gap--before {
  border-bottom: 1px dashed transparent;
}

.inline-markup__gap--after {
  border-top: 1px dashed transparent;
}

.inline-markup:hover .inline-markup__gap--before,
.inline-markup:hover .inline-markup__gap--after {
  border-color: rgba(184, 134, 74, 0.25);
  background: rgba(184, 134, 74, 0.04);
}

.inline-markup__canvas-wrap {
  width: 100%;
  min-height: 10rem;
  max-height: min(68vh, 36rem);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y pinch-zoom;
}

.inline-markup__canvas {
  display: block;
  width: 100%;
  min-height: 10rem;
  touch-action: pan-y pinch-zoom;
  cursor: default;
  background: #fff;
}

.inline-markup__resize {
  height: 1.15rem;
  cursor: ns-resize;
  position: relative;
  background: linear-gradient(to bottom, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.18));
  touch-action: none;
}

.inline-markup__resize::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(8rem, 36%);
  height: 0.26rem;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.45);
}

.inline-markup.is-active .inline-markup__resize,
.inline-markup.is-resizing .inline-markup__resize {
  background: linear-gradient(to bottom, rgba(59, 130, 246, 0.16), rgba(59, 130, 246, 0.28));
}

.inline-markup.is-active .inline-markup__resize::before,
.inline-markup.is-resizing .inline-markup__resize::before {
  height: 0.34rem;
  background: rgba(37, 99, 235, 0.92);
}

@media (max-width: 768px) {
  #inv-markup-toolbar.markup-toolbar--floating {
    margin: 0 0 0.35rem;
    width: 100%;
  }
}

body.app--media-active #mobile-icloud-hint,
body.app--embed-active #mobile-icloud-hint {
  display: none;
}

/* 독서 — 일기 탭과 동일한 타이포그래피 */
#section-reading {
  font-family: var(--font-sans);
}

#section-reading .reading-card__title {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
}

#section-reading .reading-card__author,
#section-reading .reading-card__meta,
#section-reading .reading-card__section {
  font-family: inherit;
}

#section-reading #reading-author,
#section-reading #reading-section,
#section-reading #reading-tags {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0;
}

#section-reading #reading-title {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0;
}

#reading-title[data-font="serif"],
#editor-title[data-font="serif"] {
  font-family: var(--font-serif);
}

#reading-title[data-font="sans"],
#editor-title[data-font="sans"] {
  font-family: var(--font-sans);
}

#reading-title[data-font="mono"],
#editor-title[data-font="mono"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

#reading-title[data-font="hand"],
#editor-title[data-font="hand"] {
  font-family: "Gaegu", var(--font-sans);
}

.reading-toolbar {
  margin-bottom: 1rem;
}

.reading-toolbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.reading-toolbar__row .search {
  flex: 1 1 12rem;
  min-width: 0;
}

.reading-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.reading-view-toggle {
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.1rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 249, 0.8);
  border: 1px solid var(--border);
}

.reading-view-toggle .btn.is-active {
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.reading-list--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem 0.75rem;
  padding-bottom: 2rem;
}

.reading-list--list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 2rem;
}

.reading-list--list .reading-card {
  flex-direction: row;
  align-items: stretch;
  text-align: left;
  padding: 0.85rem 1rem;
}

.reading-list--list .reading-card__cover {
  width: 72px;
  min-height: 96px;
  flex-shrink: 0;
}

.reading-list--list .reading-card__body {
  align-items: flex-start;
}

.reading-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.4rem 0.45rem 0.48rem;
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.reading-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}

.reading-card__cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f3ebe0;
}

.reading-card__cover--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.reading-card__body {
  width: 100%;
  margin-top: 0.28rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.04rem;
}

.reading-card__title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.28;
  word-break: keep-all;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reading-list--list .reading-card__title {
  -webkit-line-clamp: 1;
}

.reading-card__author {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.2;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reading-card__publisher {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reading-card__section {
  display: inline-block;
  margin: 0.06rem 0 0;
  padding: 0.08rem 0.38rem;
  font-size: 0.66rem;
  font-weight: 600;
  color: #6b5d4a;
  background: rgba(184, 134, 74, 0.14);
  border-radius: 999px;
}

.reading-card__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.15rem;
  margin-top: 0.08rem;
  font-size: 0.64rem;
  color: var(--text-muted);
}

.reading-card__date {
  font-variant-numeric: tabular-nums;
}

.reading-card__lead {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 2;
}

.reading-card__status-btn {
  border: none;
  cursor: pointer;
  font: inherit;
  line-height: 1.2;
}

.reading-card__status-btn:hover {
  filter: brightness(0.96);
}

.reading-card__status-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.reading-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  background: #f3ebe0;
  color: #6b5a45;
}

.reading-badge--reading {
  background: #efe6d8;
  color: #6a5b48;
  border-color: #e0d2bd;
}

.reading-badge--finished {
  background: #e2ebe0;
  color: #4a5f46;
  border-color: #c9d7c6;
}

.reading-badge.is-active {
  box-shadow: 0 0 0 2px rgba(184, 134, 74, 0.28);
}

.reading-editor-status {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0 0.5rem;
}

/**
 * 독서 편집 화면의 헤더. 여기에 저장 버튼이 있다.
 *
 * .editor__header는 display:none이다. 일기와 투자가 editor-sticky-chrome이라는
 * 새 헤더로 옮겨가면서 옛 헤더를 통째로 숨긴 것인데, 독서는 옮겨가지 못한 채
 * 그 규칙만 맞았다. 그래서 독서 탭에는 저장 버튼이 보이지 않았고 ⌘S로만
 * 저장할 수 있었다. index.html에서 .editor__header를 쓰는 곳은 독서뿐이다.
 *
 * 아래 flex-wrap·gap과 h2의 flex 값들은 원래 이 헤더가 flex 컨테이너임을
 * 전제하고 쓰인 것이다. 그 전제를 되살린다.
 *
 * 독서도 sticky chrome으로 옮기는 것이 결국 맞지만 그건 UI 개편이라 별도다.
 */
.editor__header--reading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.55rem;
}

.editor__header--reading h2 {
  flex: 0 1 auto;
  min-width: 4.5rem;
}

.reading-history-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: 0.15rem;
  padding: 0.1rem 0.15rem;
  border-radius: var(--radius-sm);
  background: rgba(243, 235, 224, 0.55);
  border: 1px solid rgba(184, 134, 74, 0.18);
}

.reading-history-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border: 1px solid rgba(107, 90, 69, 0.22);
  border-radius: 6px;
  background: #fffdf9;
  color: #5c4f3f;
  cursor: pointer;
}

.reading-history-btn svg {
  display: block;
  width: 1.05rem;
  height: 1.05rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reading-history-btn:hover:not([disabled]) {
  color: var(--accent);
  border-color: rgba(184, 134, 74, 0.45);
  background: #fff;
}

.reading-history-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.reading-history-btn[disabled] {
  opacity: 0.55;
  color: #9b8f7f;
  cursor: default;
  background: rgba(255, 253, 249, 0.7);
}

#reading-body-rich .inline-photo__frame {
  cursor: default;
}

#reading-body-rich .reading-inline-photo:not([data-width-pct]):not([data-size]) {
  width: 100%;
}

#reading-body-rich .reading-inline-photo.is-selected .inline-photo__resize {
  opacity: 1;
}

.reading-hl-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-width: 8.5rem;
  margin-left: 0.25rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  background: rgba(243, 235, 224, 0.45);
  border: 1px solid rgba(184, 134, 74, 0.16);
}

.reading-hl-tools .field__hint {
  margin-right: 0.15rem;
}

.reading-hl-btn {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.9);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.reading-hl-btn[data-reading-hl="yellow"] {
  color: #d9a820;
}

.reading-hl-btn[data-reading-hl="green"] {
  color: #4f9b4f;
}

.reading-hl-btn[data-reading-hl="cyan"] {
  color: #3f9ea8;
}

.reading-hl-btn[data-reading-hl="pink"] {
  color: #d66b96;
}

.reading-hl-btn:hover {
  transform: scale(1.06);
}

.reading-card__published {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.reading-card__status {
  padding: 0.1rem 0.4rem;
  background: #f3ebe0;
  border-radius: 4px;
}

.reading-cover-preview {
  width: 100%;
  max-width: 160px;
  aspect-ratio: 2 / 3;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f3ebe0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reading-cover-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reading-cover-preview__placeholder {
  font-size: 2.5rem;
}

.reading-cover-url-row {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.reading-cover-url-row .input {
  flex: 1;
  min-width: 0;
}

.reading-cover-url-row .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.reading-editor-layout .textarea--xl {
  min-height: 50vh;
}

@media (max-width: 768px) {
  .reading-list--grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}
