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

body {
  font-family: 'IBM Plex Sans KR', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: #fff;
  color: #37352f;
  height: 100vh;
  overflow: hidden;
}

#auth-guard {
  position: fixed;
  inset: 0;
  background: #f5f4f0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

#auth-guard::after {
  content: 'Bananote';
  font-family: 'IBM Plex Sans KR', ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: #9b9a97;
  letter-spacing: -0.01em;
}

#app {
  display: flex;
  height: 100vh;
}

/* ===== SIDEBAR ===== */

#sidebar {
  width: 240px;
  min-width: 240px;
  background: #f0efe9;
  border-right: 1px solid #e3e2df;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: width 0.2s ease, min-width 0.2s ease, border-right-width 0.2s ease;
}

#app.sidebar-collapsed #sidebar {
  width: 0;
  min-width: 0;
  border-right-width: 0;
}

/* Shared icon button style used across the sidebar */
.sidebar-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #9b9a97;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}
.sidebar-icon-btn:hover { background: #dddbd4; color: #37352f; }
.sidebar-icon-btn svg { pointer-events: none; display: block; }

/* Reveal tab when sidebar is collapsed */
#sidebar-reveal-btn {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 300;
  background: #f0efe9;
  border: 1px solid #e3e2df;
  border-left: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  color: #9b9a97;
  width: 20px;
  height: 52px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}
#sidebar-reveal-btn:hover { background: #e3e2df; color: #37352f; }
#sidebar-reveal-btn svg { pointer-events: none; display: block; }

/* ===== WORKSPACE BAR ===== */

#workspace-bar {
  display: flex;
  align-items: center;
  padding: 10px 8px 10px;
  gap: 2px;
  flex-shrink: 0;
}

#ws-switcher-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: #37352f;
  padding: 5px 6px;
  border-radius: 6px;
  text-align: left;
  min-width: 0;
  transition: background 0.12s;
}
#ws-switcher-btn:hover { background: #dddbd4; }

.ws-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #37352f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
  font-family: inherit;
}

#ws-name-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-caret-svg { flex-shrink: 0; color: #9b9a97; pointer-events: none; }

#ws-settings-btn.hidden { visibility: hidden; pointer-events: none; }

/* ===== SIDEBAR CALENDAR ===== */

#sidebar-calendar {
  padding: 8px 10px 10px;
  border-bottom: 1px solid #e3e2df;
  flex-shrink: 0;
}

#cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

#cal-title {
  font-size: 11.5px;
  font-weight: 600;
  color: #37352f;
  letter-spacing: 0.01em;
}

#cal-prev, #cal-next {
  background: none;
  border: none;
  cursor: pointer;
  color: #9b9a97;
  font-size: 18px;
  line-height: 1;
  padding: 0 3px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  transition: color 0.1s, background 0.1s;
}
#cal-prev:hover, #cal-next:hover { color: #37352f; background: rgba(55,53,47,0.08); }

#cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px 0;
}

.cal-day-hdr {
  font-size: 10px;
  font-weight: 600;
  color: #b5b4b1;
  text-align: center;
  padding: 2px 0 4px;
}

.cal-cell {
  font-size: 11px;
  text-align: center;
  padding: 3px 0;
  border-radius: 50%;
  color: #37352f;
  line-height: 1.5;
  min-width: 0;
}

.cal-day { cursor: default; }
.cal-today {
  background: #0f7b6c;
  color: #fff;
  font-weight: 700;
}

.cal-day {
  position: relative;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.1s;
}
.cal-day:hover:not(.cal-today):not(.cal-selected) { background: rgba(55,53,47,0.08); }

.cal-selected {
  background: #e6f4f1;
  color: #0f7b6c;
  font-weight: 700;
}
.cal-selected:hover { background: #d4ede9 !important; }

.cal-dot {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #0f7b6c;
  display: block;
}
.cal-today .cal-dot { background: rgba(255,255,255,0.8); }
.cal-selected .cal-dot { background: #0f7b6c; }

/* Events panel below calendar */
#cal-events {
  margin-top: 8px;
  border-top: 1px solid #e8e7e3;
  padding-top: 8px;
}
.cal-events-header {
  font-size: 11px;
  font-weight: 700;
  color: #0f7b6c;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}
.cal-event-item {
  font-size: 11.5px;
  color: #37352f;
  padding: 4px 6px;
  border-radius: 4px;
  background: #f0faf8;
  margin-bottom: 3px;
  border-left: 2px solid #0f7b6c;
  line-height: 1.4;
  word-break: break-word;
}
.cal-event-empty {
  font-size: 11px;
  color: #b5b4b1;
  font-style: italic;
}

/* ===== PAGES SECTION ===== */

#sidebar-pages-header {
  display: flex;
  align-items: center;
  padding: 6px 12px 4px;
  gap: 2px;
  flex-shrink: 0;
}

.sidebar-section-label {
  flex: 1;
  font-size: 10.5px;
  font-weight: 600;
  color: #b5b4b1;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* ===== USER ROW ===== */

#sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #e3e2df;
  flex-shrink: 0;
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #37352f;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
  font-family: inherit;
}

#sidebar-username {
  flex: 1;
  font-size: 13px;
  color: #37352f;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#logout-btn:hover { color: #e03e3e !important; background: rgba(224,62,62,0.08) !important; }

#sidebar-user { cursor: pointer; border-radius: 6px; margin: 4px 6px; padding: 6px 8px; transition: background 0.1s; }
#sidebar-user:hover { background: rgba(55,53,47,0.06); }

/* ===== USER PROFILE POPUP ===== */

#user-profile-popup {
  position: fixed;
  width: 228px;
  background: #fff;
  border: 1px solid #e3e2df;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.14);
  z-index: 2000;
  padding: 0;
  overflow: hidden;
}

