* {
  box-sizing: border-box;
}

html,
input,
textarea,
button {
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-size: 16px;
  font-family: system-ui, sans-serif;
  font-weight: 400;
}

html {
  min-height: 100vh;
}

body {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  color: #1b1b1b;
  line-height: 1.6;
}

h1 {
  margin: 2rem 0;
  font-size: 1.75rem;
}

body > p {
  margin: 2rem 0;
}

h2 {
  font-size: 1.3rem;
  margin: 0 0 1rem 0;
  border-block-end: 1px solid #ddd;
  padding-block-end: 1rem;
}

h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

code,
kbd {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9em;
  background: #f0f0f0;
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.demo-section code {
  background: white;
}

kbd {
  border: 1px solid #ccc;
  box-shadow: 0 1px 0 #bbb;
}

a {
  color: #0067b8;
}

.warning {
  background: #fff3cd;
  border: 1px solid #ffecb5;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  color: #664d03;
}

.demo-section {
  margin-block-end: 2rem;
  background: #eee;
  padding: 1rem;
  border-radius: 6px;
}

.field-wrapper {
  position: relative;
}

textarea,
input[type="text"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #bbb;
  border-radius: 6px;
  font-size: 1rem;
  resize: vertical;
  transition: border-color 0.15s;
}

textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: #0067b8;
  box-shadow: 0 0 0 2px rgba(0, 103, 184, 0.2);
}

/* Mention popup */
.popup {
  position: fixed;
  margin: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 150px;
}

.popup ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.popup button {
  display: block;
  width: 100%;
  text-align: start;
  border-radius: 0;
  margin: 0;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.popup button:hover {
  background: #e8f0fe;
}

/* Search highlight (CSS Custom Highlight API) */
::highlight(search-match) {
  background-color: rgba(255, 200, 0, 0.4);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.search-bar label {
  font-weight: 600;
  white-space: nowrap;
}

.search-bar input {
  flex: 1;
}

/* Live range highlight */
::highlight(tracked-word) {
  background-color: rgba(0, 120, 212, 0.3);
}

/* Disconnect demo highlight */
::highlight(disconnect-demo) {
  background-color: rgba(0, 180, 80, 0.3);
}

.button-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

button {
  padding: 0.45rem 1rem;
  border: 1px solid #bbb;
  border-radius: 6px;
  background: #f5f5f5;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}

button:hover {
  background: #e0e0e0;
}

button:active {
  background: #d0d0d0;
}

.info-text {
  font-size: 0.9rem;
  color: #555;
  min-height: 1.4rem;
}

@media (prefers-color-scheme: dark) {
  body {
    background: #1e1e1e;
    color: #e0e0e0;
  }

  h2 {
    border-bottom-color: #444;
  }

  code,
  kbd {
    background: #2d2d2d;
    color: #d4d4d4;
  }

  kbd {
    border-color: #555;
    box-shadow: 0 1px 0 #444;
  }

  a {
    color: #4fc3f7;
  }

  .warning {
    background: #3e3219;
    border-color: #5c4a1c;
    color: #ffd54f;
  }

  textarea,
  input[type="text"] {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #555;
  }

  textarea:focus,
  input[type="text"]:focus {
    border-color: #4fc3f7;
    box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.25);
  }

  .popup {
    background: #2d2d2d;
    border-color: #555;
    color: #e0e0e0;
  }

  .popup li:hover {
    background: #3a3a3a;
  }

  button {
    background: #333;
    color: #e0e0e0;
    border-color: #555;
  }

  button:hover {
    background: #444;
  }

  button:active {
    background: #555;
  }

  .info-text {
    color: #aaa;
  }

  ::highlight(search-match) {
    background-color: rgba(255, 200, 0, 0.45);
  }

  ::highlight(tracked-word) {
    background-color: rgba(79, 195, 247, 0.35);
  }

  ::highlight(disconnect-demo) {
    background-color: rgba(0, 200, 100, 0.35);
  }

}