/* Claude 风格工作台 · 弹层、菜单、提示与内部页面
   来源：dsh-claude-style@1e7acc5b 的 shared/popover.css、features/settings、
   features/account 与 docs/STYLE.md“Popovers / 形状 / 动效”。 */

/* ---------- 对话框 ---------- */
dialog.modal {
  width: min(720px, calc(100vw / var(--zoom) - 40px));
  max-width: none;
  max-height: min(86dvh / var(--zoom), 900px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-card);
  background: var(--overlay);
  color: var(--ink);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
  transform-origin: center;
}
dialog.modal[data-wide="true"] {
  width: min(960px, calc(100vw / var(--zoom) - 40px));
}
dialog.modal[open] {
  animation: dialog-in var(--dur-open) var(--ease-settle);
}
dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.32);
  animation: backdrop-in var(--dur-surface) var(--ease-standard);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 12px 10px 20px;
  border-bottom: 0.5px solid var(--divider);
}
.modal-head h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-head .spacer {
  flex: 1;
}
.modal-head .icon-btn {
  width: 30px;
  height: 30px;
}
.modal-body {
  max-height: calc(86dvh / var(--zoom) - 120px);
  overflow-y: auto;
  padding: 18px 20px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.7;
  scrollbar-gutter: stable;
}
.modal-body p {
  margin: 0 0 10px;
}
.modal-body p:last-child {
  margin-bottom: 0;
}
.modal-body h3 {
  font-size: 15px;
  margin: 16px 0 6px;
}
.modal-body label {
  display: block;
  margin: 10px 0 5px;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
}
.modal-body input:not([type="checkbox"]):not([type="radio"]),
.modal-body textarea {
  width: 100%;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-2);
  background: var(--inset);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}