.upp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid #f0efe9;
}
.upp-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #37352f;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.upp-username { font-size: 13px; font-weight: 600; color: #37352f; }

.upp-section { padding: 12px 14px 10px; }
.upp-section-title {
  font-size: 10px;
  font-weight: 700;
  color: #9b9a97;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.caldav-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid #e3e2df;
  border-radius: 5px;
  margin-bottom: 6px;
  outline: none;
  color: #37352f;
  background: #fafaf9;
}
.caldav-input:focus { border-color: #0f7b6c; background: #fff; }

.caldav-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}
.caldav-status {
  font-size: 11px;
  color: #9b9a97;
  flex: 1;
}
.caldav-status.error { color: #e03e3e; }
.caldav-status.ok    { color: #0f7b6c; }

.caldav-save-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  background: #0f7b6c;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}
.caldav-save-btn:hover { background: #0d6b5e; }
.caldav-save-btn:disabled { background: #9b9a97; cursor: default; }

.caldav-info {
  font-size: 12px;
  color: #37352f;
  margin-bottom: 8px;
  word-break: break-all;
}
.caldav-disconnect-btn {
  font-size: 12px;
  font-family: inherit;
  color: #e03e3e;
  background: none;
  border: 1px solid #e3e2df;
  border-radius: 5px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.1s;
}
.caldav-disconnect-btn:hover { background: rgba(224,62,62,0.06); }

.upp-divider { height: 1px; background: #f0efe9; }
.upp-signout-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  color: #37352f;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.1s;
}
.upp-signout-btn:hover { background: rgba(55,53,47,0.04); color: #e03e3e; }


/* workspace dropdown */
#ws-dropdown {
  position: relative;
  background: #fff;
  border: 1px solid #e3e2df;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(55,53,47,0.12);
  margin: 0 8px;
  z-index: 100;
  overflow: hidden;
}

.ws-drop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: #37352f;
}

.ws-drop-item:hover { background: #f1f0ef; }
.ws-drop-item.active { font-weight: 600; }

.ws-drop-item-icon { font-size: 14px; flex-shrink: 0; }
.ws-drop-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; flex-direction: column; gap: 1px; }
.ws-drop-owner { font-size: 10px; color: #9b9a97; font-weight: 400; }
.ws-drop-item-check { font-size: 12px; color: #37352f; flex-shrink: 0; }
.ws-drop-section {
  font-size: 11px;
  font-weight: 600;
  color: #9b9a97;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 10px 10px 4px;
}

.ws-drop-section:first-child { padding-top: 6px; }

.ws-drop-sep { height: 1px; background: #e3e2df; margin: 3px 0; }

.ws-drop-new {
  color: #6b6a67;
  font-size: 12px;
}

/* workspace modal */
#ws-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ws-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(55,53,47,0.35);
}

#ws-modal-box {
  position: relative;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(55,53,47,0.18);
  width: 460px;
  max-width: calc(100vw - 32px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

#ws-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e3e2df;
  flex-shrink: 0;
}

#ws-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: #37352f;
}

#ws-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #9b9a97;
  font-size: 16px;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

#ws-modal-close:hover { background: #e3e2df; color: #37352f; }

#ws-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.ws-section {
  margin-bottom: 22px;
}

.ws-section:last-child { margin-bottom: 0; }

.ws-section-label {
  font-size: 11px;
  font-weight: 600;
  color: #9b9a97;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.ws-name-row {
  display: flex;
  gap: 8px;
}

.ws-name-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid #e3e2df;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  color: #37352f;
  background: #faf9f7;
  outline: none;
  transition: border-color 0.15s;
}

.ws-name-row input:focus { border-color: #37352f; background: #fff; }

.ws-save-btn {
  padding: 7px 14px;
  background: #37352f;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  flex-shrink: 0;
}

.ws-save-btn:hover { background: #2d2c27; }

.ws-hint {
  font-size: 12px;
  margin-top: 5px;
  color: #9b9a97;
}

.ws-hint.error { color: #dc2626; }
.ws-hint.success { color: #059669; }

.ws-member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f1f0ef;
  font-size: 13px;
}

.ws-member-row:last-child { border-bottom: none; }
.ws-member-name { flex: 1; color: #37352f; font-weight: 500; }
.ws-member-role { font-size: 11px; color: #9b9a97; background: #f1f0ef; padding: 2px 7px; border-radius: 10px; }

.ws-remove-btn {
  background: none;
  border: 1px solid #e3e2df;
  border-radius: 4px;
  cursor: pointer;
  color: #9b9a97;
  font-size: 11px;
  font-family: inherit;
  padding: 2px 8px;
  transition: all 0.12s;
}

.ws-remove-btn:hover { border-color: #e03e3e; color: #e03e3e; background: #fff5f5; }

.ws-invite-row {
  display: flex;
  gap: 8px;
}

.ws-invite-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid #e3e2df;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  color: #37352f;
  background: #faf9f7;
  outline: none;
  transition: border-color 0.15s;
}

.ws-invite-row input:focus { border-color: #37352f; background: #fff; }

.ws-invite-btn {
  padding: 7px 14px;
  background: #37352f;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  flex-shrink: 0;
}

.ws-invite-btn:hover { background: #2d2c27; }

.ws-danger-btn {
  background: none;
  border: 1px solid #fecaca;
  color: #dc2626;
  border-radius: 5px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
  margin-right: 8px;
}

.ws-danger-btn:hover { background: #fef2f2; }

#page-tree {
  flex: 1;
  overflow-y: auto;
  padding: 2px 0 8px;
}

.tree-empty {
  color: #9b9a97;
  font-size: 13px;
  padding: 10px 14px;
}

.tree-item {
  display: flex;
  align-items: center;
  cursor: pointer;
  height: 30px;
  border-radius: 4px;
  margin: 0 4px;
  user-select: none;
  position: relative;
}

.tree-item:hover { background: #ece9e3; }
.tree-item.active { background: #e3e2df; }

.tree-toggle {
  font-size: 9px;
  color: #9b9a97;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.1s;
}

.tree-item:hover .tree-toggle,
.tree-item.active .tree-toggle,
.tree-toggle.has-children { opacity: 1; }

.tree-icon {
  font-size: 13px;
  flex-shrink: 0;
  margin-right: 5px;
  opacity: 0.6;
}

.tree-label {
  flex: 1;
  font-size: 13.5px;
  color: #37352f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 4px;
}

.tree-actions {
  display: none;
  align-items: center;
  flex-shrink: 0;
  padding-right: 4px;
}

.tree-item:hover .tree-actions { display: flex; }

.tree-add-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #9b9a97;
  font-size: 16px;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-add-btn:hover {
  background: #d3d2cf;
  color: #37352f;
}

/* ===== MAIN CONTENT ===== */

#content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #9b9a97;
}

#empty-state p { font-size: 15px; }

#empty-new-btn {
  padding: 8px 18px;
  background: #37352f;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}

#empty-new-btn:hover { background: #2f2e28; }

#no-workspace-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #9b9a97;
}

#no-workspace-state p { font-size: 15px; }

#create-first-ws-btn {
  padding: 8px 18px;
  background: #37352f;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}

#create-first-ws-btn:hover { background: #2f2e28; }

/* ===== EDITOR AREA ===== */

#editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 46px;
  border-bottom: 1px solid #ebe9e4;
  flex-shrink: 0;
  background: #fafaf8;
  gap: 8px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 1px;
  background: #fff;
  border: 1px solid #e3e2df;
  border-radius: 7px;
  padding: 3px;
}

#editor-toolbar button[data-action] {
  background: none;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: #6b6a67;
  padding: 0 8px;
  height: 26px;
  min-width: 28px;
  line-height: 1;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}
#editor-toolbar button svg,
#delete-page-btn svg {
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}

#editor-toolbar button[data-action]:hover {
  background: #f0efe9;
  color: #37352f;
}

#editor-toolbar button[data-action].toolbar-active {
  background: #37352f;
  color: #fff;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#save-status {
  font-size: 11px;
  color: #b5b4b1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 4px;
  transition: color 0.2s;
}

#save-status.status-unsaved { color: #d9730d; }
#save-status.status-saved   { color: #0f7b6c; }
#save-status.status-error   { color: #e03e3e; }

#delete-page-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: #b5b4b1;
  padding: 0;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

#delete-page-btn:hover {
  background: #fff0f0;
  border-color: #ffd0d0;
  color: #e03e3e;
}

/* ===== PAGE SCROLL ===== */

#page-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 0 48px;
}

/* Cover lives BEFORE #page-content; negative margin escapes the parent padding */
#page-cover-area {
  margin: 0 -48px;
  height: 200px;
  position: relative;
  overflow: hidden;
  background: #e5e7eb;
}

#page-cover-actions {
  position: absolute;
  bottom: 10px;
  right: 14px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}

