/* Editor inputs */
#post-title {
  padding: 12px 14px;
}

/* Editor container - wraps toolbar + textarea */
.editor-container {
  border: 1px solid var(--lm-border-color);
  border-radius: 8px;
  overflow: hidden;
}

body[data-theme="dark"] .editor-container {
  border-color: var(--dm-border-color);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  background: var(--lm-base-color);
  border-bottom: 1px solid var(--lm-border-color);
}

body[data-theme="dark"] .editor-toolbar {
  background: var(--dm-base-color);
  border-bottom-color: var(--dm-border-color);
}

.editor-textarea {
  width: 100%;
  border: none;
  border-radius: 0;
  padding: 12px 14px 100px 14px;
  resize: none;
  outline: none;
  background: var(--lm-input-bg);
  color: var(--lm-text-color);
  font-size: 1.4rem;
  line-height: 1.5;
  height: calc(100dvh - 313px) !important;
  min-height: 200px;
}

body[data-theme="dark"] .editor-textarea {
  background: var(--dm-input-bg);
  color: var(--dm-text-color);
}

.editor-textarea:focus {
  outline: none;
  box-shadow: none;
}

.editor-footer {
  padding: 6px 14px;
  border-top: 1px solid var(--lm-border-color);
  background: var(--lm-base-color);
}

body[data-theme="dark"] .editor-footer {
  border-top-color: var(--dm-border-color);
  background: var(--dm-base-color);
}

/* Fallback for browsers without dvh support */
@supports not (height: 100dvh) {
  .editor-textarea {
    height: calc(100vh - 313px) !important;
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .editor-textarea {
    height: calc(100dvh - 333px) !important;
  }
  @supports not (height: 100dvh) {
    .editor-textarea {
      height: calc(100vh - 333px) !important;
    }
  }
}

/* Prevent content container from scrolling in editor view */
#item-content:has(#post-content) {
  overflow: hidden !important;
}

/* Formatting Help Modal */
.formatting-help-body {
  max-height: 60vh;
  overflow-y: auto;
  padding: 0 !important;
}

#formatting-help-modal .modal-body {
  padding: 15px;
}

.formatting-search-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--lm-border-color);
  border-radius: 8px;
  background: var(--lm-input-bg);
}

.formatting-search-wrapper i {
  color: var(--lm-text-muted-color);
  font-size: 1.4rem;
}

.formatting-search-wrapper input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 1.4rem;
  width: 100%;
  color: inherit;
}

.formatting-search-wrapper input::placeholder {
  color: var(--lm-text-muted-color);
}

body[data-theme="dark"] .formatting-search-wrapper {
  border-color: var(--dm-border-color);
  background: var(--dm-input-bg);
}

body[data-theme="dark"] .formatting-search-wrapper i,
body[data-theme="dark"] .formatting-search-wrapper input::placeholder {
  color: var(--dm-text-muted-color);
}

.formatting-section {
  margin-bottom: 20px;
}

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

.formatting-section.hidden {
  display: none;
}

.formatting-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--lm-text-muted-color);
  margin-bottom: 8px;
  padding-left: 4px;
}

.formatting-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.formatting-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.formatting-item:hover,
.formatting-item.selected {
  background-color: rgba(0, 0, 0, 0.05);
}

.formatting-item.selected {
  background-color: rgba(0, 0, 0, 0.08);
}

.formatting-item.hidden {
  display: none;
}

.formatting-item-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  color: var(--lm-text-muted-color);
  font-size: 1.4rem;
}

.formatting-item-content {
  flex: 1;
  min-width: 0;
}

.formatting-item-title {
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--lm-text-color);
}

.formatting-item-syntax {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
  font-size: 1.15rem;
  color: var(--lm-text-muted-color);
  margin-top: 1px;
}

.formatting-tips {
  margin: 0;
  padding-left: 18px;
  font-size: 1.25rem;
  color: var(--lm-text-muted-color);
}

.formatting-tips li {
  margin-bottom: 6px;
}

.formatting-tips li:last-child {
  margin-bottom: 0;
}

.formatting-tips li.hidden {
  display: none;
}

.formatting-tips code {
  background-color: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 1.1rem;
}

/* Dark mode */
body[data-theme="dark"] .formatting-section-title {
  color: var(--dm-text-muted-color);
}

body[data-theme="dark"] .formatting-item:hover,
body[data-theme="dark"] .formatting-item.selected {
  background-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .formatting-item.selected {
  background-color: rgba(255, 255, 255, 0.12);
}

body[data-theme="dark"] .formatting-item-icon {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--dm-text-muted-color);
}

body[data-theme="dark"] .formatting-item-title {
  color: var(--dm-text-color);
}

body[data-theme="dark"] .formatting-item-syntax {
  color: var(--dm-text-muted-color);
}

body[data-theme="dark"] .formatting-tips {
  color: var(--dm-text-muted-color);
}

body[data-theme="dark"] .formatting-tips code {
  background-color: rgba(255, 255, 255, 0.08);
}

/* tidScript elements in public pages */
.tidscript-hr {
  border: none;
  border-top: 1px solid var(--lm-border-color);
  margin: 30px 0;
}

.tidscript-spacer {
  height: 40px;
}

.tidscript-feed-empty {
  padding: 20px 0;
  text-align: center;
}

body[data-theme="dark"] .tidscript-hr {
  border-top-color: var(--dm-border-color);
}

/* Global search modal */
#global-search-modal .modal-content {
  overflow: hidden;
}

.global-search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}