.modal-body textarea {
  min-height: 110px;
  resize: vertical;
}
.modal-body :is(input, textarea):focus {
  border-color: var(--accent);
}
.modal-body .reader-search input[type="search"] {
  width: 100%;
}
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding: 12px 16px;
  border-top: 0.5px solid var(--divider);
  background: var(--overlay);
}
.modal-actions .btn {
  min-width: 64px;
}
.modal-body .tool-card {
  padding: 10px 0;
  border-bottom: 0.5px solid var(--divider);
}
.modal-body .tool-card:last-child {
  border-bottom: 0;
}
.modal-body .tool-card strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}
.modal-body .tool-card small {
  display: block;
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 10.5px;
}
.modal-body .tool-card .row {
  margin-top: 8px;
}
.modal-body .tool-card .row button {
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-row);
  border: 0.5px solid var(--border-1);
  background: var(--canvas);
  color: var(--ink-2);
  font-size: 11px;
}
.modal-body .tool-card .row button:hover {
  background: var(--hover);
  color: var(--ink);
}
.modal-body .tool-card .row button.danger {
  color: var(--danger);
}
.modal-body .aw-issue {
  padding: 10px 0;
}
.modal-body .aw-issue p {
  margin: 5px 0 0;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.6;
}
.modal-body .aw-issue p b {
  display: inline-block;
  min-width: 36px;
  color: var(--ink-3);
  font-weight: 500;
}
.modal-body .review-summary {
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 0.5px solid var(--border-1);
  border-radius: var(--radius-2);
  background: var(--canvas);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.65;
}
.modal-body .login-error {
  min-height: 18px;
  margin-top: 6px;
  color: var(--danger);
  font-size: 11px;
}
.modal-body .login-note {
  color: var(--ink-3);
  font-size: 12px;
}
.modal-body .radio-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.modal-body .radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  margin: 0;
  padding: 0 10px;
  border: 0.5px solid var(--border-1);
  border-radius: var(--radius-2);
  font-size: 12px;
  cursor: pointer;
}
.modal-body .radio-row label:has(input:checked) {
  border-color: var(--ink);
  background: var(--hover);
}
.modal-body .radio-row input {
  accent-color: var(--accent);
}

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: var(--layer-toast);
  max-width: min(560px, calc(100vw / var(--zoom) - 32px));
  padding: 9px 14px;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-2);
  background: var(--overlay);
  color: var(--ink);
  box-shadow: var(--shadow-popover);
  font-size: 12px;
  line-height: 1.55;
  animation: toast-in var(--dur-surface) var(--ease-settle);
}
.toast[data-kind="error"] {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

/* ---------- 主题菜单 ---------- */
.theme-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: var(--layer-float);
  width: 190px;
  padding: 5px;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-popover);
  background: var(--overlay);
  box-shadow: var(--shadow-popover);
  animation: popover-in var(--dur-surface) var(--ease-settle);
}
.theme-menu .popover-title {
  padding: 5px 8px 4px;
  color: var(--ink-3);
  font-size: 11px;
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-row);
  color: var(--ink);
  font-size: 12px;
  text-align: left;
}
.theme-option:hover {
  background: var(--hover);
}
.theme-option .swatch {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border-2);
}
.theme-option[aria-checked="true"] .tick {
  margin-left: auto;
  color: var(--accent);
}
.theme-option .tick {
  width: 14px;
  height: 14px;
  margin-left: auto;
}
.theme-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--border-1);
}
.theme-menu .zoom-hint {
  margin-left: 6px;
  color: var(--ink-4, var(--ink-3));
  font-size: 10.5px;
}
.zoom-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 3px 3px;
}
.zoom-btn,
.zoom-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border-radius: var(--radius-row);
  color: var(--ink);
  transition: background-color var(--timing-feedback), color var(--timing-feedback);
}
.zoom-btn {
  width: 34px;
  flex: none;
  color: var(--ink-2);
}
.zoom-btn .aw-svg {
  width: 14px;
  height: 14px;
}
.zoom-value {
  flex: 1;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.zoom-btn:hover:not(:disabled),
.zoom-value:hover:not(:disabled) {
  background: var(--hover);
  color: var(--ink);
}
.zoom-btn:disabled {
  color: var(--ink-4, var(--ink-3));
  opacity: 0.45;
  cursor: default;
}
.zoom-value:disabled {
  cursor: default;
}

/* ---------- 阅读器（reader.mjs） ---------- */
.reader-meta {
  margin: 0 0 10px;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.reader-search {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
}
.modal-body .reader-search input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-2);
  background: var(--inset);
  color: var(--ink);
  font-size: 12px;
}
.reader-search button,
.reader-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: none;
  min-height: 30px;
  padding: 4px 9px;
  border: 0.5px solid var(--border-1);
  border-radius: var(--radius-2);
  background: var(--canvas);
  color: var(--ink-2);
  font-size: 11px;
  transition: background-color var(--timing-feedback), border-color var(--timing-feedback);
}
.reader-search button:hover,
.reader-toolbar button:hover {
  background: var(--hover);
  border-color: var(--border-2);
  color: var(--ink);
}
.reader-search button:disabled,
.reader-toolbar button:disabled {
  opacity: 0.4;
}
.reader-window {
  position: relative;
  height: min(52dvh / var(--zoom), 540px);
  min-height: 220px;
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-2);
  background: var(--canvas);
  contain: strict;
}
.reader-window:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}
.reader-window pre {
  margin: 0;
  padding: 14px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-code);
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink);
  tab-size: 4;
}
.reader-window mark {
  padding: 0 2px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--ink);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
}
.reader-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin: 10px 0 8px;
}
.reader-page {
  padding: 0 4px;
  color: var(--ink-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.reader-follow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 4px 0 10px;
  color: var(--ink-2);
  font-size: 11px;
  cursor: pointer;
  user-select: none;
}
.reader-follow input {
  appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  border: 1.5px solid var(--border-3);
  border-radius: 4px;
  display: grid;
  place-content: center;
  cursor: pointer;
}
.reader-follow input::before {
  content: "";
  width: 8px;
  height: 4.5px;
  border-left: 1.6px solid var(--on-accent);
  border-bottom: 1.6px solid var(--on-accent);
  transform: rotate(-45deg) scale(0);
  margin-top: -2px;
  transition: transform var(--dur-feedback) var(--ease-spring);
}
.reader-follow input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.reader-follow input:checked::before {
  transform: rotate(-45deg) scale(1);
}
.reader-position {
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.reader-position::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: var(--border-2);
}
.reader-position::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border: 2px solid var(--overlay);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.reader-position::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: var(--border-2);
}
.reader-position::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid var(--overlay);
  border-radius: 50%;
  background: var(--accent);
}
.reader-position:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* 版本差异：完整变更段，三块各自着色，不在字符级别伪造 patch */
.diff-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.diff-block {
  border: 1px solid var(--border-1);
  border-radius: 8px;
  overflow: hidden;
}
.diff-block .diff-label {
  height: 26px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  border-bottom: 0.5px solid var(--divider);
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.diff-block pre {
  margin: 0;
  padding: 10px 12px;
  max-height: calc(42vh / var(--zoom));
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-2);
}
.diff-block.removed {
  border-color: color-mix(in srgb, var(--danger) 26%, var(--border-1));
  background: color-mix(in srgb, var(--danger) 4%, var(--canvas));
}
.diff-block.removed pre {
  color: var(--danger-ink);
}
.diff-block.added {
  border-color: color-mix(in srgb, #3d8a5c 26%, var(--border-1));
  background: color-mix(in srgb, #3d8a5c 4%, var(--canvas));
}
.diff-block.added pre {
  color: #2f6b45;
}
html[data-agent-theme="dark"] .diff-block.removed pre {
  color: #e69a92;
}
html[data-agent-theme="dark"] .diff-block.added pre {
  color: #8fc9a2;
}
