body {
  font-family: Arial, sans-serif;
  background-color: #fcfcfc;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 600px;
}

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

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 200px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 100;
  border-radius: 4px;
  right: 0;
}

.dropdown-content a {
  color: #333;
  padding: 10px 12px;
  text-decoration: none;
  display: block;
  font-size: 0.9em;
}

.dropdown-content a:hover {
  background-color: #f1f1f1;
}

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

body.dark-mode .dropdown-content {
  background-color: #333;
}

body.dark-mode .dropdown-content a {
  color: #e0e0e0;
}

body.dark-mode .dropdown-content a:hover {
  background-color: #444;
}

@media (max-width: 400px) {
  .dropdown-content {
    min-width: 150px;
    right: -50px;
  }
}

#top {
  background-color: #f4f4f4;
  padding: 5px 10px;
  display: flex;
  align-items: center;
}

#top h4.title {
  margin: 0;
  margin-right: 15px;
  font-size: 1.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  margin-left: auto;
  gap: 8px;
}

.control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 1em;
  color: #333;
  background-color: #e9e9e9;
  border: 1px solid #ccc;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
  text-decoration: none;
}

.control:hover {
  background-color: #d5d5d5;
}

.toggle input {
  margin: 0;
  margin-right: 3px;
  margin-left: 0;
  vertical-align: middle;
  width: 12px;
  height: 12px;
}

.content {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0 5px;
}

.split.right {
  width: 99%;
  max-width: 600px;
}

.bed-input {
  width: 100%;
  height: 100%;
  padding: 10px;
  box-sizing: border-box;
  border: none;
  outline: none;
  resize: none;
  z-index: 2;
  white-space: nowrap;
  overflow: scroll;
}

.bed-container {
  display: inline-block;
  position: relative;
  overflow: hidden;
  width: 100%;
  text-size-adjust: none;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: none;
  height: calc(100vh - 50px);
}

.bed-backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
}

.bed-highlights {
  white-space: pre;
  color: #129dff;
  padding: 10px;
  overflow: hidden;
}

.error-text {
  color: #ff3333;
}

.bed-content {
  background: none;
  border: none;
  font-family: monospace;
  font-size: 1.2em;
}

.ta {
  height: calc(100vh - 50px);
}

.sum-value {
  text-decoration: underline;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
  background-color: #fefefe;
  margin: 15% auto;
  padding: 0;
  border: 1px solid #888;
  width: 80%;
  max-width: 300px;
  border-radius: 5px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.modal-header {
  padding: 10px 15px;
  background-color: #f4f4f4;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 5px 5px 0 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2em;
}

.modal-body {
  padding: 15px;
}

.close {
  color: #aaa;
  font-size: 2em;
  font-weight: bold;
  cursor: pointer;
  margin-left: auto;
}

.close:hover,
.close:focus {
  color: black;
  text-decoration: none;
}

.setting-item {
  margin-bottom: 15px;
}

.setting-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  cursor: pointer;
  gap: 5px;
}

.setting-label input[type="checkbox"] {
  margin-right: 10px;
}

@media (max-width: 400px) {
  #top h4.title {
    font-size: 0.9em;
    margin-right: 2px;
    max-width: 80px;
  }

  #top {
    padding: 2px 4px;
  }

  .controls {
    gap: 2px;
  }

  .control {
    padding: 2px 4px;
  }
}

body.dark-mode {
  background-color: #222;
  color: #e0e0e0;
}

body.dark-mode #top {
  background-color: #333;
  color: #e0e0e0;
}

body.dark-mode .control {
  background-color: #444;
  color: #e0e0e0;
  border-color: #555;
}

body.dark-mode .control:hover {
  background-color: #555;
}

body.dark-mode .bed-container {
  border-color: #555;
}

body.dark-mode .bed-input, 
body.dark-mode .bed-highlights {
  color: #e0e0e0;
}

body.dark-mode .bed-highlights {
  color: #4db8ff;
}

body.dark-mode .error-text {
  color: #ff6666;
}

body.dark-mode .modal-content {
  background-color: #333;
  color: #e0e0e0;
  border-color: #555;
}

body.dark-mode .modal-header {
  background-color: #444;
  border-color: #555;
}

body.dark-mode .close {
  color: #ccc;
}

body.dark-mode .close:hover,
body.dark-mode .close:focus {
  color: white;
}

body.dark-mode .sum-value {
  color: #4db8ff;
}

.precision-control {
  display: flex;
  align-items: center;
  margin-left: 5px;
  gap: 5px;
}

.precision-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 1.2em;
  font-weight: bold;
  background-color: #e9e9e9;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.precision-btn:hover {
  background-color: #d5d5d5;
  transform: scale(1.05);
}

.precision-btn:active {
  background-color: #c5c5c5;
  transform: scale(0.95);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#precision {
  width: 50px;
  height: 30px;
  text-align: center;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0 5px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (max-width: 400px) {
  .precision-control {
    margin-top: 8px;
    width: 100%;
    justify-content: center;
    gap: 10px;
  }
  
  #precision {
    flex: 0 0 60px;
    min-width: 60px;
  }
  
  .precision-btn {
    min-width: 40px;
    min-height: 40px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  }
}

body.dark-mode .precision-btn {
  background-color: #444;
  color: #e0e0e0;
  border-color: #555;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.dark-mode .precision-btn:hover {
  background-color: #555;
}

body.dark-mode .precision-btn:active {
  background-color: #666;
}

body.dark-mode #precision {
  background-color: #333;
  color: #e0e0e0;
  border-color: #555;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.full-width-mode {
  width: 100%;
  max-width: 100%;
}

body.full-width-mode .split.right {
  width: 100%;
  max-width: 100%;
}

body.full-width-mode .bed-input,
body.full-width-mode .bed-highlights {
  width: 100%;
}

/* Mobile Share Link styles */
.mobile-share {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.mobile-share::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 5px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='18' cy='5' r='3'%3E%3C/circle%3E%3Ccircle cx='6' cy='12' r='3'%3E%3C/circle%3E%3Ccircle cx='18' cy='19' r='3'%3E%3C/circle%3E%3Cline x1='8.59' y1='13.51' x2='15.42' y2='17.49'%3E%3C/line%3E%3Cline x1='15.41' y1='6.51' x2='8.59' y2='10.49'%3E%3C/line%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  vertical-align: middle;
}

body.dark-mode .mobile-share::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e0e0e0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='18' cy='5' r='3'%3E%3C/circle%3E%3Ccircle cx='6' cy='12' r='3'%3E%3C/circle%3E%3Ccircle cx='18' cy='19' r='3'%3E%3C/circle%3E%3Cline x1='8.59' y1='13.51' x2='15.42' y2='17.49'%3E%3C/line%3E%3Cline x1='15.41' y1='6.51' x2='8.59' y2='10.49'%3E%3C/line%3E%3C/svg%3E");
}

/* Mobile-specific enhancements */
@media (max-width: 500px) {
  .mobile-share {
    font-weight: bold;
    background-color: rgba(19, 157, 255, 0.1);
  }

  body.dark-mode .mobile-share {
    background-color: rgba(77, 184, 255, 0.15);
  }

  /* Improve dropdown usability on mobile */
  .dropdown-content {
    padding: 5px 0;
  }

  .dropdown-content a {
    padding: 15px 12px;
  }
}