.law-editor-tools {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 3px;
  border: 1px solid #cbd8e1;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 4px 14px rgba(26, 55, 76, 0.07);
}

.law-color-palette { display: flex; gap: 4px; align-items: center; }
.law-editor-tools .law-color-palette button { width: 19px; min-width: 19px; height: 19px; padding: 0; border-radius: 50%; background: var(--swatch) !important; border: 2px solid transparent; }
.law-editor-tools .law-color-palette button[aria-pressed="true"] { border-color: #254a62; box-shadow: inset 0 0 0 2px #fff; }
.law-account-dialog { width: min(380px, calc(100vw - 32px)); padding: 24px; border: 1px solid #bacbd5; border-radius: 8px; color: #223e50; background: #f9fbfc; }
.law-account-dialog::backdrop { background: #142a4266; }
.law-account-dialog h2 { font-size: 20px; margin: 0 0 20px; }
.law-account-dialog label { display: grid; gap: 6px; margin: 12px 0; font-size: 14px; }
.law-account-dialog input { min-width: 0; width: 100%; padding: 9px; border: 1px solid #bacbd5; border-radius: 5px; }
.law-account-dialog form > div { display: flex; justify-content: end; gap: 8px; }
.law-account-dialog button { padding: 8px 12px; border: 1px solid #bacbd5; border-radius: 5px; background: #fff; }
.law-account-dialog button[type="submit"] { background: #246487; color: #fff; }
.law-account-dialog [data-auth-error] { color: #b33d38; font-size: 13px; }

.law-editor-tools button {
  min-width: 31px;
  height: 30px;
  display: inline-grid;
  grid-auto-flow: column;
  place-items: center;
  gap: 5px;
  padding: 0 8px;
  color: #405b70;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font: 650 12px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.law-editor-tools button:hover,
.law-editor-tools button:focus-visible {
  color: #164f72;
  border-color: #b8cbd8;
  background: #edf4f8;
  outline: none;
}

.law-editor-tools button[aria-pressed="true"] {
  color: #fff;
  border-color: #246487;
  background: #246487;
}

.law-editor-tools button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.law-editor-tools .law-editor-separator {
  width: 1px;
  height: 18px;
  margin: 0 1px;
  background: #d7e1e8;
}

.law-editor-tools .law-editor-icon {
  min-width: 14px;
  font-size: 14px;
  font-weight: 750;
  text-align: center;
}

.law-editor-tools .law-editor-highlight-icon {
  width: 15px;
  height: 10px;
  border-bottom: 4px solid #ffd84d;
}

.law-editor-tools .law-editor-underline-icon {
  text-decoration: underline 2px #2b77a4;
  text-underline-offset: 3px;
}

.law-editor-status {
  min-width: 52px;
  padding: 0 5px;
  color: #718493;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.law-editor-status.is-dirty {
  color: #a35b16;
}

.law-editor-status.is-saved {
  color: #267054;
}

.law-editor-active .original[contenteditable="true"] {
  min-height: 1.6em;
  border-radius: 3px;
  outline: 1px dashed rgba(43, 119, 164, 0.34);
  outline-offset: 3px;
  cursor: text;
}

.law-editor-active .original[contenteditable="true"]:focus {
  outline: 2px solid rgba(43, 119, 164, 0.72);
  background: rgba(225, 239, 247, 0.46);
}

.user-highlight {
  color: inherit;
  background: linear-gradient(transparent 20%, var(--user-mark, #ffe46b) 20%, var(--user-mark, #ffe46b) 92%, transparent 92%);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.user-underline {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, var(--user-mark, #2477a7) 65%, #14334a);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.user-annotation {
  color: inherit;
  background: rgba(115, 93, 176, 0.1);
  border-bottom: 2px dotted #7964b2;
  cursor: pointer;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.user-annotation:hover,
.user-annotation.is-current {
  background: rgba(115, 93, 176, 0.2);
  box-shadow: 0 0 0 2px rgba(115, 93, 176, 0.1);
}

.law-annotation-drawer {
  position: fixed;
  top: 74px;
  right: 14px;
  bottom: 14px;
  z-index: 120;
  width: min(360px, calc(100vw - 28px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  color: #263d50;
  border: 1px solid #c7d5df;
  border-radius: 9px;
  background: rgba(250, 252, 253, 0.98);
  box-shadow: 0 20px 54px rgba(20, 42, 59, 0.24);
  backdrop-filter: blur(16px);
}

.law-annotation-drawer[hidden] {
  display: none;
}

.law-annotation-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid #dae3e9;
}

.law-annotation-head strong {
  font-size: 14px;
}

.law-annotation-head span {
  margin-left: 6px;
  color: #718493;
  font-size: 11px;
}

.law-annotation-head button,
.law-annotation-item button {
  color: #607789;
  border: 1px solid #d2dde4;
  border-radius: 5px;
  background: #fff;
}

.law-annotation-head button {
  width: 30px;
  height: 30px;
  padding: 0;
}

.law-annotation-list {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  overflow: auto;
}

.law-annotation-empty {
  margin: auto;
  color: #8293a0;
  font-size: 13px;
}

.law-annotation-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 11px;
  border: 1px solid #dce5eb;
  border-left: 3px solid #7964b2;
  border-radius: 6px;
  background: #fff;
}

.law-annotation-item > div {
  min-width: 0;
  cursor: pointer;
}

.law-annotation-item q {
  display: block;
  overflow: hidden;
  color: #6b7d8a;
  font-size: 11px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.law-annotation-item p {
  margin: 5px 0 0;
  color: #283f51;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.law-annotation-item button {
  align-self: start;
  padding: 5px 7px;
  font-size: 11px;
}

.law-editor-dialog {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(13, 27, 39, 0.42);
  backdrop-filter: blur(5px);
}

.law-editor-dialog[hidden] {
  display: none;
}

.law-editor-dialog form {
  width: min(440px, 100%);
  padding: 18px;
  border: 1px solid #c8d6df;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 22px 64px rgba(12, 30, 44, 0.3);
}

.law-editor-dialog h2 {
  margin: 0 0 5px;
  color: #233b4e;
  font-size: 17px;
}

.law-editor-dialog .law-editor-quote {
  margin: 0 0 12px;
  overflow: hidden;
  color: #718493;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.law-editor-dialog textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  padding: 10px 11px;
  color: #20384a;
  border: 1px solid #bdced9;
  border-radius: 6px;
  background: #fbfcfd;
  font: 14px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.law-editor-dialog textarea:focus {
  border-color: #2d7ba6;
  outline: 2px solid rgba(45, 123, 166, 0.14);
}

.law-editor-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 13px;
}

.law-editor-dialog-actions button {
  min-width: 72px;
  padding: 8px 12px;
  border: 1px solid #c6d4dd;
  border-radius: 6px;
  background: #fff;
  color: #496275;
}

.law-editor-dialog-actions button[type="submit"] {
  color: #fff;
  border-color: #246487;
  background: #246487;
}

.law-editor-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 240;
  max-width: min(420px, calc(100vw - 28px));
  padding: 9px 13px;
  color: #fff;
  border-radius: 6px;
  background: rgba(26, 49, 66, 0.94);
  box-shadow: 0 10px 28px rgba(13, 30, 43, 0.24);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.law-editor-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 800px) {
  .law-editor-tools {
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
  }

  .law-editor-tools button {
    flex: 0 0 auto;
  }

  .law-editor-tools .law-editor-label,
  .law-editor-status {
    display: none;
  }

  .law-annotation-drawer {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    height: min(56vh, 520px);
  }
}

@media print {
  .law-editor-tools,
  .law-annotation-drawer,
  .law-editor-dialog,
  .law-editor-toast {
    display: none !important;
  }
}
