:root {
  --ta-bg: #f5f2ec;
  --ta-surface: #ffffff;
  --ta-surface-muted: #f0ece4;
  --ta-ink: #2c2a26;
  --ta-ink-muted: #6d675d;
  --ta-line: rgba(44, 42, 38, 0.12);
  --ta-accent: #3f5f73;
  --ta-accent-soft: rgba(63, 95, 115, 0.12);
  --ta-accent-ink: #ffffff;
  --ta-warn: #b07a2a;
  --ta-ok: #3e6b4f;
  --ta-radius: 14px;
  --ta-shadow: 0 12px 32px rgba(44, 42, 38, 0.08);
  --ta-sidebar-width: 232px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: var(--ta-ink);
  background: var(--ta-bg);
}

.ta-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.ta-shell {
  width: min(1060px, calc(100% - 48px));
  max-width: 100%;
  margin: 0 auto;
  padding: 28px 0 40px;
}

.ta-topbar,
.ta-workspace-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ta-topbar > *,
.ta-workspace-topbar > *,
.ta-workspace-meta > *,
.ta-hero-actions > *,
.ta-products > *,
.ta-scenario-grid > *,
.ta-overview-grid > *,
.ta-quick-actions > *,
.ta-section-grid > *,
.ta-list-item-meta > * {
  min-width: 0;
}

.ta-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.ta-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--ta-accent) 0 45%, transparent 45%),
    linear-gradient(45deg, var(--ta-accent-soft) 0 60%, var(--ta-accent) 60%);
  display: inline-block;
}

.ta-brand-name {
  font-weight: 700;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.ta-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
}

.ta-badge-preview {
  background: var(--ta-accent-soft);
  color: var(--ta-accent);
}

.ta-hero {
  margin: 64px 0 36px;
  max-width: 760px;
}

.ta-eyebrow {
  color: var(--ta-accent);
  font-weight: 600;
  margin: 0 0 12px;
}

.ta-hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.2;
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}

.ta-hero-copy {
  color: var(--ta-ink-muted);
  line-height: 1.8;
  margin: 0 0 24px;
  overflow-wrap: anywhere;
}

.ta-hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.ta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--ta-line);
  background: var(--ta-surface);
  color: var(--ta-ink);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  max-width: 100%;
}

.ta-btn-primary {
  background: var(--ta-accent);
  border-color: var(--ta-accent);
  color: var(--ta-accent-ink);
}

.ta-btn-block {
  width: 100%;
}

.ta-btn-note,
.ta-login-hint,
.ta-login-security {
  color: var(--ta-ink-muted);
  font-size: 13px;
}

.ta-products {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 18px;
  margin: 32px 0;
}

.ta-product-card,
.ta-section-card,
.ta-stat-card,
.ta-scenario,
.ta-login-card {
  background: var(--ta-surface);
  border: 1px solid var(--ta-line);
  border-radius: var(--ta-radius);
  box-shadow: var(--ta-shadow);
}

.ta-product-card {
  padding: 24px;
}