.global-search-input-wrapper i {
  color: var(--lm-text-muted-color);
  font-size: 1.5rem;
  flex-shrink: 0;
}

#global-search-input {
  border: none;
  background: transparent;
  box-shadow: none;
  font-size: 1.5rem;
  padding: 0;
  width: 100%;
  outline: none;
  color: inherit;
}

#global-search-input::placeholder {
  opacity: 0.5;
}

#global-search-modal .modal-body {
  max-height: 400px;
  overflow-y: auto;
  border-top: 1px solid var(--lm-border-color);
}

#global-search-results {
  padding: 8px;
}

/* Dark mode */
body[data-theme="dark"] .global-search-input-wrapper i {
  color: var(--dm-text-muted-color);
}

body[data-theme="dark"] #global-search-modal .modal-body {
  border-top-color: var(--dm-border-color);
}

a.search-result-item,
a.search-result-item:hover,
a.search-result-item:visited,
a.search-result-item:active {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--lm-text-color);
  transition: background-color 0.15s ease;
  cursor: pointer;
}

body[data-theme="dark"] a.search-result-item,
body[data-theme="dark"] a.search-result-item:hover,
body[data-theme="dark"] a.search-result-item:visited,
body[data-theme="dark"] a.search-result-item:active {
  color: var(--dm-text-color);
}

.search-result-item:hover,
.search-result-item.selected {
  background-color: rgba(0, 0, 0, 0.05);
}

.search-result-item.selected {
  background-color: rgba(0, 0, 0, 0.08);
}

.search-result-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  color: var(--lm-text-muted-color);
  font-size: 1.4rem;
}

.search-result-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.search-result-title {
  font-weight: 600;
  font-size: 1.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-excerpt {
  font-size: 1.2rem;
  color: var(--lm-text-muted-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.search-result-status {
  flex-shrink: 0;
  font-size: 1.1rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.search-result-status.published {
  background-color: rgba(40, 167, 69, 0.12);
  color: #28a745;
}

.search-result-status.draft {
  background-color: rgba(0, 0, 0, 0.06);
  color: var(--lm-text-muted-color);
}

body[data-theme="dark"] .search-result-item:hover,
body[data-theme="dark"] .search-result-item.selected {
  background-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .search-result-item.selected {
  background-color: rgba(255, 255, 255, 0.12);
}

body[data-theme="dark"] .search-result-icon {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--dm-text-muted-color);
}

body[data-theme="dark"] .search-result-excerpt {
  color: var(--dm-text-muted-color);
}

body[data-theme="dark"] .search-result-status.published {
  background-color: rgba(40, 167, 69, 0.2);
}

body[data-theme="dark"] .search-result-status.draft {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--dm-text-muted-color);
}

/* Image Picker Modal */
#image-picker-modal .modal-body {
  padding: 15px;
}

.image-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 5px;
  margin: -5px;
}

.image-picker-upload-tile {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px dashed var(--lm-border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(0, 0, 0, 0.02);
}

.image-picker-upload-tile i {
  font-size: 2.4rem;
  color: var(--lm-text-muted-color);
  transition: all 0.2s ease;
}

.image-picker-upload-tile:hover {
  border-color: var(--primary-color);
  background: rgba(24, 144, 255, 0.05);
  transform: scale(1.02);
}

.image-picker-upload-tile:hover i {
  color: var(--primary-color);
}

.image-picker-item {
  aspect-ratio: 1;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.image-picker-item:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-picker-item.selected {
  border-color: var(--primary-color);
}

.image-picker-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--lm-text-muted-color);
  font-size: 1.3rem;
}

/* Style bar with toggle pills */
.image-picker-style-bar {
  display: flex;
  gap: 8px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--lm-border-color);
}

.image-picker-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.image-picker-toggle:hover {
  background: rgba(0, 0, 0, 0.07);
}

.image-picker-toggle input {
  display: none;
}

.image-picker-toggle-label {
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--lm-text-muted-color);
  transition: color 0.2s ease;
  position: relative;
  padding-left: 20px;
}

.image-picker-toggle-label::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 2px solid var(--lm-border-color);
  background: transparent;
  transition: all 0.2s ease;
}

.image-picker-toggle input:checked + .image-picker-toggle-label {
  color: var(--primary-color);
}

.image-picker-toggle input:checked + .image-picker-toggle-label::before {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.image-picker-toggle input:checked + .image-picker-toggle-label::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-60%) rotate(45deg);
  width: 4px;
  height: 7px;
  border: solid white;
  border-width: 0 2px 2px 0;
}

/* Dark mode */
body[data-theme="dark"] .image-picker-upload-tile {
  border-color: var(--dm-border-color);
  background: rgba(255, 255, 255, 0.03);
}

body[data-theme="dark"] .image-picker-upload-tile i {
  color: var(--dm-text-muted-color);
}

body[data-theme="dark"] .image-picker-upload-tile:hover {
  background: rgba(24, 144, 255, 0.1);
}

body[data-theme="dark"] .image-picker-item {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

body[data-theme="dark"] .image-picker-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

body[data-theme="dark"] .image-picker-empty {
  color: var(--dm-text-muted-color);
}

body[data-theme="dark"] .image-picker-style-bar {
  border-top-color: var(--dm-border-color);
}

body[data-theme="dark"] .image-picker-toggle {
  background: rgba(255, 255, 255, 0.06);
}

body[data-theme="dark"] .image-picker-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .image-picker-toggle-label {
  color: var(--dm-text-muted-color);
}

body[data-theme="dark"] .image-picker-toggle-label::before {
  border-color: var(--dm-border-color);
}