/**
 * TimiTopBar SDK v2.2.0 样式
 * 主题仅由挂载配置中的 theme: 'light' | 'dark' 决定，不跟随系统主题。
 */

.tk-topbar-inner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid #e3d9ca;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  font-family: 'DM Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 12px;
  color: #3d352e;
  box-sizing: border-box;
}

.tk-topbar-inner *,
.tk-topbar-inner *::before,
.tk-topbar-inner *::after,
.tk-auth-actions *,
.tk-user-menu *,
.tk-product-dropdown * {
  box-sizing: border-box;
}

.tk-topbar-left,
.tk-topbar-right,
.tk-auth-actions {
  display: flex;
  align-items: center;
}

.tk-topbar-left {
  gap: 4px;
  min-width: 0;
}

.tk-topbar-right {
  gap: 8px;
}

.tk-auth-actions {
  gap: 6px;
  min-height: 34px;
}

.tk-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 6px;
  color: #3d352e;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.tk-brand:hover {
  background: #f1ede5;
  color: #9b6958;
}

.tk-brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  font-size: 16px;
  line-height: 1;
}

.tk-brand-text {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tk-brand-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  user-select: none;
  vertical-align: middle;
  transition: transform 0.2s ease, color 0.2s ease, background 0.15s;
}

.tk-brand-arrow:hover,
.tk-brand-arrow:focus-visible {
  background: #f1ede5;
  color: #475569;
  outline: none;
}

.tk-brand-arrow.tk-brand-arrow-open {
  transform: rotate(180deg);
  color: #475569;
}

.tk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.2s, background 0.15s, color 0.15s;
}

.tk-btn:focus-visible,
.tk-user-trigger:focus-visible,
.tk-user-dropdown a:focus-visible,
.tk-user-dropdown button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.tk-btn-text {
  padding: 6px 10px;
  background: transparent;
  color: #5f564c;
}

.tk-btn-text:hover {
  background: #f1ede5;
  color: #3d352e;
}

.tk-btn-primary {
  background: #3d352e;
  color: #ffffff;
}

.tk-btn-primary:hover {
  background: #2e2721;
}

.tk-user-menu {
  position: relative;
  min-height: 34px;
}

.tk-user-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: min(260px, 55vw);
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #5f564c;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  transition: background 0.15s;
}

.tk-user-trigger:hover {
  background: #f1ede5;
}

.tk-user-name {
  max-width: 120px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.tk-user-arrow {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 10px;
}

.tk-badge {
  display: inline-block;
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 3px;
  background: #f1ede5;
  color: #756b60;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.tk-badge-free {
  background: #f1ede5;
  color: #756b60;
}

.tk-badge-pro {
  background: #ede9fe;
  color: #6d28d9;
}

.tk-badge-lifetime {
  background: #fef3c7;
  color: #9a3412;
}

.tk-user-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  display: none;
  min-width: 180px;
  padding: 4px;
  border: 1px solid #e3d9ca;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(61, 53, 46, 0.12);
  z-index: 200;
}

.tk-user-dropdown.tk-user-dropdown-open {
  display: block;
  animation: tk-dropdown-fadein 0.15s ease;
}

.tk-user-dropdown.tk-user-dropdown-has-status {
  width: 270px;
  max-width: calc(100vw - 16px);
}