.ta-product-card,
.ta-scenario,
.ta-section-card,
.ta-stat-card,
.ta-list-item {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ta-product-card h2 {
  margin: 8px 0;
}

.ta-product-card p {
  color: var(--ta-ink-muted);
  line-height: 1.7;
}

.ta-product-tag {
  font-size: 12px;
  color: var(--ta-accent);
  background: var(--ta-accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.ta-link {
  color: var(--ta-accent);
  text-decoration: none;
  font-weight: 600;
}

.ta-link-btn {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font-size: 14px;
}

.ta-scenarios h2,
.ta-flow h2 {
  font-size: 20px;
}

.ta-scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 14px;
}

.ta-scenario {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ta-scenario span {
  color: var(--ta-ink-muted);
}

.ta-flow-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.ta-flow-steps li {
  position: relative;
  background: var(--ta-surface);
  border: 1px solid var(--ta-line);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.ta-flow-steps li + li::before {
  content: "→";
  position: absolute;
  left: -14px;
  color: var(--ta-accent);
}

.ta-footer {
  margin-top: 40px;
  color: var(--ta-ink-muted);
  font-size: 13px;
  border-top: 1px solid var(--ta-line);
  padding-top: 16px;
}

/* Login */
.ta-login {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ta-login-card {
  width: min(420px, 100%);
  padding: 28px;
  min-width: 0;
}

.ta-login-card h1 {
  font-size: 22px;
  margin: 18px 0 8px;
}

.ta-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--ta-ink-muted);
  font-size: 13px;
}

.ta-field input {
  border: 1px solid var(--ta-line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--ta-surface);
  color: var(--ta-ink);
}

.ta-login-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  gap: 12px;
}

.ta-login-error {
  color: #a23a2a;
  font-size: 13px;
  line-height: 1.6;
  margin: 12px 0 0;
}

.ta-demo-badge {
  background: rgba(176, 122, 42, 0.14);
  color: var(--ta-warn);
}

/* Real mode must never show the demo badge, even if the hidden attribute is
   overridden by another rule; demo mode keeps the badge visible. */
.ta-real-mode .ta-demo-badge {
  display: none !important;
}

.ta-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Workspace desktop */
.ta-workspace {
  background: var(--ta-bg);
}

.ta-workspace-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--ta-surface);
  border-bottom: 1px solid var(--ta-line);
  padding: 12px 20px;
}

.ta-workspace-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ta-ink-muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.ta-workspace-layout {
  display: grid;
  grid-template-columns: var(--ta-sidebar-width) 1fr;
  min-height: calc(100vh - 62px);
}

.ta-sidebar-desktop {
  background: var(--ta-surface-muted);
  border-right: 1px solid var(--ta-line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ta-nav-item {
  color: var(--ta-ink);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
}

.ta-nav-item:hover,
.ta-nav-item.is-active {
  background: var(--ta-accent-soft);
  color: var(--ta-accent);
}

.ta-workspace-main {
  padding: 24px;
  min-width: 0;
}

.ta-panel {
  display: none;
}

.ta-panel.is-active {
  display: block;
}

.ta-welcome h1 {
  margin: 0 0 8px;
  font-size: 24px;
  overflow-wrap: anywhere;
}

.ta-welcome p {
  color: var(--ta-ink-muted);
  margin: 0 0 20px;
  overflow-wrap: anywhere;
}

.ta-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.ta-stat-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ta-stat-label {
  color: var(--ta-ink-muted);
  font-size: 13px;
}

.ta-stat-card strong {
  font-size: 28px;
}

.ta-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.ta-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 16px;
}

.ta-section-card {
  padding: 18px;
  margin-bottom: 16px;
}

.ta-section-card h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.ta-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ta-list-item {
  border: 1px solid var(--ta-line);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ta-list-item-title {
  font-weight: 600;
}

.ta-list-item-meta {
  color: var(--ta-ink-muted);
  font-size: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}

.ta-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--ta-surface-muted);
  overflow: hidden;
  min-width: 0;
}

.ta-progress > span {
  display: block;
  height: 100%;
  background: var(--ta-accent);
  border-radius: 999px;
}

.ta-status {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--ta-accent-soft);
  color: var(--ta-accent);
}

.ta-status-warn {
  background: rgba(176, 122, 42, 0.14);
  color: var(--ta-warn);
}

.ta-status-ok {
  background: rgba(62, 107, 79, 0.14);
  color: var(--ta-ok);
}

.ta-empty {
  color: var(--ta-ink-muted);
  font-size: 13px;
}

.ta-dev-note {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(176, 122, 42, 0.08);
  color: var(--ta-warn);
  font-size: 13px;
}

.ta-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ta-ink);
  color: var(--ta-surface);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--ta-shadow);
  z-index: 50;
}