#page-cover-area:hover #page-cover-actions { opacity: 1; }

.cover-action-btn {
  background: rgba(255,255,255,0.88);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  padding: 4px 10px;
  color: #37352f;
  font-weight: 500;
  backdrop-filter: blur(4px);
}
.cover-action-btn:hover { background: rgba(255,255,255,1); }

/* Hero area: icon + meta buttons */
#page-hero {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 40px;
}
#page-hero.has-cover { padding-top: 16px; }

#page-icon-wrap { line-height: 1; }

.page-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 64px;
  line-height: 1;
  padding: 4px 2px;
  border-radius: 6px;
  transition: background 0.1s;
  display: inline-block;
}
.page-icon:hover { background: rgba(55,53,47,0.08); }

#page-header-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
#page-hero:hover #page-header-actions,
#page-hero:focus-within #page-header-actions { opacity: 1; }

.page-meta-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: #b5b4b1;
  padding: 3px 7px;
  border-radius: 4px;
}
.page-meta-btn:hover { background: rgba(55,53,47,0.06); color: #9b9a97; }

#page-content {
  max-width: 720px;
  margin: 0 auto;
}

#page-title {
  font-size: 40px;
  font-weight: 700;
  color: #37352f;
  padding: 48px 0 6px;
  border: none;
  outline: none;
  line-height: 1.2;
  letter-spacing: -0.02em;
  word-break: break-word;
  transition: padding-top 0.15s;
}