@keyframes tk-dropdown-fadein {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.tk-user-dropdown a,
.tk-user-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #5f564c;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.tk-user-dropdown a:hover,
.tk-user-dropdown button:hover {
  background: #f8f5ef;
  color: #3d352e;
}

.tk-menu-icon {
  width: 16px;
  flex: 0 0 16px;
  font-size: 13px;
  text-align: center;
}

.tk-menu-danger {
  color: #c62828 !important;
}

.tk-menu-danger:hover {
  background: #fef2f2 !important;
  color: #b91c1c !important;
}

.tk-dropdown-divider {
  height: 1px;
  margin: 4px 0;
  background: #ebe4d8;
}

.tk-status-section {
  padding: 6px 10px 8px;
}

.tk-status-title {
  margin-bottom: 6px;
  color: #756b60;
  font-size: 10px;
  font-weight: 600;
}

.tk-status-content {
  min-height: 20px;
}

.tk-status-row,
.tk-status-progress-head,
.tk-status-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tk-status-row + .tk-status-row {
  margin-top: 5px;
}

.tk-status-label,
.tk-status-progress-head,
.tk-status-message,
.tk-status-note {
  color: #756b60;
  font-size: 11px;
}

.tk-status-value {
  min-width: 0;
  color: #3d352e;
  font-size: 11px;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.tk-status-progress-block {
  margin-top: 8px;
}

.tk-status-progress-head {
  margin-bottom: 4px;
}

.tk-status-progress {
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: #ebe4d8;
}

.tk-status-progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #2f7d67;
  transition: width 0.2s ease;
}

.tk-status-warning,
.tk-status-progress-block.tk-status-warning .tk-status-progress-head {
  color: #b45309;
}

.tk-status-progress-block.tk-status-warning .tk-status-progress > span {
  background: #d97706;
}

.tk-status-danger,
.tk-status-progress-block.tk-status-danger .tk-status-progress-head {
  color: #b91c1c;
}

.tk-status-progress-block.tk-status-danger .tk-status-progress > span {
  background: #dc2626;
}

.tk-status-success {
  color: #047857;
}

.tk-status-note {
  margin-top: 7px;
  line-height: 1.45;
}

.tk-status-error {
  color: #b91c1c;
  font-size: 11px;
}

.tk-user-dropdown .tk-status-retry {
  width: 24px;
  min-width: 24px;
  height: 24px;
  padding: 0;
  justify-content: center;
  color: #b91c1c;
  font-size: 15px;
}

.tk-product-dropdown {
  position: fixed;
  width: 280px;
  padding: 8px 0;
  border: 1px solid #e3d9ca;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(61, 53, 46, 0.12);
  color: #3d352e;
  font-family: 'DM Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 12px;
  z-index: 10000;
}

.tk-product-dropdown.tk-enhance-dropdown {
  display: none;
}

.tk-product-dropdown.tk-enhance-dropdown.tk-dropdown-open {
  display: block;
  animation: tk-dropdown-fadein 0.15s ease;
}

.tk-dropdown-title {
  padding: 4px 16px 8px;
  color: #756b60;
  font-size: 11px;
  font-weight: 500;
}

.tk-dropdown-group {
  padding: 0;
}

.tk-dropdown-item {
  position: relative;
  display: flex;
  align-items: center;
  padding: 8px 16px;
  color: #3d352e;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.tk-dropdown-item:hover,
.tk-dropdown-item:focus-visible {
  background: #f8f5ef;
  outline: none;
}

.tk-dropdown-item-current {
  background: #f1ede5;
  color: #8b5e4f;
  font-weight: 600;
}

.tk-dropdown-item-current::after {
  content: '✓';
  margin-left: auto;
  color: #8b5e4f;
  font-size: 13px;
}

.tk-dropdown-item-icon {
  margin-right: 8px;
  color: #756b60;
  font-size: 11px;
}

.tk-dropdown-item-external::after {
  content: '↗';
  margin-left: auto;
  color: #64748b;
  font-size: 11px;
}

.tk-dropdown-footer {
  padding: 8px 16px 4px;
}

.tk-dropdown-footer-text {
  color: #756b60;
  font-size: 11px;
  line-height: 1.5;
}

.tk-dropdown-footer-link {
  display: inline-block;
  margin-top: 2px;
  color: #8b5e4f;
  cursor: pointer;
  font-size: 11px;
  text-decoration: none;
}

.tk-dropdown-footer-link:hover {
  text-decoration: underline;
}

.tk-user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: #5f564c;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.tk-user-menu-item:hover {
  background: #f8f5ef;
  color: #3d352e;
}

/* 显式暗色主题。没有系统主题媒体查询，避免改变宿主产品的固定主题。 */
.tk-theme-dark .tk-topbar-inner {
  background: rgba(30, 41, 59, 0.92);
  border-bottom-color: #334155;
  color: #e2e8f0;
}

.tk-theme-dark .tk-brand {
  color: #e2e8f0;
}

.tk-theme-dark .tk-brand:hover {
  background: #334155;
  color: #93c5fd;
}

.tk-theme-dark .tk-brand-arrow,
.tk-brand-arrow.tk-theme-dark {
  color: #94a3b8;
}

.tk-theme-dark .tk-brand-arrow:hover,
.tk-theme-dark .tk-brand-arrow:focus-visible,
.tk-brand-arrow.tk-theme-dark:hover,
.tk-brand-arrow.tk-theme-dark:focus-visible {
  background: #334155;
  color: #e2e8f0;
}

.tk-theme-dark .tk-btn-text {
  color: #e2e8f0;
}

.tk-theme-dark .tk-btn-text:hover,
.tk-theme-dark .tk-user-trigger:hover {
  background: #334155;
  color: #ffffff;
}

.tk-theme-dark .tk-btn-primary {
  background: #f8fafc;
  color: #1e293b;
}

.tk-theme-dark .tk-btn-primary:hover {
  background: #e2e8f0;
}

.tk-theme-dark .tk-user-trigger {
  color: #e2e8f0;
}

.tk-theme-dark .tk-badge-free {
  background: #334155;
  color: #cbd5e1;
}

.tk-theme-dark .tk-user-dropdown,
.tk-theme-dark .tk-product-dropdown,
.tk-product-dropdown.tk-theme-dark {
  background: #1e293b;
  border-color: #475569;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.tk-theme-dark .tk-user-dropdown a,
.tk-theme-dark .tk-user-dropdown button,
.tk-theme-dark .tk-dropdown-item,
.tk-product-dropdown.tk-theme-dark .tk-dropdown-item {
  color: #e2e8f0;
}

.tk-theme-dark .tk-user-dropdown a:hover,
.tk-theme-dark .tk-user-dropdown button:hover,
.tk-theme-dark .tk-dropdown-item:hover,
.tk-theme-dark .tk-dropdown-item:focus-visible,
.tk-product-dropdown.tk-theme-dark .tk-dropdown-item:hover,
.tk-product-dropdown.tk-theme-dark .tk-dropdown-item:focus-visible {
  background: #334155;
  color: #ffffff;
}

.tk-theme-dark .tk-dropdown-title,
.tk-theme-dark .tk-dropdown-footer-text,
.tk-product-dropdown.tk-theme-dark .tk-dropdown-title,
.tk-product-dropdown.tk-theme-dark .tk-dropdown-footer-text {
  color: #cbd5e1;
}

.tk-theme-dark .tk-dropdown-divider,
.tk-product-dropdown.tk-theme-dark .tk-dropdown-divider {
  background: #475569;
}

.tk-theme-dark .tk-status-title,
.tk-theme-dark .tk-status-label,
.tk-theme-dark .tk-status-progress-head,
.tk-theme-dark .tk-status-message,
.tk-theme-dark .tk-status-note {
  color: #cbd5e1;
}

.tk-theme-dark .tk-status-value {
  color: #f8fafc;
}

.tk-theme-dark .tk-status-progress {
  background: #475569;
}

.tk-theme-dark .tk-dropdown-item-current,
.tk-product-dropdown.tk-theme-dark .tk-dropdown-item-current {
  background: #1e3a5f;
  color: #93c5fd;
}

.tk-theme-dark .tk-dropdown-item-current::after,
.tk-product-dropdown.tk-theme-dark .tk-dropdown-item-current::after {
  color: #93c5fd;
}

.tk-theme-dark .tk-dropdown-item-icon,
.tk-product-dropdown.tk-theme-dark .tk-dropdown-item-icon {
  color: #cbd5e1;
}

.tk-theme-dark .tk-dropdown-footer-link,
.tk-product-dropdown.tk-theme-dark .tk-dropdown-footer-link {
  color: #93c5fd;
}

@media (max-width: 768px) {
  .tk-topbar-inner {
    padding: 0 16px;
  }

  .tk-brand-text {
    max-width: 100px;
  }

  .tk-user-name {
    max-width: 80px;
  }

  .tk-product-dropdown {
    width: calc(100vw - 32px);
    max-width: 280px;
  }

  .tk-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tk-user-dropdown.tk-user-dropdown-open,
  .tk-product-dropdown.tk-enhance-dropdown.tk-dropdown-open {
    animation: none;
  }
}