/* Drawer open only locks vertical background scrolling; it never clips layout. */
body.ta-drawer-open {
  overflow-y: hidden;
}

/* Mobile DOM is hidden on desktop by default. */
.ta-home-mobile,
.ta-workspace-mobile {
  display: none;
}

@media (min-width: 761px) {
  .ta-home-mobile,
  .ta-workspace-mobile {
    display: none;
  }
}

/* ============ Mobile layout: independent DOM ============ */
@media (max-width: 760px) {
  .ta-home-desktop,
  .ta-workspace-desktop {
    display: none;
  }

  .ta-home-mobile,
  .ta-workspace-mobile {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* ---- Mobile home ---- */
  .ta-mobile-home-shell {
    width: auto;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 28px 16px 40px;
    box-sizing: border-box;
  }

  .ta-mobile-home-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
  }

  .ta-mobile-home-header .ta-brand,
  .ta-mobile-home-header .ta-brand-name {
    min-width: 0;
    max-width: 100%;
  }

  .ta-mobile-home-hero {
    margin: 36px 0 28px;
    min-width: 0;
    max-width: 100%;
  }

  .ta-mobile-home-hero > * {
    min-width: 0;
    max-width: 100%;
    width: auto;
  }

  .ta-mobile-eyebrow {
    color: var(--ta-accent);
    font-weight: 600;
    margin: 0 0 12px;
    line-height: 1.6;
  }

  .ta-mobile-home-hero h1 {
    margin: 0 0 16px;
    font-size: clamp(32px, 8.5vw, 38px);
    line-height: 1.14;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .ta-mobile-hero-copy {
    margin: 0 0 20px;
    color: var(--ta-ink-muted);
    line-height: 1.8;
    overflow-wrap: anywhere;
  }

  .ta-mobile-hero-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    min-width: 0;
  }

  .ta-mobile-hero-actions .ta-btn,
  .ta-mobile-hero-actions .ta-btn-note {
    width: 100%;
  }

  .ta-mobile-hero-actions .ta-btn-note {
    line-height: 1.6;
  }

  .ta-mobile-products {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin: 0 0 24px;
    min-width: 0;
  }

  .ta-mobile-product-card {
    background: var(--ta-surface);
    border: 1px solid var(--ta-line);
    border-radius: var(--ta-radius);
    box-shadow: var(--ta-shadow);
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .ta-mobile-product-card h2 {
    margin: 0;
    font-size: 18px;
  }

  .ta-mobile-product-card p {
    margin: 0;
    color: var(--ta-ink-muted);
    line-height: 1.7;
  }

  .ta-mobile-flow,
  .ta-mobile-scenarios {
    margin: 0 0 24px;
    min-width: 0;
    max-width: 100%;
  }

  .ta-mobile-flow h2,
  .ta-mobile-scenarios h2 {
    margin: 0 0 12px;
    font-size: 20px;
  }

  .ta-mobile-flow-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .ta-mobile-flow-steps li {
    background: var(--ta-surface);
    border: 1px solid var(--ta-line);
    border-radius: 10px;
    padding: 12px 14px;
    font-weight: 600;
    min-width: 0;
    max-width: 100%;
  }

  .ta-mobile-scenarios {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .ta-mobile-scenario {
    background: var(--ta-surface);
    border: 1px solid var(--ta-line);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .ta-mobile-scenario span {
    color: var(--ta-ink-muted);
  }

  .ta-mobile-home-footer {
    margin-top: 8px;
  }

  /* ---- Login (minimal corrections only) ---- */
  .ta-login {
    padding: 12px;
  }

  .ta-login-card {
    width: auto;
    max-width: 100%;
    min-width: 0;
    padding: 20px 16px;
  }

  .ta-login-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  /* ---- Mobile workspace ---- */
  .ta-workspace-header-mobile {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--ta-surface);
    border-bottom: 1px solid var(--ta-line);
  }

  .ta-workspace-header-mobile .ta-brand {
    min-width: 0;
    justify-content: flex-start;
  }

  .ta-brand-short {
    display: inline;
    font-weight: 700;
    overflow-wrap: anywhere;
    min-width: 0;
  }

  .ta-menu-toggle,
  .ta-mobile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ta-line);
    background: var(--ta-surface);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ta-ink);
    min-width: 0;
  }

  .ta-mobile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-weight: 700;
    color: var(--ta-accent);
    background: var(--ta-accent-soft);
    flex: 0 0 auto;
  }

  .ta-workspace-main-mobile {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
    padding: 14px 16px 32px;
    box-sizing: border-box;
  }

  .ta-mobile-panel {
    display: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .ta-mobile-panel.is-active {
    display: block;
  }

  .ta-mobile-panel h1 {
    font-size: 20px;
    margin: 0 0 8px;
    overflow-wrap: anywhere;
  }

  .ta-mobile-panel > p {
    color: var(--ta-ink-muted);
    overflow-wrap: anywhere;
  }

  .ta-mobile-overview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 14px;
    min-width: 0;
  }

  .ta-mobile-stat-card {
    background: var(--ta-surface);
    border: 1px solid var(--ta-line);
    border-radius: var(--ta-radius);
    box-shadow: var(--ta-shadow);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .ta-mobile-stat-label {
    color: var(--ta-ink-muted);
    font-size: 13px;
    line-height: 1.4;
  }

  .ta-mobile-stat-card strong {
    font-size: 22px;
  }

  .ta-mobile-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 14px;
    min-width: 0;
  }

  .ta-mobile-quick-actions .ta-btn {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    min-width: 0;
  }

  .ta-mobile-section-card {
    background: var(--ta-surface);
    border: 1px solid var(--ta-line);
    border-radius: var(--ta-radius);
    box-shadow: var(--ta-shadow);
    padding: 14px;
    margin-bottom: 12px;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .ta-mobile-section-card h2 {
    margin: 0 0 10px;
    font-size: 15px;
  }

  .ta-mobile-section-card .ta-list {
    gap: 8px;
  }

  .ta-mobile-section-card .ta-list-item {
    padding: 10px;
    gap: 6px;
  }

  .ta-mobile-section-card .ta-list-item-title {
    font-size: 14px;
  }

  .ta-welcome h1 {
    font-size: 20px;
    margin-bottom: 4px;
  }

  .ta-welcome p {
    font-size: 13px;
    margin-bottom: 14px;
  }

  /* ---- Drawer: fixed, out of normal flow ---- */
  .ta-drawer {
    position: fixed;
    inset-block: 0;
    left: 0;
    width: min(82vw, 320px);
    max-width: calc(100vw - 40px);
    height: 100vh;
    height: 100dvh;
    background: var(--ta-surface);
    border-right: 1px solid var(--ta-line);
    box-shadow: var(--ta-shadow);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    z-index: 100;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
  }

  .ta-drawer.is-open {
    transform: translateX(0);
  }

  .ta-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(20, 20, 20, 0.35);
    border: 0;
    cursor: pointer;
  }

  .ta-drawer-backdrop[hidden] {
    display: none;
  }

  .ta-drawer-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .ta-drawer-line {
    margin: 0;
    color: var(--ta-ink-muted);
    font-size: 13px;
    display: flex;
    gap: 8px;
    overflow-wrap: anywhere;
  }

  .ta-drawer-line strong {
    color: var(--ta-ink);
    min-width: 0;
  }

  .ta-drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .ta-drawer-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--ta-line);
  }
}

@media (max-width: 340px) {
  .ta-mobile-overview-grid,
  .ta-mobile-quick-actions {
    grid-template-columns: 1fr;
  }

  .ta-mobile-stat-card strong {
    font-size: 20px;
  }
}
