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

body {
  font-family: sans-serif;
  margin: 0;
  padding: 0;
  background: #f2f2f2;
  overflow-x: hidden;
}

.toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  padding: 10px;
  background: #333;
  color: white;
  gap: 5px;
  z-index: 1000;
}

.toolbar button,
.toolbar select,
.toolbar input[type="color"] {
  margin: 2px;
  padding: 5px;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #fff;
  min-width: 260px;
  z-index: 1001;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.dropdown-content label,
.dropdown-content button {
  color: black;
  background: white;
  padding: 6px 10px;
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  cursor: pointer;
}

.dropdown-content label:hover,
.dropdown-content button:hover {
  background-color: #eee;
}

.dropdown:hover .dropdown-content {
  display: block;
}

#editor {
  background: white;
  padding: 15px;
  min-height: 500px;
  outline: none;
  margin: 120px auto 20px;
  border: 1px solid #ccc;
  max-width: 800px;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: var(--editor-width, 800px);
}

.emoji-picker {
  position: absolute;
  background: white;
  border: 1px solid #ccc;
  padding: 5px;
  display: none;
  z-index: 1000;
}

.emoji-picker span {
  cursor: pointer;
  font-size: 20px;
  padding: 3px;
}

img {
  max-width: 100%;
  height: auto;
}

:root {
  --editor-width: 800px;
}

#ruler {
  position: fixed;
  top: 50px; /* высота тулбара */
  left: 0;
  right: 0;
  height: 30px;
  background: #222;
  z-index: 999;
  display: flex;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}

#ruler-inner {
  position: relative;
  width: 100%;
  max-width: var(--editor-width, 800px);
  height: 100%;
}
.tick {
  pointer-events: none;
}


#ruler .tick {
  position: absolute;
  width: 1px;
  background: #ccc;
  height: 10px;
  top: 0;
}

.tick.mm {
  height: 5px;
  background: #666;
  width: 1px;
}


#ruler .tick::after {
  content: attr(data-cm);
  position: absolute;
  top: 10px;
  left: -5px;
  font-size: 10px;
  color: #eee;
}


#ruler::-webkit-scrollbar {
  display: none;
}
#ruler {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#resizeSlider {
  position: fixed;
  top: 85px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  z-index: 1001;
  background: transparent;
}


body.dark-theme {
  background: #1c1c1c;
  color: #e0e0e0;
}

body.dark-theme #editor {
  background: #2a2a2a;
  color: #f0f0f0;
  border-color: #555;
}

body.dark-theme .toolbar {
  background: #222;
  color: #fff;
}

body.dark-theme .toolbar button,
body.dark-theme .toolbar select,
body.dark-theme .toolbar input[type="color"] {
  background: #444;
  color: #fff;
  border: 1px solid #666;
}

body.dark-theme .dropdown-content {
  background-color: #333;
  color: #eee;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

body.dark-theme .dropdown-content label,
body.dark-theme .dropdown-content button {
  background: #333;
  color: #eee;
}

body.dark-theme .dropdown-content label:hover,
body.dark-theme .dropdown-content button:hover {
  background-color: #444;
}

body.dark-theme .emoji-picker {
  background: #333;
  border-color: #666;
}

body.dark-theme .emoji-picker span {
  color: #fff;
}

body.dark-theme #ruler {
  background: #1a1a1a;
}
body.dark-theme #ruler .tick {
  background: #666;
}
body.dark-theme .tick.mm {
  background: #444;
}
body.dark-theme #ruler .tick::after {
  color: #aaa;
}

body.dark-theme #resizeSlider input[type="range"] {
  background-color: #444;
}