:root {
  --app-bg: #18222d;
  --app-surface: #232e3c;
  --app-card: #232e3c;
  --app-text: #f5f5f5;
  --app-muted: #8b9db1;
  --app-link: #6cbcff;
  --app-accent: #5db2ff;
  --app-accent-text: #ffffff;
  --app-danger: #ff7a7a;
  --app-border: rgba(245, 245, 245, 0.16);
  --app-danger-soft: rgba(255, 122, 122, 0.14);
  --app-tab-bg: rgba(35, 46, 60, 0.78);
  --app-tab-bg-hover: rgba(35, 46, 60, 0.95);
  --app-accent-soft: rgba(93, 178, 255, 0.28);
  --app-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  --app-soft-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
  --app-overlay: rgba(0, 0, 0, 0.62);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial;
  background: var(--app-bg);
  color: var(--app-text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.wrap {
  max-width: 920px;
  margin: 24px auto;
  padding: 18px;
}

.muted {
  color: var(--app-muted);
  font-size: 13px;
}

.error {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--app-danger);
  background: var(--app-danger-soft);
  border-radius: 8px;
  color: var(--app-danger);
}

.hidden {
  display: none;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.tab {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--app-tab-bg);
  border: 1px solid var(--app-border);
  color: var(--app-text);
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.14s ease;
}

.tab:hover {
  background: var(--app-tab-bg-hover);
}

.tab.right {
  margin-left: auto;
}

.tab.active {
  background: var(--app-accent);
  color: var(--app-accent-text);
  box-shadow: var(--app-soft-shadow);
}

button.tab {
  background: transparent;
  border: none;
  color: inherit;
}

.tabs .tab-icon {
  width: 46px;
  height: 46px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  color: var(--app-muted);
  background: var(--app-tab-bg);
  border: 1px solid var(--app-border);
  box-shadow: var(--app-soft-shadow);
}

.tabs .tab-icon:hover {
  transform: translateY(-1px);
  background: var(--app-tab-bg-hover);
}

.tabs .tab-icon:active {
  transform: translateY(0);
}

.tabs .tab-icon:focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

.tabs .tab-icon.active {
  color: var(--app-accent-text);
  background: var(--app-accent);
  box-shadow: 0 12px 24px var(--app-accent-soft), var(--app-soft-shadow);
}

.tabs .tab-icon .tab-glyph {
  font-size: 22px;
  line-height: 1;
  font-variation-settings: "FILL" 0, "wght" 300, "GRAD" 0, "opsz" 24;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
  user-select: none;
}

.tabs .tab-icon.right {
  margin-left: auto;
}

.card {
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
  box-shadow: var(--app-soft-shadow);
}

.suggestions {
  position: relative;
  background: transparent;
  margin-top: 6px;
  max-height: 240px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--app-border);
}

.suggestion {
  padding: 8px 10px;
  background: var(--app-tab-bg);
  border-bottom: 1px solid var(--app-border);
  cursor: pointer;
}

.suggestion:hover {
  background: var(--app-tab-bg-hover);
}

.suggestion.empty {
  color: var(--app-muted);
  cursor: default;
}

.row {
  margin-top: 6px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

input,
select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  color: var(--app-text);
}

input::placeholder {
  color: var(--app-muted);
}

label {
  display: block;
  margin-top: 12px;
}

button.primary {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--app-accent);
  border: none;
  color: var(--app-accent-text);
  cursor: pointer;
  box-shadow: var(--app-soft-shadow);
}

.tools-import-example {
  margin-top: 10px;
  border: 1px dashed var(--app-border);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--app-tab-bg);
}

.tools-import-example summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--app-text);
}

.tools-import-example pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: var(--app-muted);
}

.status-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--app-border);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--app-surface);
  color: var(--app-text);
  font-weight: 700;
}

.avatar-sm {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

.avatar-md {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 22px;
}

.avatar-fallback {
  background: var(--app-accent);
  color: var(--app-accent-text);
}

.user-link {
  padding: 0;
  border: none;
  background: none;
  color: var(--app-link);
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
}

.user-link:hover {
  color: var(--app-text);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--app-link);
}

.mini-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  flex-shrink: 0;
}

.mini-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: var(--app-text);
}

.tiny-avatar {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  flex-shrink: 0;
}

.tiny-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-weight: 700;
  color: var(--app-text);
}