#page-title:empty::before {
  content: attr(placeholder);
  color: #c4c3bf;
  pointer-events: none;
}

/* ===== BLOCKS ===== */

#blocks-container {
  padding-top: 4px;
  padding-bottom: 240px;
  cursor: text;
  min-height: 300px;
}

.block {
  position: relative;
  border-radius: 4px;
  margin: 1px 0;
  padding-top: 3px;
}

.block:hover:not(.active):not(.selected) { background: rgba(55, 53, 47, 0.03); }

.block:focus { outline: none; }

/* Horizontal top-bar indicator (also the drag handle) */
.block-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 2px 2px 0 0;
  cursor: grab;
  background: transparent;
  transition: background 0.12s;
  z-index: 5;
  user-select: none;
}
.block-top-bar:active { cursor: grabbing; }
.block.active > .block-top-bar                     { background: #0f7b6c; }
.block.selected > .block-top-bar                   { background: #3b82f6; }
.block.dragging > .block-top-bar                   { background: transparent; }

.block.selected { background: rgba(59, 130, 246, 0.04); }

/* View mode (rendered HTML) */
.block-preview {
  padding: 3px 4px;
  min-height: 1.6em;
  line-height: 1.75;
  cursor: text;
  word-break: break-word;
}

.block-preview.empty::after {
  content: 'Click to edit…';
  color: #c4c3bf;
  font-size: 14px;
  pointer-events: none;
}

/* Edit mode (markdown textarea) */
.block-editor {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: 'IBM Plex Sans KR', ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.8;
  color: #37352f;
  background: #f5f4f0;
  padding: 4px 8px;
  border-radius: 4px;
  min-height: 30px;
  overflow: hidden;
  caret-color: #37352f;
}

.block-editor::placeholder { color: #c4c3bf; }

/* ===== RENDERED HTML STYLES (inside .block-preview) ===== */

.block-preview h1,
.block-preview h2,
.block-preview h3,
.block-preview h4,
.block-preview h5,
.block-preview h6 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 0;
}

.block-preview h1 { font-size: 1.875em; }
.block-preview h2 { font-size: 1.5em; }
.block-preview h3 { font-size: 1.25em; }
.block-preview h4 { font-size: 1.1em; }

.block-preview p { margin: 0; }

.block-preview a {
  color: #0f7b6c;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.block-preview strong { font-weight: 600; }

.block-preview code {
  font-family: 'SF Mono', 'Cascadia Code', 'Menlo', monospace;
  font-size: 0.875em;
  background: #f0efe9;
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: #e03e3e;
}

.block-preview pre {
  background: #f7f6f3;
  border: 1px solid #e3e2df;
  border-radius: 6px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 0;
}

.block-preview pre code {
  background: none;
  padding: 0;
  color: #37352f;
  border-radius: 0;
}

.block-preview blockquote {
  border-left: 3px solid #e3e2df;
  padding: 2px 0 2px 16px;
  margin: 0;
  color: #9b9a97;
}

.block-preview ul,
.block-preview ol {
  padding-left: 1.6em;
  margin: 0;
}

.block-preview li { margin: 0.1em 0; }

.block-preview hr {
  border: none;
  border-top: 1px solid #e3e2df;
  margin: 8px 0;
}

.block-preview table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95em;
}

.block-preview th,
.block-preview td {
  border: 1px solid #e3e2df;
  padding: 6px 12px;
  text-align: left;
}

.block-preview th {
  background: #f7f6f3;
  font-weight: 600;
}

.block-preview img {
  max-width: 100%;
  border-radius: 4px;
}

/* ===== FORMULA BAR ===== */

.formula-bar {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid #d3d2cf;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  background: #fff;
  height: 30px;
  overflow: hidden;
}

.fbar-label {
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: #0059c7;
  border-right: 1px solid #d3d2cf;
  height: 100%;
  display: flex;
  align-items: center;
  background: #f5f8ff;
  flex-shrink: 0;
  font-style: italic;
}

.fbar-ref {
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #37352f;
  border-right: 1px solid #d3d2cf;
  min-width: 40px;
  height: 100%;
  display: flex;
  align-items: center;
  background: #fafaf8;
  flex-shrink: 0;
  font-family: 'SF Mono', 'Cascadia Code', 'Menlo', monospace;
}

.fbar-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0 10px;
  font-size: 13px;
  font-family: 'SF Mono', 'Cascadia Code', 'Menlo', monospace;
  color: #37352f;
  height: 100%;
  background: transparent;
}

.fbar-input[readonly] { color: #b5b4b1; }
.fbar-input:not([readonly]) { color: #0059c7; }

.cell-fmt-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  background: #fafaf8;
  border: 1px solid #d3d2cf;
  border-top: none;
  border-bottom: none;
}
.fbar-fmt-btn {
  background: none;
  border: none;
  border-radius: 3px;
  padding: 2px 7px;
  height: 24px;
  font-size: 12px;
  cursor: pointer;
  color: #37352f;
  display: flex;
  align-items: center;
}
.fbar-fmt-btn:hover { background: #e9e8e5; }
.fbar-fmt-sep {
  width: 1px;
  height: 14px;
  background: #d3d2cf;
  margin: 0 2px;
  flex-shrink: 0;
}

/* ===== TABLE EDITOR ===== */

.table-editor {
  overflow-x: auto;
  margin: 2px 0;
  padding-bottom: 2px;
  border-radius: 4px;
}

.table-grid {
  border-collapse: collapse;
  font-size: 14px;
  min-width: 100%;
}

.table-grid th,
.table-grid td {
  border: 1px solid #d3d2cf;
  padding: 0;
  min-width: 120px;
  position: relative;
}

.table-grid thead tr th {
  background: #f7f6f3;
}

.table-grid th input,
.table-grid td input {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  padding: 7px 10px;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  color: #37352f;
  line-height: 1.5;
  min-width: 0;
}

.table-grid th input { font-weight: 600; }

.table-grid th input:focus,
.table-grid td input:focus {
  background: #eef4ff;
  box-shadow: inset 0 0 0 2px #3b82f6;
  position: relative;
  z-index: 1;
}

/* Formula cells */
.table-grid td:has(input[data-formula]),
.table-grid th:has(input[data-formula]) {
  background: #f5f8ff;
}

.table-grid input[data-formula] {
  color: #0059c7;
}

.table-grid input[data-formula]:focus {
  color: #37352f;
}

.col-add-btn {
  width: 34px !important;
  min-width: 34px !important;
  cursor: pointer;
  text-align: center;
  color: #9b9a97;
  font-size: 16px;
  font-weight: 400;
  user-select: none;
  background: #f7f6f3;
}

.col-add-btn:hover { background: #e3e2df; color: #37352f; }

.row-del-btn {
  width: 34px !important;
  min-width: 34px !important;
  cursor: pointer;
  text-align: center;
  color: #c4c3bf;
  font-size: 14px;
  user-select: none;
  background: transparent;
}

.row-del-btn:hover { background: #ffe2e2; color: #e03e3e; }

.row-add-btn {
  display: inline-block;
  margin-top: 5px;
  background: none;
  border: none;
  cursor: pointer;
  color: #9b9a97;
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: inherit;
}

.row-add-btn:hover { background: #f0efe9; color: #37352f; }

/* ===== TODO / CHECKBOX ===== */

.todo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
  min-height: 1.75em;
}

.todo-checkbox {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 1.5px solid #c4c3bf;
  border-radius: 3px;
  cursor: pointer;
  margin: 0;
  position: relative;
  background: #fff;
  transition: background 0.12s, border-color 0.12s;
}

.todo-checkbox:hover { border-color: #9b9a97; }

.todo-checkbox:checked {
  background: #0f7b6c;
  border-color: #0f7b6c;
}

.todo-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.todo-text {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: #37352f;
  background: transparent;
  padding: 0;
  line-height: 1.75;
  min-width: 0;
}

.todo-text::placeholder { color: #c4c3bf; }

.todo-done {
  color: #b5b4b1;
  text-decoration: line-through;
}

/* ===== SLASH MENU ===== */

#slash-menu {
  position: fixed;
  z-index: 1000;
  background: #fff;
  border: 1px solid #e3e2df;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
  width: 280px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 0;
  display: none;
}

.slash-group {
  font-size: 11px;
  font-weight: 600;
  color: #9b9a97;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 12px 4px;
}

.slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
}

.slash-item:hover,
.slash-item.selected {
  background: #f0efe9;
}

.slash-icon {
  width: 28px;
  height: 28px;
  background: #f7f6f3;
  border: 1px solid #e3e2df;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.slash-label {
  font-size: 13.5px;
  font-weight: 500;
  color: #37352f;
  flex-shrink: 0;
}

.slash-desc {
  font-size: 12px;
  color: #9b9a97;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== TABLE ENHANCEMENTS ===== */

/* ⊟ row header / Σ summary toggles in formula bar */
.tbl-rowhdr-btn,
.tbl-summary-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #9b9a97;
  padding: 0 8px;
  height: 100%;
  font-family: inherit;
  flex-shrink: 0;
}
.tbl-rowhdr-btn:hover,
.tbl-summary-btn:hover { background: #f0efe9; color: #37352f; }
.tbl-rowhdr-btn.active,
.tbl-summary-btn.active { color: #0f7b6c; border-color: #0f7b6c; }

/* Row header column */
.table-grid .row-header-cell { background: #f7f6f3; }
.table-grid .row-header-cell input { font-weight: 600; background: transparent; }
.table-grid .row-header-cell input:focus { background: #eef4ff; }

/* Format badge in column header */
.col-fmt-badge {
  position: absolute;
  bottom: 2px;
  right: 18px;
  font-size: 9px;
  font-weight: 700;
  color: #9b9a97;
  pointer-events: none;
  letter-spacing: 0.02em;
}

/* Column resize handle */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  user-select: none;
  z-index: 2;
}
.col-resize-handle:hover { background: rgba(0,0,0,0.15); }
.col-resize-handle.resizing { background: rgba(0,0,0,0.25); }

/* Summary row */
.summary-foot td {
  background: #f7f6f3;
  border: 1px solid #d3d2cf;
  padding: 0;
}
.summary-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  cursor: pointer;
  min-height: 38px;
  gap: 1px;
  user-select: none;
}
.summary-cell:hover { background: #ece9e3; }
.summary-value {
  font-size: 12px;
  font-weight: 600;
  color: #37352f;
  line-height: 1.3;
}
.summary-label {
  font-size: 10px;
  color: #9b9a97;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Column context menu */
.col-context-menu {
  position: fixed;
  z-index: 2000;
  background: #fff;
  border: 1px solid #e3e2df;
  border-radius: 7px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.13), 0 1px 4px rgba(0,0,0,0.06);
  min-width: 170px;
  padding: 4px 0;
}
.col-menu-section {
  font-size: 10px;
  font-weight: 700;
  color: #9b9a97;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 12px 3px;
}
.col-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  font-size: 13px;
  color: #37352f;
  cursor: pointer;
}
.col-menu-item span {
  width: 16px;
  text-align: center;
  font-weight: 600;
  color: #9b9a97;
}
.col-menu-item:hover { background: #f0efe9; }
.col-menu-item.active { color: #0f7b6c; font-weight: 600; }
.col-menu-item.active span { color: #0f7b6c; }
.col-menu-danger { color: #e03e3e !important; }
.col-menu-danger:hover { background: #ffe2e2 !important; }
.col-menu-sep { height: 1px; background: #e3e2df; margin: 4px 0; }

/* Nested submenu */
.col-menu-has-sub { position: relative; }
.sub-arrow { margin-left: auto; font-size: 9px; color: #9b9a97; pointer-events: none; }
.col-submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: -4px;
  z-index: 2001;
  background: #fff;
  border: 1px solid #e3e2df;
  border-radius: 7px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.13);
  min-width: 130px;
  padding: 4px 0;
}
.col-menu-has-sub:hover .col-submenu { display: block; }
.col-context-menu.submenu-left .col-submenu { left: auto; right: 100%; }

/* ===== SECTION BLOCK ===== */

.section-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  border-radius: 4px;
  cursor: default;
}
.section-header:hover { background: rgba(55,53,47,0.04); }

.section-arrow {
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: #9b9a97;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  flex-shrink: 0;
  transition: transform 0.15s, color 0.1s;
  transform: rotate(0deg);
}
.section-arrow:hover { color: #37352f; background: rgba(55,53,47,0.08); }
.section-arrow.open { transform: rotate(90deg); }

.section-title-input {
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: #37352f;
  background: transparent;
  border: none;
  outline: none;
  flex: 1;
  padding: 2px 0;
  cursor: text;
}
.section-title-input::placeholder { color: #c4c3bf; font-weight: 400; }

.section-body {
  display: none;
  margin: 2px 0 4px 10px;
  padding-left: 14px;
  border-left: 2px solid #e3e2df;
}
.section-body.open { display: block; }
.section-children { padding: 2px 0; }

/* Section children reuse .block styles; adjust the left indicator offset */
.section-body .block.active::before  { left: -24px; }
.section-body .block.selected::before { left: -24px; }

/* ===== ICON PICKER ===== */

.icon-picker {
  position: fixed;
  z-index: 1500;
  background: #fff;
  border: 1px solid #e3e2df;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 1px 4px rgba(0,0,0,0.06);
  width: 290px;
  padding: 10px;
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px;
  max-height: 250px;
  overflow-y: auto;
}

.icon-opt {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  border-radius: 5px;
  text-align: center;
  transition: background 0.08s;
}
.icon-opt:hover { background: #f0efe9; }

.icon-picker-footer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f0efe9;
  display: flex;
  justify-content: flex-end;
}

.icon-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: #9b9a97;
  padding: 3px 8px;
  border-radius: 4px;
}
.icon-remove-btn:hover { background: #f0efe9; color: #e03e3e; }

/* ===== COVER PICKER ===== */

.cover-picker {
  position: fixed;
  z-index: 1500;
  background: #fff;
  border: 1px solid #e3e2df;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 1px 4px rgba(0,0,0,0.06);
  width: 300px;
  padding: 12px;
}

.cover-picker-label {
  font-size: 11px;
  font-weight: 600;
  color: #9b9a97;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.cover-swatch-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}

.cover-swatch {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.cover-swatch:hover { transform: scale(1.12); }
.cover-swatch.active { border-color: #37352f; }

.cover-url-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.cover-url-input {
  flex: 1;
  border: 1px solid #e3e2df;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  color: #37352f;
}
.cover-url-input:focus { border-color: #3b82f6; }

.cover-url-submit {
  background: #37352f;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.cover-url-submit:hover { background: #2f2e28; }

.cover-picker-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #f0efe9;
  display: flex;
  justify-content: flex-end;
}

.cover-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: #9b9a97;
  padding: 3px 8px;
  border-radius: 4px;
}
.cover-remove-btn:hover { background: #f0efe9; color: #e03e3e; }

/* ===== BLOCK DELETE BUTTON (top-right) ===== */

.block-delete-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #b0aeaa;
  font-size: 14px;
  border: none;
  background: none;
  border-radius: 3px;
  padding: 0;
  line-height: 1;
  font-family: inherit;
  z-index: 10;
  transition: color 0.1s, background 0.1s;
}
.block.active > .block-delete-btn { display: flex; }
.block-delete-btn:hover { color: #e03e3e; background: rgba(224,62,62,0.08); }

/* Drag-and-drop states */
.block.dragging { opacity: 0.35; }
.block.drag-over-top    { box-shadow: 0 -2px 0 0 #3b82f6; }
.block.drag-over-bottom { box-shadow:  0 2px 0 0 #3b82f6; }

/* ===== COLUMNS BLOCK ===== */

.columns-wrap {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.column-sep {
  width: 1px;
  background: #e3e2df;
  align-self: stretch;
  flex-shrink: 0;
  margin: 4px 0;
}

.column-item {
  flex: 1;
  min-width: 0;
  padding: 0 10px;
}

.column-item:first-child { padding-left: 0; }
.column-item:last-child  { padding-right: 0; }

.column-header {
  display: flex;
  justify-content: flex-end;
  height: 18px;
  opacity: 0;
  transition: opacity 0.15s;
}

.column-item:hover .column-header { opacity: 1; }

.column-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #9b9a97;
  font-size: 15px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 3px;
  font-family: inherit;
  transition: color 0.1s, background 0.1s;
}

.column-del-btn:hover { color: #e03e3e; background: rgba(55,53,47,0.06); }

.column-children {
  min-height: 36px;
}

/* Column children reuse .block styles; left indicator fits tighter */
.column-children .block.active::before  { left: -10px; }
.column-children .block.selected::before { left: -10px; }

/* ===== FLOATING TEXT BLOCK TOOLBAR ===== */
#text-block-toolbar {
  position: fixed;
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 1px;
  padding: 3px;
  background: #fff;
  border: 1px solid #e3e2df;
  border-radius: 7px;
  box-shadow: 0 4px 16px rgba(55,53,47,0.12), 0 1px 4px rgba(55,53,47,0.06);
  pointer-events: auto;
}
#text-block-toolbar button {
  background: none;
  border: none;
  border-radius: 5px;
  padding: 0 8px;
  height: 26px;
  min-width: 28px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: #6b6a67;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
}
#text-block-toolbar button svg { pointer-events: none; display: block; flex-shrink: 0; }
#text-block-toolbar button:hover { background: #f0efe9; color: #37352f; }
#text-block-toolbar button.tbt-active {
  background: #37352f;
  color: #fff;
  font-weight: 700;
}
.tbt-sep { width: 1px; height: 14px; background: #e3e2df; margin: 0 2px; flex-shrink: 0; }

/* ===== ACTIVE BLOCK ASSISTANT ===== */
#ai-block-assistant {
  position: fixed;
  z-index: 9998;
  display: none;
  padding: 8px;
  background: rgba(255,255,255,0.98);
  border: 1px solid #d8d7d2;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(55,53,47,0.14), 0 2px 6px rgba(55,53,47,0.08);
  backdrop-filter: blur(8px);
}

.ai-assistant-main {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-assistant-badge {
  height: 26px;
  min-width: 28px;
  padding: 0 7px;
  border-radius: 6px;
  background: #0f7b6c;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.ai-assistant-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  border: 1px solid #e3e2df;
  border-radius: 6px;
  padding: 0 9px;
  font: inherit;
  font-size: 13px;
  color: #37352f;
  background: #f8f7f3;
  outline: none;
}

.ai-assistant-input:focus {
  border-color: #0f7b6c;
  background: #fff;
}

.ai-assistant-submit,
.ai-assistant-actions button {
  height: 30px;
  border: 1px solid #e3e2df;
  border-radius: 6px;
  background: #fff;
  color: #37352f;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 10px;
}

.ai-assistant-submit {
  background: #37352f;
  border-color: #37352f;
  color: #fff;
}

.ai-assistant-submit:hover { background: #2f2e28; }
.ai-assistant-actions button:hover { background: #f0efe9; }

#ai-block-assistant.ai-assistant-busy {
  opacity: 0.78;
}

#ai-block-assistant button:disabled,
#ai-block-assistant input[readonly] {
  cursor: wait;
}

.ai-assistant-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 7px;
}

.ai-assistant-status {
  min-height: 15px;
  margin-top: 4px;
  color: #0f7b6c;
  font-size: 11px;
}

/* ===== AI REVIEW MODAL ===== */
#ai-review-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}

.ai-review-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(55,53,47,0.32);
}

.ai-review-dialog {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 48px));
  background: #fff;
  border: 1px solid #d8d7d2;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(55,53,47,0.22), 0 4px 14px rgba(55,53,47,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #ebe9e4;
}

#ai-review-title {
  font-size: 15px;
  font-weight: 700;
  color: #37352f;
}

.ai-review-subtitle {
  margin-top: 2px;
  color: #9b9a97;
  font-size: 12px;
}

.ai-review-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #9b9a97;
  font-size: 18px;
  cursor: pointer;
}

.ai-review-close:hover { background: #f0efe9; color: #37352f; }

.ai-review-output {
  width: 100%;
  min-height: 220px;
  max-height: 420px;
  resize: vertical;
  border: none;
  outline: none;
  padding: 14px 16px;
  font: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: #37352f;
  background: #fff;
}

.ai-review-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #ebe9e4;
  background: #fafaf8;
}

.ai-review-cancel,
.ai-review-approve {
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ai-review-cancel {
  border: 1px solid #d8d7d2;
  background: #fff;
  color: #37352f;
}

.ai-review-cancel:hover { background: #f0efe9; }

.ai-review-approve {
  border: 1px solid #37352f;
  background: #37352f;
  color: #fff;
}

.ai-review-approve:hover { background: #2f2e28; }

.columns-footer {
  margin-top: 4px;
  display: flex;
  justify-content: center;
}

.columns-add-btn {
  background: none;
  border: 1px dashed #c4c3bf;
  color: #9b9a97;
  border-radius: 4px;
  padding: 2px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
}

.columns-add-btn:hover {
  background: #f1f0ef;
  color: #37352f;
  border-color: #9b9a97;
}

/* ===== MEDIA BLOCKS ===== */

.media-placeholder {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border: 1.5px dashed #d3d2cf;
  border-radius: 8px;
  background: #fafaf8;
  margin: 4px 0;
}

.media-ph-icon { font-size: 28px; flex-shrink: 0; line-height: 1; padding-top: 2px; }

.media-ph-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.media-ph-body p { font-size: 14px; color: #6b6a67; font-weight: 500; margin: 0; }
.media-ph-body small { font-size: 12px; color: #9b9a97; }

.media-ph-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.media-url-input {
  flex: 1;
  padding: 6px 10px;
  border: 1.5px solid #e3e2df;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  color: #37352f;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
.media-url-input:focus { border-color: #37352f; }

.media-submit-btn {
  padding: 6px 14px;
  background: #37352f;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s;
}
.media-submit-btn:hover { background: #2f2e28; }

.media-upload-label { display: inline-block; }
.media-upload-btn {
  display: inline-block;
  padding: 5px 12px;
  background: none;
  border: 1.5px solid #d3d2cf;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  color: #6b6a67;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.media-upload-btn:hover { border-color: #37352f; color: #37352f; background: #f0efe9; }

/* Image block */
.image-block { margin: 4px 0; }

.image-display {
  display: block;
  max-width: 100%;
  border-radius: 6px;
}

.image-block.img-error .image-display { display: none; }
.image-block.img-error::after {
  content: 'Image could not be loaded';
  display: block;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #e03e3e;
  font-size: 13px;
}

.media-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 2px;
}

.image-caption-input,
.embed-caption-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 12px;
  color: #9b9a97;
  background: transparent;
  padding: 0;
  min-width: 0;
}
.image-caption-input::placeholder,
.embed-caption-input::placeholder { color: #c4c3bf; }

.media-change-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  color: #b5b4b1;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.media-change-btn:hover { background: #f0efe9; color: #37352f; }

/* Embed block */
.embed-block { margin: 4px 0; }

.embed-frame {
  display: block;
  width: 100%;
  height: 400px;
  border: none;
  border-radius: 6px;
  background: #f7f6f3;
}

/* ===== FILE BLOCK ===== */

.file-block { margin: 4px 0; }

.file-image-preview,
.file-video-preview {
  display: block;
  max-width: 100%;
  border-radius: 6px 6px 0 0;
  margin-bottom: 0;
}

.file-video-preview { width: 100%; }

.file-audio-preview {
  display: block;
  width: 100%;
  margin: 4px 0;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f7f6f3;
  border: 1px solid #e3e2df;
  border-radius: 6px;
}

.file-image-preview + .file-card,
.file-video-preview + .file-card {
  border-radius: 0 0 6px 6px;
  border-top: none;
}

.file-card-icon { font-size: 20px; line-height: 1; flex-shrink: 0; }

.file-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-card-name {
  font-size: 13px;
  font-weight: 500;
  color: #37352f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-card-size {
  font-size: 11px;
  color: #9b9a97;
}

.file-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.file-download-btn {
  padding: 4px 10px;
  background: #37352f;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s;
}
.file-download-btn:hover { background: #2f2e28; }

.file-remove-btn {
  padding: 4px 10px;
  background: none;
  border: 1px solid #e3e2df;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
  color: #9b9a97;
  cursor: pointer;
  transition: all 0.12s;
}
.file-remove-btn:hover { border-color: #e03e3e; color: #e03e3e; background: #fff5f5; }

/* ===== SCROLLBAR ===== */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d3d2cf; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b5b4b1; }