.suggestion-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#toSuggestions .suggestion {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 12px;
}

#toSuggestions .suggestion:last-child {
  border-bottom: none;
}

#toSuggestions .suggestion-user {
  gap: 8px;
}

#toSuggestions .tiny-avatar {
  width: 16px;
  height: 16px;
}

#toSuggestions .tiny-avatar-fallback {
  font-size: 8px;
}

.compact-photo {
  display: block;
  max-width: 140px;
  max-height: 140px;
  border-radius: 8px;
  object-fit: cover;
  margin-top: 8px;
  border: 1px solid var(--app-border);
}

.compact-photo-sm {
  display: block;
  max-width: 96px;
  max-height: 96px;
  border-radius: 8px;
  object-fit: cover;
  margin-top: 8px;
  border: 1px solid var(--app-border);
}

.profile-top {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.profile-avatar-editor {
  position: relative;
  width: 110px;
  height: 110px;
}

.profile-avatar-preview {
  width: 110px;
  height: 110px;
}

.profile-avatar-preview .profile-avatar-large {
  width: 110px;
  height: 110px;
  font-size: 36px;
}

.profile-avatar-corner-actions {
  position: absolute;
  top: -10px;
  right: -10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-avatar-icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--app-border);
  background: rgba(125, 133, 145, 0.92);
  color: #f3f4f6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--app-soft-shadow);
}

.profile-avatar-icon-btn:hover {
  background: rgba(112, 121, 134, 0.98);
}

.profile-avatar-icon-btn:focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: 1px;
}

.profile-avatar-icon-btn .material-symbols-outlined {
  font-size: 16px;
  line-height: 1;
}

.profile-avatar-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0, 0, 0, 0);
  overflow: hidden;
}

.profile-theme-note {
  margin-top: 6px;
}

.avatar-crop-modal {
  max-width: 430px;
}

.avatar-crop-note {
  margin-top: 6px;
}

.avatar-crop-stage {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.avatar-crop-canvas {
  width: min(78vw, 320px);
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  touch-action: none;
  cursor: grab;
}

.avatar-crop-canvas.dragging {
  cursor: grabbing;
}

.avatar-crop-zoom-label {
  margin-top: 10px;
}

.profile-modal-card {
  max-width: 460px;
}

.profile-modal-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.profile-modal-head h3 {
  margin: 0;
}

.profile-name-link {
  color: var(--app-text);
  text-decoration: underline;
}

.profile-open-btn {
  padding: 0;
  background: none;
  border: none;
  color: var(--app-text);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: var(--app-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--app-card);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  padding: 16px;
  border-radius: 12px;
  max-width: 520px;
  width: 92%;
  box-shadow: var(--app-shadow);
}

.modal-card img {
  max-width: 420px;
  border-radius: 8px;
}

.image-viewer-overlay {
  position: fixed;
  inset: 0;
  background: var(--app-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 12px;
}

.image-viewer-img {
  max-width: 95vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 10px;
}

.image-viewer-close {
  position: fixed;
  top: 12px;
  right: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--app-accent);
  color: var(--app-accent-text);
  border: none;
  cursor: pointer;
}

.header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.tools-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.tools-toolbar h2 {
  margin-bottom: 0;
}

.tools-search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  background: var(--app-tab-bg);
  border: 1px solid var(--app-border);
  color: var(--app-text);
  box-shadow: var(--app-soft-shadow);
}

.tools-search-toggle:hover {
  background: var(--app-tab-bg-hover);
}

.tools-search-toggle .material-symbols-outlined {
  font-size: 22px;
  line-height: 1;
  user-select: none;
}

#toolSearchPanel {
  margin-top: 8px;
}

.suggestion-tool {
  width: 100%;
  text-align: left;
  border: none;
  color: var(--app-text);
  font: inherit;
}

.suggestion-tool:focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: -2px;
}

.suggestion-meta {
  font-size: 12px;
  margin-top: 2px;
}

h1 {
  margin: 0;
  font-size: 28px;
}

@media (max-width: 640px) {
  .wrap {
    padding: 12px;
  }

  h1 {
    font-size: 22px;
  }

  .tabs {
    gap: 8px;
  }

  .tabs .tab-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .tabs .tab-icon .tab-glyph {
    font-size: 20px;
  }
}
